0% found this document useful (0 votes)
33 views16 pages

DBMS Journal-2

Uploaded by

sameertest41
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views16 pages

DBMS Journal-2

Uploaded by

sameertest41
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Practical no.

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:

i. Display all the tuples of the table.


ii. Retrieve first and last name of all friends.

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:

i. Display all the tuples of the table.

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.

vi. Display distinct prices.


Practical no.2
 Queries using aggregate, string, and date functions fired on a single
table.

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:

i. Display all the tuples of the table.


ii. Retrieve the names twice.

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.

1. Create a table called EMPLOYEE_TBL containing the attributes emp_id (integer),


emp_name( varchar(15) ) and emp_city( varchar(15) ). All attributes are not null with emp_id as a
primary key.

i. Insert a tuple (12,'Munna Bhai', 'Mumbai').

ii. Can you now insert (12,'Munni Bhai','Pune')?

iii. Try to insert (14,'NULL','Pune'). Do you get any problems?

iv. Insert (15, NULL,'Pune'). Is there any fault message?

v. List all the tuples.


2. Create a table called Man containing the attributes emp_id (integer), emp_name( varchar(15) ),
emp_city( varchar(15) ) , emp_age ( numeric) and emp_dept (numeric). First three attributes are
not null. emp_id is a primary key. Emp_age is the age of employees lie between 31 and 41.
emp_dept is having unique value.

i. Can you insert a tuple (12,'Munna Bhai', 'Mumbai', 31,4)?

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:

i. Can you add a tuple (NULL, ‘Pune’)?

ii. List all the tuples.

iii. Retrieve the city by removing leading and trailing blanks.


iv. Display the names of all publishers with offices in ‘Pune’.

v. List all the positions of the character ‘a’ from name.

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:

ii. Cartesian product of two tables:


iii. Join two tables by left outer join:

iv. Join two tables by right outer join:

You might also like