Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Q 1.

Create the following tables (Primary keys are underlined)


Employee (emp_no, emp_name, address, city, birth_date, designation, salary)
Department (Dept_no, dept_name, location)

There exists a one-to-many relationship between Department and Employee.


Create the relations accordingly, so that the relationship is handled properly and the
relations are in normalized form (3NF) and insert 5 records into each table.
Solve the following queries.
a) Find the details of employee who’s salary is greater than 10000.
b) Delete all employees of department 20.
c) List the names and salary of employees having location ‘Pune’

Q.2) Practical Questions on PostgreSQL


Consider the following database maintained by a college. It gives information about students and
the teachers along with the subject taught by the teacher and the marks obtained by the student in
the subject.
Following are the tables:
STUDENT (SNO INTEGER, S_NAME CHAR (30), S_CLASS CHAR (10), S_ADDR CHAR (50))
TEACHER (TNO INTEGER, T_NAME CHAR (20), QUALIFICATION CHAR
(15), EXPERIENCE INTEGER)
The relationship is as follows:
STUDENT-TEACHER: M-M with descriptive attribute as subject name and marks.

A) Execute the following queries


1. Change the name of the student as ‘Ram Pande’ having SNO is 20.
2. Find the list of teachers having qualification “Ph. D.”.
B) Create a view (Any one)
1.Create a view containing details of all the teachers teaching the subject
‘Mathematics’.
2. Create a view to list the details of all the students who are taught by a teacher
having experience of more than 3 years.

Q 1) Create the following tables (Primary keys are underlined)


Bus (bus_no, capacity, depot_name)
Route (route_no, source, destination, no_of_stations)
Driver (driver_no, driver_name, license_no, address, age, salary)
Constraints: License number must be unique.
Relationships:
Route - Bus: 1 to Many.
Bus - Driver: Many to Many with descriptive attribute shift (‘morning’ or ‘evening’)
and date of duty.
Create the relations accordingly, so that the relationship is handled properly and the relations
are in normalized form (3NF) and insert 5 records into each table.
Solve the following queries(Any 3)
a) List buses with capacity greater than 20.
b) List driver details with maximum salary.
c) List the details of all drivers working on _____ date.
d) Delete all the records of driver who’s age is 61.

Q.2) Practical Questions on PostgreSQL.


Consider the following Student –Marks database
Student (rollno integer, name varchar (30), address varchar (50), class varchar (10))
Subject (scode varchar (10), subject_name varchar (20))
Student-Subject are related with M-M relationship with attributes marks_scored.
A) Execute the following queries
1. Change the names of students having class ‘FY’ and rollno is ‘13’
2. List the names of all the subjects in descending order.
B) Create a view (Any one)
1. Write a view to list student name, class &total marks scored by each student,
sorted by student name.
2. Write a view to list student names along with subject name who is belongs to class
‘SY’.

Q.1) Create the following relations (Primary keys are underlined)


Doctor (doctor_code,doctor_name, Area_name)
Patient (Patient_code, Patient_name)
Doctor and patient are related with many to many relationships.
Solve the following queries

1. Display the names of doctors working in_____ area.


2. Update the patient name who’s code is ‘110’.
3. List the names of all the Patients in descending order.
Q.2) Practical Questions on PostgreSQL
Consider the following database maintained by a school about students and
competitions.
STUDENT (sreg_no int , name char(30), class char(10))
COMPETITION (c_no int , name char(20), C_type char(15))
The relationship is as follows:
STUDENT-COMPETITION: M-M with described attributes rank and year.
A) Execute the following queries
1. Change the rank to 1st of student “Kiran Gandhi” which has taken part drawing
Competition.
2. List out all the competitions held in the school for class 5 th.

B) Create a view (Any one)


1. To display competition held under ‘Sports’ type.
2. Update the name of competition whose C_type is ‘541’
3. To contain student name, class, competition name, rank and year. The list should
be sorted by student name.
Q.1) Create the following relations (Primary keys are underlined)
Car (car_code, c_name, c_price , color , model)
Customer (cust_code, cust_name, cust_address , lic_no )
There exists a many-to-many relationship between car and customer.
Solve the following queries.
1) List the car names having price is less than 10 lakhs.
2) Display all customer name who’s name starts with ‘P’.
3) List all the car names having color ‘Red’.

Q.2) Practical Questions on PostgreSQL.

Consider the following Person–Area database


Person (pnumber integer, pname varchar (20), birthdate date, income money)
Area ( aname varchar (20), area-type varchar (5) )
An area can have one or more persons living in it, but a person belongs to exactly one area.
The attribute ‘area_type’ can have values either ‘urban’ or ‘rural’
A) Execute the following queries
1. List the names of all people living in ‘_______’ area.
2. List the details of all people whose names start with the alphabet ‘__’.
B) Create a view (Any one)

1) Whose birthday falls in the month of_______.


2) List the names of person whose income is same.

Q.1) Create the following tables (Primary keys are underlined)


Customer (custno, custname, custaddress)
account (actno, acctype, balance)

Relationship between Customer and account is one-to-many.


Constraints:
Create the relations accordingly, so that the relationship is handled properly and the relations
are in normalized form(3NF) and insert 5 records into each table
Solve the following queries
a) List the names of customer whose address is Pune.
b) Display all the details of customer whose customer no is ‘202’.
c) Change the account type of the customer having account no is ‘153’.

Q.2) Practical Questions on PostgreSQL

Consider the following Project-Employee database maintained by a company which


stores the details of the projects assigned to the employees.
Following are the tables:
PROJECT (pno integer, p_name char (30), ptype char(20),duration integer)
EMPLOYEE (eno integer, e_name char (20), qualification char (15), joindate date)
The relationships are as follows:
PROJECT-EMPLOYEE:M-M Relationship, with descriptive attributes as start_date (date),
no_of_hours_worked (integer).
A) Execute the following queries.(Any two)
1. List the names of the employees whose qualification is BE.
2. Find the names of the employees whose joining date is _________.
3. Find the employee number and name, who do not work on project “Robotics”.

B) Create a view (Any one)


1. Create a view containing the project name, project type and duration.
2. Create a view over the employee table which contains only employee name and his
qualification and it should be sorted on employee name.

Q.1) Create the following tables (Primary keys are underlined)


Politician(pno,pname,pdesc)
Party(party_code,party_name)
Politician & party are related with many-to-one.
Create the relations accordingly,so that the relationship is handled properly and the relations
are in normalized form(3NF) and insert 5 records into each table.
Solve the following queries

a) Display details of all politician of party ‘BJP’.


b) display name of party which has party code ‘586’
c) Update the party name from BJP to Shivsena whose party code is 101
Q.2) Practical Questions on PostgreSQL
Consider the following database maintained by a college. It gives information about students and
the teachers along with the subject taught by the teacher and the marks obtained by the student in
the subject.
Following are the tables:
STUDENT (SNO INTEGER, S_NAME CHAR (30), S_CLASS CHAR (10), S_ADDR CHAR (50))
TEACHER (TNO INTEGER, T_NAME CHAR (20), QUALIFICATION CHAR
(15), EXPERIENCE INTEGER)
The relationship is as follows:
STUDENT-TEACHER: M-M with descriptive attribute as subject name and marks.

A) Execute the following queries


1. Change the name of the student as ‘Jay Kolse’ having SNO is 85.
2. Find the list of teachers having qualification “SET/NET.”
B) Create a view (Any one)
1. Create a view containing details of all the teachers teaching the subject
‘Mathematics’.
2. Create a view to list the details of all the students who are taught by a teacher
having experience of more than 3 years.

Q 1) Create the following tables (Primary keys are underlined)

Item (item_no,name,quantity)
Supplier(sno,name,addr,city,phone)
Item & supplier are related with many-to-many relationships.
Create the relations accordingly, so that the relationship is handled properly and the relations
are in normalized form(3NF) and insert 5 records into each table.
Solve the following queries
a) List all the details of items having quantity > 500
b) Increase the 5% rate of the item mouse.
c) Display all the supplier who’s city is ‘Mumbai’.
Q.2) Practical Questions on PostgreSQL

Consider the following Project-Employee database maintained by a company which


stores the details of the projects assigned to the employees.
Following are the tables:
PROJECT (pno integer, p_name char (30), ptype char(20),duration integer)
EMPLOYEE (eno integer, e_name char (20), qualification char (15), joindate date)
The relationships are as follows:
PROJECT-EMPLOYEE:M-M Relationship, with descriptive attributes as start_date (date),
no_of_hours_worked (integer).
C) Execute the following queries. (Any Two)
1. List the names of the employees whose qualification is BE.
2. Find the names of the employees whose joining date is _________.
3. Find the employee number and name, who do not work on project “Robotics”.

D) Create a view (Any one)


1. Create a view containing the project name, project type and duration.
2. Create a view over the employee table which contains only employee name and his
qualification and it should be sorted on employee name.

Q 1) Create the following tables (Primary keys are underlined)


Machine (mno, mname, mtype, mcost)
Part (pno, pnmae, pdesc)
Machine and parts are related with one to many relationships
Constraints:
Primary Key mno ,pno,
Machine name not be null.
Create the relations accordingly, so that the relationship is handled properly and the relations
are in normalized form(3NF) and insert 5 records into each table.
Solve the following queries
a) Display all the machine name with its type.
b) List all the parts of ‘CNC’ machine
c) Delete the record from part table whose part name is wheel.

Q.2) Practical Questions on PostgreSQL.

Consider the following database maintained by a school about students and


competitions.
STUDENT (sreg_no int , name char(30), class char(10))
COMPETITION(c_no int , name char(20), C_type char(15))
The relationship is as follows:
STUDENT-COMPETITION: M-M with described attributes rank and year.
A) Execute the following queries.
1. List out all the competitions held in the school for class 10 th in year 2016.
2. List out all the competitions held in the school under ‘academic’ in year 2016.
B) Create a view (Any one)
1. To display competition held under ‘Sports’ type.
2. To list competition name year wise.
3. To contain student name, class, competition name, rank and year. The list should
be sorted by student name.
Q 1) Create the following tables (Primary keys are underlined)

Item (item_no,name,quantity)
Supplier(sno,name,addr,city,phone)
Item & supplier are related with many-to-many relationships.
Create the relations accordingly, so that the relationship is handled properly and the relations
are in normalized form(3NF) and insert 5 records into each table.
Solve the following queries
a) List all the details of items having quantity greater than 500.
b) Increase the 5% rate of the item mouse.
c) Display all the supplier who’s city is ‘Mumbai’.

Q.2) Practical Questions on PostgreSQL.

Consider the following Person–Area database


Person (pnumber integer, pname varchar (20), birthdate date, income money)
Area ( aname varchar (20), area-type varchar (5) )
An area can have one or more persons living in it, but a person belongs to exactly one area.
The attribute ‘area_type’ can have values either ‘urban’ or ‘rural’
A) Execute the following queries
1. List the names of all people living in ‘_______’ area.
2. List the details of all people whose names start with the alphabet ‘__’.
B) Create a view (Any one)

1) Whose birthday falls in the month of_______.


2) List the names of person whose income is same.

Q 1) Create the following tables (Primary keys are underlined)


Sailors (sid, sname, rate,age)
Boats (bid, bname, colour)
Reserves (sid, bid, date)
Sailors and boats are related many to many.
Create the relations accordingly, so that the relationship is handled properly and the relations
are in normalized form(3NF) and insert 5 records into each table.
Solve the following queries.
a) Find all the sailors with a rating above 8.
b) Find the ages of sailors whose name begins and ends with ‘P’.
c) Find name of sailors who have reserved red and green boats.

Q.2) Practical Questions on PostgreSQL


Consider the following database maintained by a school about students and
competitions.
STUDENT (sreg_no int , name char(30), class char(10))
COMPETITION(c_no int , name char(20), C_type char(15))
The relationship is as follows:
STUDENT-COMPETITION: M-M with described attributes rank and year.
A) Execute the following queries
1. Change the rank to 1st of student “Kiran Gandhi” which has taken part drawing
Competition.
2. List out all the competitions held in the school for class 5 th.

B) Create a view (Any one)


1. To display competition held under ‘Sports’ type.
2. Update the name of competition whose C_type is ‘541’
3. To contain student name, class, competition name, rank and year. The list should
be sorted by student name.

Q 1) Create the following tables (Primary keys are underlined)


Customer (cno, cname, city)
Account (ano, acc_type, balance)

Relationship between Customer and Account is one to many.


Create the relations accordingly, so that the relationship is handled properly and the relations
are in normalized form(3NF) and insert 5 records into each table.
Solve the following queries.
a) List the details of customer whose account type saving.
b) List the details of account whose balance between 4000 and 6000.
c) List the details of customer with maximum account balance.

Q.2) Practical Questions on PostgreSQL

Consider the following Bus transport Database.


Bus (bus_no int , capacity int , depot_namevar char(20))
Route( route_no int, source char(20), destination char(20), No_of_stations int)
Driver (driver_no int, driver_name char(20), license_no int, address Char(20), d_age int,
salary float)
Relationships
Bus_Route : M-1 and Bus_Driver : M-M with descriptive attributes date of duty allotted and
shift can be 1(Morning)or 2 ( Evening ).
A) Execute the following queries (Any two)
1. Find out the name of the driver having maximum salary.
2. Delete the record of bus having capacity less than 10.
3. Increase the salary of all drivers by 5% .

B) Create a view (Any one)


1. To display the details of the buses that run on routes 1or 2.
2. To find out the name of the driver who’s salary is greater than 25000.
Q.1) Create the following tables (Primary keys are underlined):

Person (pnumber integer, pname varchar (20), birthdate date, income money)
Area ( aname varchar (20), area-type varchar (5) )
An area can have one or more persons living in it, but a person belongs to exactly one area.
The attribute ‘area_type’ can have values either ‘urban’ or ‘rural’.
Create the relations accordingly,so that the relationship is handled properly and the relations
are in normalized form(3NF) and insert 5 records into each table.

Solve the following queries:

a. List the names of all people living in ‘Pune’ area.


b. List the details of all people whose names start with the alphabet ‘A’
c. Count area wise people whose income is below 3000.

Q.2) Practical Questions on PostgreSQL.

Consider the following database maintained by a school about students and


competitions.
STUDENT (sreg_no int , name char(30), class char(10))
COMPETITION(c_no int , name char(20), C_type char(15))
The relationship is as follows:
STUDENT-COMPETITION: M-M with described attributes rank and year.
A) Execute the following queries.

1. List out all the competitions held in the school for class 10 th in year 2016.
2. List out all the competitions held in the school under ‘academic’ in year 2016.
B) Create a view (Any one)
1. To display competition held under ‘Sports’ type.
2. To list competition name year wise.
3. To contain student name, class, competition name, rank and year. The list should
be sorted by student name.

Q.1) Practical Questions on PostgreSQL.


Consider the following Book Author Database.
Book (b_no int, b name varchar (20), pub_name varchar (10), b_price float)
Author (a_no int, a_name varchar (20), qualification varchar (15), address varchar (15))
Relationship between Book and Author is many to many.
Constraints: Primary Key, Pub_name should not be null.

Solve the following queries:


1. List book details for which book price is between 300.00 and 500.00.
2. List all author details sorted by their name in descending order.
3. List the details of all books whose names start with the alphabet 'R’.

Q.2) Practical Questions on PostgreSQL


Consider the following database maintained by a school about students and
competitions.
STUDENT (sreg_no int , name char(30), class char(10))
COMPETITION(c_no int , name char(20), C_type char(15))
The relationship is as follows:
STUDENT-COMPETITION: M-M with described attributes rank and year.
A) Execute the following queries( Any two)
1. Delete the student who’s registration no is ‘6’.
2. List out all the competitions held in the school for class 5 th.
3. Display all the student name in descending order.

B) Create a view (Any one)


1. To display competition held under ‘Sports’ type.
2. Update the name of competition whose C_type is ‘541’
3. To contain student name, class, competition name, rank and year. The list should
be sorted by student name.

Q.1) Create the following relations (Primary keys are underlined)


Car (car_code, c_name, c_price , color , model)
Customer (cust_code, cust_name, cust_address , lic_no )
There exists a many-to-many relationship between car and customer.
Solve the following queries.
1) List the car names having price is less than 10 lakhs.
2) Display all customer name who’s name starts with ‘P’.
3) List all the car names having color ‘Red’.

Q.2) Practical Questions on PostgreSQL.


Consider the following Person–Area database
Person (pnumber integer, pname varchar (20), birthdate date, income money)
Area ( aname varchar (20), area-type varchar (5) )
An area can have one or more persons living in it, but a person belongs to exactly one area.
The attribute ‘area_type’ can have values either ‘urban’ or ‘rural’
A) Execute the following queries
1. List the names of all people living in ‘_______’ area.
2. List the details of all people whose names start with the alphabet ‘__’.
B) Create a view (Any one)

1) Whose birthday falls in the month of_______.


2) List the names of person whose income is same.

Q 1) Create the following tables (Primary keys are underlined)


Bus (bus_no, capacity, depot_name)
Route (route_no, source, destination, no_of_stations)
Driver (driver_no, driver_name, license_no, address, age, salary)
Constraints: License number must be unique.
Relationships:
Route - Bus: 1 to Many.
Bus - Driver: Many to Many with descriptive attribute shift (‘morning’ or ‘evening’)
and date of duty.
Create the relations accordingly, so that the relationship is handled properly and the relations
are in normalized form (3NF) and insert 5 records into each table.
Solve the following queries
a) List buses with capacity greater than 20.
b) List driver details with maximum salary.
c) List the details of all drivers working on _____ date.

Q.2) Practical Questions on PostgreSQL


Consider the following Student –Marks database
Student (rollno integer, name varchar (30), address varchar (50), class varchar (10))
Subject (scode varchar (10), subject_name varchar (20))
Student-Subject are related with M-M relationship with attributes marks_scored.
C) Execute the following queries
1. Change the names of students having class ‘FY’ and rollno is ‘13’
2. List the names of all the subjects in descending order.
D) Create a view (Any one)
3. Write a view to list student name, class &total marks scored by each student,
sorted by student name.
4. Write a view to list student names along with subject name who is belongs to class
‘SY’.
Q 1) Create the following tables (Primary keys are underlined)

Item (item_no,name,quantity)
Supplier(sno,name,addr,city,phone)
Item & supplier are related with many-to-many relationships.
Create the relations accordingly, so that the relationship is handled properly and the relations
are in normalized form(3NF) and insert 5 records into each table.
Solve the following queries
a) List all the details of items having quantity > 500
b) Display all the items in descending order.
c) Display all the supplier who’s city is ‘Mumbai’.

Q.2) Practical Questions on PostgreSQL

Consider the following Project-Employee database maintained by a company which


stores the details of the projects assigned to the employees.
Following are the tables:
PROJECT (pno integer, p_name char (30), ptype char(20),duration integer)
EMPLOYEE (eno integer, e_name char (20), qualification char (15), joindate date)
The relationships are as follows:
PROJECT-EMPLOYEE:M-M Relationship, with descriptive attributes as start_date (date),
no_of_hours_worked (integer).
A) Execute the following queries. (Any two)
1. List the names of the employees whose qualification is BE.
2. Find the names of the employees whose joining date is _________.
3. Find the employee number and name, who do not work on project “Robotics”.

B) Create a view (Any one)


1. Create a view containing the project name, project type and duration.
2. Create a view over the employee table which contains only employee name and his
qualification and it should be sorted on employee name.

You might also like