Database Management Systems Lab ETCS-256
Database Management Systems Lab ETCS-256
ETCS-256
The major objective of this lab is to provide a strong formal foundation in database concepts, technology and practice to
the participants to groom them into well-informed database application developers. This course prepares the students for
developing intelligent and normalized database management systems. Upon completion of this course, the student should
be able to understand the research trends in database management system.
Compare the different database tools for open source and commercial DBMSMYSQL/
ETCS256.1
MariaDB/ PL/pgSQL
ETCS256.2 Design the relational database for the given specification of the requirement.
Build a simple database system and demonstrate competence with the fundamental tasks
ETCS256.4
involved with modeling, designing, and implementing a DBMS
Department of Computer Science and Engineering
Rubrics for Lab Assessment
0 1 2 3
Rubrics Missing Inadequate Needs Adequate
Improvement
The problem to be
An attempt is made to solved is described but
Is able to identify the problem to be there are minor The problem to be solved is
identify the solved but it is described omissions or vague clearly stated.
problem to be No mention is in a confusing manner, details. Objectives are Objectives are complete,
solved and made of the objectives are not conceptually correct specific, concise, and
R1
define the problem to be relevant, objectives and measurable but measurable. They are
objectives of solved. contain technical/ may be incomplete in written using correct
the conceptual errors or scope or have technical terminology and
experiment. objectives are not linguistic errors. are free from linguistic
measurable. errors.
The experiment
Is able to attempts to solve the
The experiment attempts problem but due to the The experiment solves the
design a
The experiment to solve the problem but nature of the design problem and has a high
reliable
R2 does not solve due to the nature of the there is a moderate likelihood of producing
experiment
the problem. design the data will not data that will
that solves the chance the data will
lead to a reliable solution. not lead to a reliable lead to a reliable solution.
problem.
solution.
Is able to
Diagrams are
communicate Diagrams and/or
missing and/or Diagrams are present but
the details of experimental
experimental unclear and/or Diagrams and/or
an procedure are present
R3 procedure is experimental procedure is experimental procedure are
experimental but with minor
missing or present but important clear and complete.
procedure omissions or vague
extremely details are missing.
clearly and details.
vague.
completely.
An acceptable judgment is
Is able to make An acceptable made about the result, with
No discussion is A judgment is made
a judgment judgment is made clear reasoning. The effects
presented about about the results, but it is
R5 about the about the result, but the of assumptions and
the results of the not reasonable or
results of the reasoning is flawed or experimental uncertainties
experiment . coherent.
experiment. incomplete. are considered.
List of Experiments
General (0) Describe any five databases that are recently used by the companies with their limitations
Draw E-R diagram and convert entities and relationships to relation table for a given scenario.
Two assignments shall be carried out i.e. consider two different scenarios (e.g. bank, college)
1
2 Design a Database and create required tables. For e.g. Bank, College Database
For a given set of relation schemes, create tables and perform the following
Simple Queries, Simple Queries with Aggregate functions, Queries with Aggregate functions
5 (group by and having clause), Queries involving- Date Functions, String
Functions , Math Functions
Join Queries- Inner Join, Outer Join Subqueries- With IN clause, With EXISTS clause
9 Write a Pl/SQL program using FOR loop to insert ten rows into a database table.
Perform the following operation for demonstrating the insertion, updation and deletion using the
10
referential integrity constraints
Lab Assessment Sheet
Marks
Exp. Date of
Total Marks Remarks Signature
No. Performance
0 10 March 2021
1 17 March 2021
2 28 April 2021
3
5 May 2021
4
29 May 2021
5
29 May 2021
EXPERIMENT 0
AIM
To study about DBMS.
Database
A database is a collection of related data which represents some aspect of the real world. A database system is
designed to be built and populated with data for a certain task.
History of DBMS
In 1960, Charles W. Bachman designed the Integrated Database System, the “first” DBMS. IBM, not wanting
to be left out, created a database system of their own, known as IMS. Both database systems are described as
the forerunners of navigational databases.
By the mid-1960s, as computers developed speed and flexibility, and started becoming popular, many kinds of
general use database systems became available. As a result, customers demanded a standard be developed, in
turn leading to Bachman forming the Database Task Group. The Database Task Group presented Common
Business Oriented Language (COBOL) standard in 1971, which also came to be known as the “CODASYL
approach.”
The CODASYL approach was a very complicated system and required substantial training. It depended on a
“manual” navigation technique using a linked data set, which formed a large network.
It was during the year 1970 that the relational database model was developed by Edgar Codd. Many of the
database models we use today are relational based. It was considered the standardized database model from
then.
The relational model was still in use by many people in the market.Later during the same decade (1980’s),
IBM developed the Structured Query Language (SQL) as a part of R project. It was declared as a standard
language for the queries by ISO and ANSI.
Further, there were many other models with rich features like complex queries, datatypes to insert images
and many others. The Internet Age has perhaps influenced the data models much more. Data models were
developed using object oriented programming features, embedding with scripting languages like Hyper
Text Markup Language (HTML) for queries. With humongous data being available online, DBMS is
gaining more significance day by day.
Characteristics
Applications of DBMS
1.Railway Reservation System: In the railway reservation system, the database is required to store the record
or data of ticket bookings, status about train’s arrival, and departure. Also if trains get late, people get to know it
through database update.
2. Library Management System: The database management system (DBMS) is used to maintain all the
information related to the name of the book, issue date, availability of the book, and its author.
3. Banking: Database management system is used to store the transaction information of the customer in the
database.
4. Education Sector: Presently, examinations are conducted online by many colleges and universities. They
manage all examination data such as student’s registrations details, grades, courses, fee, attendance, results, etc.
through the database management system (DBMS).
5. Credit card transactions: Database Management system is used for purchasing on credit cards and
generation of monthly statements.
6. Social Media Sites: Daily, millions of peoples sign up for these social media accounts like Pinterest ,
Facebook , Twitter, and Google plus. By the use of the database management system, all the information of
users are stored in the database and, we become able to connect with other people.
7. Telecommunications: Without DBMS any telecommunication company can’t think. The Database
management system is necessary for these companies to store the call details and monthly postpaid bills in the
database.
8. Finance: The database management system is used for storing information about sales, holding and
purchases of financial instruments such as stocks and bonds in a database.
Types of DBMS
Network database - The network database model allows each child to have multiple parents. It helps
you to address the need to model more complex relationships like as the orders/parts many-to-many
relationship. In this model, entities are organized in a graph which can be accessed through several
paths.
Relational Database - Relational DBMS is the most widely used DBMS model because it is one of the
easiest. This model is based on normalizing data in the rows and columns of the tables. Relational model
stored in fixed structures and manipulated using SQL.
Object Oriented Database - In Object-oriented Model data stored in the form of objects. The structure
which is called classes which display data within it. It defines a database as a collection of objects which
stores both data members values and operations.
Advantages of DBMS
Disadvantage of DBMS
Cost of Hardware and Software of a DBMS is quite high which increases the budget of your
organization.
Most database management systems are often complex systems, so the training for users to use the
DBMS is required.
In some organizations, all data is integrated into a single database which can be damaged because of
electric failure or database is corrupted on the storage media
Use of the same program at a time by many users sometimes lead to the loss of some data.
DBMS can't perform sophisticated calculations
AIM
Draw an ER Diagram of your choice except one to one and convert them into relational table.
THEORY
ER Diagram
ER Diagram stands for Entity Relationship Diagram, also known as ERD is a diagram that displays the
relationship of entity sets stored in a database. In other words, ER diagrams help to explain the logical
structure of databases.
Entity Relationship Diagram Symbols & Notations mainly contains three basic symbols which are rectangle,
oval and diamond to represent relationships between elements, entities and attributes.
Components of ER Diagram
Entity : Entities are objects or concepts that represent important data. Entities are typically nouns such
as product, customer, location, or promotion.
Attributes : ERD attributes are characteristics of the entity that help users to better understand the
database. Attributes are included to include details of the various entities that are highlighted in a
conceptual ER diagram.
Relationships : Within entity-relationship diagrams, relationships are used to document the interaction
between two entities. Relationships are usually verbs such as assign, associate, or track and provide
useful information that could not be discerned with just the entity types.
Uses of ER Diagram
Database troubleshooting: ER diagrams are used to analyze existing databases to find and resolve problems
in logic or deployment. Drawing the diagram should reveal where it’s going wrong.
Business information systems: The diagrams are used to design or analyze relational databases used in
business processes. Any business process that uses fielded data involving entities, actions and interplay can
potentially benefit from a relational database.
Business process re-engineering (BPR): ER diagrams help in analyzing databases used in business process
re-engineering and in modeling a new database setup.
Education: Databases are today’s method of storing relational information for educational purposes and later
retrieval, so ER Diagrams can be valuable in planning those data structures.
Research: Since so much research focuses on structured data, ER diagrams can play a key role in setting up
useful databases to analyze the data.
ER DIAGRAM
Aim
Design a Database and create required tables.
1 Database Creation
Show Databases :
2 Table Creation :
After selecting the database, create a table called Table_name with attributes – Abc of datatype1 and Cdf
of datatype2.
3 Insertion of records :
Insert Into table_name
Values (val1, val2, …) ;
allows to insert new records in the table, the new record will have values for all the attributes in the table.
Update table_name
updates a particular attribute in a particular record depending upon a condition in the table.
It displays all the entries of column_name1 and column_name2 attributes of the table table_name.
Add constraints to the a ributes such as not null and primary key and use func ons sum, average, count,
max, min.
PRIMARY KEY : ID
Insert Values
Student Table
AGGREGATE FUNCTIONS
MIN
The MIN() function returns the smallest value of the selected column.
Syntax:-
SELECT MIN(column_name)
FROM table_name
WHERE condition;
MAX
The MAX() function returns the largest value of the selected column.
Syntax:-
SELECT MAX(column_name)
FROM table_name
WHERE condition;
COUNT
The COUNT() function returns the number of rows that matches a specified criterion.
Syntax:-
SELECT COUNT(column_name)
FROM table_name
WHERE condition;
SELECT COUNT(*)
FROM table_name;
SUM
The SUM() function returns the total sum of a numeric column
Syntax:-
SELECT SUM(column_name)
FROM table_name
WHERE condition;
AVG
The AVG() function returns the average value of a numeric column.
Syntax:-
SELECT SUM(column_name)
FROM table_name
WHERE condition;
GROUP BY
• The GROUP BY statement groups rows that have the same values into summary rows, like "find the
number of customers in each country".
• The GROUP BY statement is often used with aggregate functions (COUNT(), MAX(), MIN(), SUM(),
AVG()) to group the result-set by one or more columns.
Syntax:-
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
ORDER BY column_name(s);
HAVING
The HAVING clause was added to SQL because the WHERE keyword cannot be used with
aggregate functions.
Syntax:-
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
HAVING condition
ORDER BY column_name(s);
EXPERIMENT 4
Aim
Aim - Design a Database and create required tables. Add foreign key constraint to the attributes. Also
perform Join Queries – natural join, equi join, inner join, left join, right join.
A primary key, also called a primary keyword, is a key in a relational database that is unique for each record. It
is a unique identifier, such as a driver license number, telephone number (including area code), or vehicle
identification number (VIN). A relational database must always have one and only one primary key.
A foreign key is a key used to link two tables together. This is sometimes also called as a referencing key. A
Foreign Key is a column or a combination of columns whose values match a Primary Key in a different table.
An equijoin is an operation that combines multiple tables based on equality or matching column values in the
associated tables. It can return all attributes of both tables along with duplicate columns that match the join
condition.
Natural Join
It joins the tables based on the same column names and their data types. It always returns unique columns in the
result set.
Inner Join
It joins the tables based on the column name specified in the ON clause explicitly. It returns only those rows
that exist in both tables. It returns all the attributes of both tables along with duplicate columns that match the
ON clause condition.
Left Join
The Left Join clause, it will return all the records from the first (left-side) table, even no matching records found
from the second (right side) table. If it will not find any matches record from the right side table, then returns
null.
Right Join
The Right Join is used to joins two or more tables and returns all rows from the right-hand table, and only those
results from the other table that fulfilled the join condition. If it finds unmatched records from the left side table,
it returns Null value.
EXPERIMENT – 5
AIM
Dropping/Truncating/Renaming Tables, backing up / Restoring a Database.
THEORY
A) SQL RENAME TABLE
SQL RENAME TABLE syntax is used to change the name of a table.