DBMS Journal-2
DBMS Journal-2
1
Creating a single table without constraints and firing select queries.
1. Friends is an entity set with attributes last name (Lname), first name ( Fname), address, city and
age. Draw E-R diagram. Convert an entity set to table with suitable data types for attributes. Add
5 meaningful records. Fire the following queries:
iii. Fetch all the friends with age more than 25.
iv. Retrieve all friends with Mumbai city and age less than 20 or last name Shah.
v. Retrieve all first and last names with age lies between 20 and 30.
2. Item is an entity set with attributes item number (ino), item name (iname), company, and price.
Draw E-R diagram. Convert an entity set to table with suitable data types for attributes. Add 5
meaningful records. Fire the following queries:
ii. Retrieve ino and item name with three characters of which first character is ‘a’.
iii. Retrieve item name with any number of characters of which last two characters are ‘ap’ of
company.
iv. Fetch item name where item number is 20, 30, 50.
v. Retrieve all item numbers and item names by sorting item name with price lies between 20 and
40.
1. Mailing_list is an entity set with attributes email and name. Convert an entity set to table with
suitable data types for attributes. Add 5 meaningful records. Fire the following queries:
2. Create a table called Employee containing attributes emp_id (integer), name ( varchar(15) ),
emp_age ( numeric) and salary (numeric). Add 5 meaningful records. Fire the following queries:
iii. Reverse the salary for the emp_id = 12 and display name and salary.
iv. Return three characters of a name from right and display name and salary.
v. Return two characters of a name from left and display name with salary less than 15000.
3. Create a table called Person with attributes name, dob and salary. Add 5meaningful records. Fire
the following queries:
Practical no.3
Creating single table with constraints and executing queries.
ii. What result you get if you insert (14,'Tina Mehta','Mumbai', 21, 5)?
iii. Try to insert (15,'Heena Mehta', 'Pune', 41, 4). Do you get any problems?
iv. List all the tuples and add 4 more tuples which are satisfied by above constraints.
v. List the name and the maximum age of a person residing in Mumbai.
vi. Retrieve all the names in upper letters for age between 32 and 39.
3. Create a table called Publishers with attributes name and city. Attribute name is defined as unique
with city taken only from ‘Mumbai’, ‘Pune’, ‘Nasik’, ‘Panji’. Profit is defined as not null and lies
between Rs.10, 000 to Rs.50, 000.Insert 5 records. Fire the following queries:
vi. Display the name of a publisher getting maximum and minimum profit.
vii. Display the sum of profit that lies between 11,000 to 13,000.
Practical no.4
Creating and altering a single table and executing queries.
Practical no.5
Joining tables and executing queries.
1. Create relations for schema
i. Create table mailing_list(email varchar(30) not null primary key, name varchar(30));
ii. Create table phone_list(email varchar(30) not null references mailing_list, phone_number
varchar(10) not null);
Insert 5 records and fire the following Queries:
i. Join the above relations and make comment on the result that you get: