0% found this document useful (0 votes)
51 views44 pages

DBMS Lab File - Udit - Dumka

A Database Management System (DBMS) is a software system that allows users to define, create, maintain, and manipulate databases. It serves as an interface between the database and the end-users or application programs, providing a centralized platform for managing data efficiently. Here are some key components and functions of a DBMS: Data Definition: DBMS allows users to define the structure of the database schema, including tables, attributes, keys, constraints, and relationships.

Uploaded by

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

DBMS Lab File - Udit - Dumka

A Database Management System (DBMS) is a software system that allows users to define, create, maintain, and manipulate databases. It serves as an interface between the database and the end-users or application programs, providing a centralized platform for managing data efficiently. Here are some key components and functions of a DBMS: Data Definition: DBMS allows users to define the structure of the database schema, including tables, attributes, keys, constraints, and relationships.

Uploaded by

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

Lab Record

of

Database Management System


(CSF205)

Submitted to: Submitted by:


Mr. Anuj Kumar Udit Dumka
Assistant Prof. 210102337(1000015937)
School of Computing CSE-A-P1
DIT University 2 ndYr (4thSem)

Session 2022-23

School of Computing
Index

S. Title of Experiment Remarks


No

1 Implementation of Data Definition language in Query Language.

2 Implementation of Data Manipulation in Query Language.

3 Insertion &Updation of records in Database table

4 Solve the following questions.

5 Implementation of GROUP functions (avg, count, max, min, Sum).

6 Execution of the various type of SET OPERATORS (Union, Intersect,


Minus).

7 Apply the various types of Integrity Constraints on table.

8 Solve the following questions.

9 Creation of various types of JOINS.

10 Implementation of Views and Indices in database.

11 Solve the following questions.

12 Implementation of foreign key on database.

13 Modify the database structure and drop the record with structure.

14 Solve the given questions.


Practical - 1

Objective: Implementation of Data Definition language in Query Language.


Output:
1.Creation of table

2. Alteration of table

3. Data entry in table

4. Truncate the table

5.Drop the table

School of Computing
Objective:

Practical- 2

Implementation of Data Manipulation in query language.


Output:
1.Selcting all columns from table

4.Retrieve data from table according to the requests.

5.Deletion of row from table


Objective:

Practical- 3

Insertion and updating in Database table.

Output:

1.Insertion of data in table

2.Updation of data in table

School of Computing
Objective:

Practical- 4
Objective:

Practical – 4

Q 1. Write SQL statements for:


Output:
I. Creating a table with following information: Name of table: employees, columns and data types:
empno decimal (6) PRIMARY KEY, empnamevarchar (20), empunitvarchar (20);

II. Altering table by adding new column class varchar (20)

III. Inserting data into the employees table{At least 5 rows}

IV. Deleting a row from the table


V. Drop column class

VI. Alter table by changing the data type of empno to decimal (8).
VII. Delete all the data from employee table.

VIII. Delete the table.

Ques 2.Create the following user 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

IV. Display the content of the table.

V. Display the NAME and SALARY of the users.


VI. Display the name of users who’s SALARY are greater than 2000.

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

2. Minimum salary in each location

3.No of employees in each department


4.Average salary of all employees.

5.Sum of salaries in each location

School of Computing
Practical - 6
Objective: Execution of various types of set operations(union, intersect, minus)
Output:
1.Union operation

2.Union all operation


3. Intersection Operation:

4.Minus(Not In) operator

School of Computing
Practical - 7
Objective: Apply the various types of Integrity Constraints on table.

1. Create a table Customers and Initialize Primary Key Constraints as customer_id:

2. Create a table Orders and Initialize foreign key Constraints as customer_id by refe. to customers
table:

3. Create a table Employee and Initialize employee_email as Unique Constraint:

4. Create a table Product and initialize Check Constraint on price:

School of Computing
5. Violates the primary key in orders:

6. Violation of foreign key Constraints:

7. Violation of Unique Constraints:


Practical – 8

Based on employee table calculate following using SQL commands:


• Total no of rows in table?
• No of employees in department DE1
• No of employees in department DE1 and basic<10000?
• Find No of departments?
• Total basic salary of all the employees?
• Total basic salary of all the employees of department DE2?
• Total basic salary of employees of department DE1 whose basic is less than 10000?• Total pay
of all the employees of dept DE2? { Total pay= basic+hra-taxtdeductions)
• Total pay of all the employees of dept DE1, show result as grosspay?
• Total pay of all the employees of dept DE1 and basic<10000. Display as gross?
• Avg HRA of an employee?
• Avg pay of employee?
• Show department wise avg pay of empolyees and show results only for those departments where
avg pay>7500. Also sort the result in decreasing order of avg pay.

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

• Add at least 3 rows in each table


• Show the violation of foreign key constraint.

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

2.Updation of elements in Main Table

School of Computing
3.Updation of Elements in View Table:
Practical – 11
Ques1.

Pid Pname Quantity Dept Basic TAX LOC

001A SPOCKET 29 DEPT1 20000 200 Pune

002A SPINNER 30 DEPT4 30000 300 Pune

003A REARCOVER 25 DEPT1 5000 150 Mumbai

004A TAILLIGHT 24 DEPT4 4000 240 Mumbai

005A HEADLIGHT 32 DEPT1 25000 349 Bangalore

006A METER 29 DEPT3 10000 200 Pune

007A SPARKPLUG 30 DEPT2 20000 300 Pune

008A WIREREAR 25 DEPT1 5000 150 Bangalore

009A BREAKPAD 24 DEPT2 4000 240 Mumbai

010A LOGOMETER 31 DEPT2 6700 450 Nasik


Based on production table calculate following using SQL commands: - 1. No of employees
in each city, order result in decreasing order.
2. No of employees in city Mumbai and having basic>10000.
3. No of Departments in the table.
4. Total Tax of all the employees from Mumbai and Banglore separately in same table. 5. Total
basic salary of employees of city Banglore, who’s basic is less than or equal to 20000.
6. Total pay of all the employees of city Banglore. Show the result in column named as GROSS.
{Total Pay is BASIC-TAX).
7. Calculate Avg basic salary city wise and display the result of only those cities where avg basic
salary <15000.Also sort the result in decreasing order of avg salary.
8. Display the pid, Pname and Tax for those employees where Quantity is between 24 and 29.
9. Display the results of the table where last character of Pname is “T”.
10. Display the results of the table where total number of character in Pname are 8.
11. Display the city wise average basic where city name ends at “e”.
12. Display the city wise total tax where 3rd character of city name is “n”.
13. Create a view using Pname, LOC and Dept from employee table.
14. Demonstrate the features of view by making changes to original table and view.
15. Delete the view.

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:

Implementation of Foreign Key on DATABASE.

Output:
1.Creation of table using foreign key constraint:

2.Insertion of Data in both tables without any violation:

3.Violation of Foreign Key Constraint (Entry of value in referencing table which is not present in
referenced tables)

4. Violation of Foreign Key by Trying to drop the referenced table


Practical – 13
Objective: Modify the database structure and drop the record with structure.
Output:
1.Print all the details of the table customers:

2. Add new column in table Customers:

3.Show new column:

4.Drop the record with structure:

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.

• List all the clients who are located in MUMBAI state.

• Find the products whose selling price is greater than 1900 and less than or equal to
3500

• Add a new column UPDATED_PRICE into the product table.

• 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.

Age of the youngest male and female student


Name and the CGPA for all students who got above 7.5 CGPA ordered by their CGPAs then
their names.

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.

You might also like