DBMS Lab Report
DBMS Lab Report
OBJECTIVE:
To understand and draw ER diagram for Library Management System
THEORY:
Entity-Relational (ER) Data Model uses tables to represent the data and the relationship among these data.
Each table has multiple columns and each column is identified by a unique name. It is a low-level model.
ER model describes the design of database in terms of entities and relations between them. Peter Chen
developed the ER diagram in 1976 .The ER data model specifies enterprise schema that represents the
overall logical structure of a database graphically.
ER diagram of Library Management System using online available tool smartdraw.com
LAB 2
OBJECTIVE:
To study different data defination language (DDL) commands in SQL and implement them in database.
THEORY:
SQL commands are extensively used to interact with databases, enabling users to perform a wide range of
actions on database systems. Understanding these commands is crucial for effectively managing and
manipulating data.
Data Definition Language(DDL) is a subset of SQL and a part of DBMS (Database Management System).
DDL consist of Commands to commands like CREATE, ALTER, TRUNCATE and DROP. These
commands are used to create or modify the tables in SQL.
DDL commands:
iv. TRUNCATE;
TRUNCATE TABLE students;
Removes all data from the students table, but the table's structure stays the same.
v. RENAME;
RENAME TABLE students TO pupils;
LAB 3
OBJECTIVE:
To study different data manipulation language (DML) commands in SQL and implement them in database.
THEORY:
The SQL commands that deal with the manipulation of data present in the database belong to DML or Data
Manipulation Language and this includes most of the SQL statements.
It is the component of the SQL statement that controls access to data and to the database. Basically, DCL
statements are grouped with DML statements.
iii. DELETE;
DELETE FROM pupils
WHERE student_id = 1;
iv. SELECT:
SELECT * FROM pupils
WHERE student_id = 2;
THEORY:
Join operation: It's a fundamental operation in relational databases that allows for the retrieval of
from multiple tables simultaneously. SQL JOIN clause is used to query and access data from multiple
tables by establishing logical relationships between them. It can access data from multiple tables
simultaneously using common key values shared across different tables.
We can use SQL JOIN with multiple tables. It can also be paired with other clauses, the most popular use
will be using JOIN with WHERE clause to filter data retrieval.
Firstly start by creating two table one we created in previous labs, we will be using that and created another
table name ‘courses’ with respective columns and data were inserted. Now applying JOIN OPERATION.
Course table:
Pupils table:
After JOINING:
SELECT p.first_name, p.last_name, c.course_name
FROM pupils p
INNER JOIN courses c ON p.student_id = c.student_id;
ii. NATURAL JOIN
A NATURAL JOIN is a type of join that automatically matches columns with the same name
in both tables and combines them in the result set. It simplifies joining tables when the column
names and data types are the same and you want to use those columns for the join condition.
Code: SELECT * FROM pupils
NATURAL JOIN courses;
LAB 5
OBJECTIVE:
To study different clauses in SQL.
THEORY:
SQL clauses are essential components of SQL queries that help you retrieve, filter, group, and sort data
from a database. Here are some of the most commonly used SQL clauses.
Demo Table;
1. Example: Retrieve SupplierID, Name, and Address from suppliers table, where supplier name
starts form k.
Command: SELECT SupplierID, Name, Address
FROM Suppliers
WHERE Name LIKE 'Ca%';
3. Example: Retrieve SupplierID, Name and Address of supplier whose name contains “ango” in
second substring.
Command: SELECT SupplierID, Name, Address
FROM Suppliers
WHERE Name LIKE '_ango%';
LAB 6
OBJECTIVE:
Solve the given questions using ORACLE LIVE SQL - HR database scheme.
THEORY:
Oracle Live SQL is a web-based platform that allows you to write, run, and share SQL scripts directly in
your browser.
HR database scheme.
3. Display total salary distribution at the end of the month for all employees.
14. Display department where sum of salaries is 50000 or greater than 50000.