DBMS Lab File - Udit - Dumka
DBMS Lab File - Udit - Dumka
of
Session 2022-23
School of Computing
Index
13 Modify the database structure and drop the record with structure.
2. Alteration of table
School of Computing
Objective:
Practical- 2
Practical- 3
Output:
School of Computing
Objective:
Practical- 4
Objective:
Practical – 4
VI. Alter table by changing the data type of empno to decimal (8).
VII. Delete all the data from employee table.
Answer the following questions related to the above table using SQL queries :
I. Assign ID as primary key for the table and NAME cannot be NULL
School of Computing
II. Add Unique constraint to SALARY
III. Add check constraint on AGE so that user cant enter value of age <=22
VII. Demonstrate some outputs that violate the conditions of mentioned constraints.
School of Computing
Practical - 5
Objective: Implementation of group functions (sum, count, avg, max, min).
Output:
1.Maximum salary in each department
School of Computing
Practical - 6
Objective: Execution of various types of set operations(union, intersect, minus)
Output:
1.Union operation
School of Computing
Practical - 7
Objective: Apply the various types of Integrity Constraints on table.
2. Create a table Orders and Initialize foreign key Constraints as customer_id by refe. to customers
table:
School of Computing
5. Violates the primary key in orders:
School of Computing
Output:
1
2.
3.
4.
5.
6.
7.
8.
9.
School of Computing
10.
11.
12.
13.
Q2. Create two tables
Project (Pid, Pname, Plocation)
Manager (Mid, Mname, Salary, Pid)
*** Pid in Manager table is foreign key referring Project table primary key Pid
Output:
1.
2.
School of Computing
Practical – 9 Objective:
Creation of various types of JOINS.
Output:
1.Inner Join
2.Left Join
3.Right Join
Practical – 10
Objective: Implementation of views in DATABASE and indices in database.
Output:
1.Creation of View
School of Computing
3.Updation of Elements in View Table:
Practical – 11
Ques1.
School of Computing
Output:
1.
2.
3.
4.
5.
6.
7.
8.
9.
School of Computing
10.
11.
12.
13.
14.
School of Computing
15.
Ques 2. Create a table T1 using Default, Check and NOT NULL constraint and show the violation of
each constraint while entering the data into the table. Also create a second table T2 and perform
UNION operation on Table T1 & T2.
Output:
School of Computing
Practical – 12 Objective:
Output:
1.Creation of table using foreign key constraint:
3.Violation of Foreign Key Constraint (Entry of value in referencing table which is not present in
referenced tables)
School of Computing
Practical-14
Problems:
Q1. A database is being constructed for storing sales information system. A product can be
described with a unique product number, product name, selling price, manufacturer name. The
product can sale to a particular client and each client have its own unique client number, client
name, client addresses, city, pin code, state and total balance to be required to paid. Each
client order to buy product from the salesman. In the order, it has unique sales order number,
client number, salesman number (unique).
OUTPUT:
Product Table:
Client Table
Sales Order Table:
• Retrieve the client ids and the states of all the clients.
School of Computing
• Find the names of all clients having ‘S’ as the second letter in their names.
• Find the products whose selling price is greater than 1900 and less than or equal to
3500
• List the names, city and state of the clients not in the state of ‘DELHI’
• List the name of clients who orders a product from city DELHI.
Q2. Suppose that a faculty wants to keep records about the students, the desired records should
maintain this information about each student: (SAPid, Sname, CGPA,
Age, Location and Gender)
a. Create the appropriate Table.
b. Write SQL Queries to answer the following problems: -List the names of all
male students.
-What is the age of the youngest male and female student?
- List the name and the CGPA for all students who got above 7.5 CGPA ordered by their
CGPAs then their names.
-What is the Topper name?
c. Create a course table with cid and cname, SAPid. Also, list the students and the courses
student opted for.
OUTPUT:
a. Create the appropriate Table.
School of Computing
b.List the names of all male students.
Topper name
School of Computing
c.Create a course table with cid and cname, SAPid. Also, list the students and the courses
student opted for.