0% found this document useful (0 votes)
44 views

Database Management Systems Lab ETCS-256

The aim of this experiment was to study database management systems (DBMS). A database is a collection of related data representing some aspect of the real world. A DBMS is software for storing and retrieving user data with security measures. It consists of programs that manipulate the database. Some key databases used by companies include financial, healthcare, retail, and education databases, each with their own limitations.

Uploaded by

Aakash Gupta
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)
44 views

Database Management Systems Lab ETCS-256

The aim of this experiment was to study database management systems (DBMS). A database is a collection of related data representing some aspect of the real world. A DBMS is software for storing and retrieving user data with security measures. It consists of programs that manipulate the database. Some key databases used by companies include financial, healthcare, retail, and education databases, each with their own limitations.

Uploaded by

Aakash Gupta
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/ 28

DATABASE MANAGEMENT SYSTEMS LAB

ETCS-256

Faculty Name : Mr. Moolchand Sharma Student Name : Priyank Rawat


Roll No. : 02596402719
Group : 4C12

Maharaja Agrasen Institute of Technology, PSP Area, Sector –


22, Rohini, New Delhi – 110086
Course Objectives:

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.

S.NO Course Outcomes

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.

ETCS256.3 For a given specification construct the SQL queries.

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.

Is able to All important data are


record and Data are either present, but recorded All important data are
Some important data are
represent data absent or in a way that requires present, organized and
R4 absent or
in a incomprehensi some
meaningful incomprehensible. recorded clearly.
ble. effort to comprehend.
way.

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

Perform the following:


Viewing all databases, creating a Database, viewing all Tables in a Database, Creating
3 Tables (With and Without Constraints),
Inserting/Updating/Deleting Records in a Table, Saving (Commit) and Undoing (rollback)

Perform the following:


4
Altering a Table, Dropping/Truncating/Renaming Tables, backing up / Restoring a 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

6 Write the queries to implement the concept of Integrity constrains

For a given set of relation tables perform the following :


7
Creating Views (with and without check option), Dropping views, Selecting from a view

8 Perform the queries for triggers

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.

DBMS(Database Management System)


Database Management System (DBMS) is a software for storing and retrieving users' data while considering
appropriate security measures. It consists of a group of programs which manipulate the database. The DBMS
accepts the request for data from an application and instructs the operating system to provide the specific data.
In large systems, a DBMS helps users and other third-party software to store and retrieve data.

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

 Improves security and removes redundancy.


 Supports multiple views of data.
 Sharing of data and multi-user data processing.
 Allows entities and relations among them to form tables.
 DBMS supports multi-user environment that allows users to access and manipulate data in parallel.

Applications of DBMS

Some applications of DBMS are :-

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

Four Types of DBMS systems are:

 Hierarchical database - In a Hierarchical database, model data is organized in a tree-like structure.


Data is Stored Hierarchically (top down or bottom up) format. Data is represented using a parent-child
relationship. In Hierarchical DBMS parent may have many children, but children have only one parent.

 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

 DBMS offers a variety of techniques to store & retrieve data


 DBMS serves as an efficient handler to balance the needs of multiple applications using the same data
 Uniform administration procedures for data
 Application programmers never exposed to details of data representation and storage.
 A DBMS uses various powerful functions to store and retrieve data efficiently.
 Offers Data Integrity and Security
 The DBMS implies integrity constraints to get a high level of protection against prohibited access to
data.
 A DBMS schedules concurrent access to the data in such a manner that only one user can access the
same data at a time
 Reduced Application Development Time

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

Popular DBMS Systems , their characteristics, advantages and disadvantages

S.No Database Advantages Limitations


1. Oracle  Probability  Difficult to manage
 Backup and recovery  Expensive compared to
 Market presence MYSQL
 Multiple database  Complexity
support
 Version Changes

2. MYSQL  Data security  Doesn’t support a very large


 High performance database size as efficiently.
 Comprehensive  Few stability issues
Transactional Support  Poor performance scaling
 Complete workflow  Functionality heavily
control dependent on addons.
 On demand  Development is not
Scalability community driven
 Round-the clock
uptime
3. Firebase  Free for beginners  Storage is inconvenient
 Ease of Integration  Android centered
 Limited data migration
4. Postgre SQL  Highly Expandable  Slower than MYSQL
 Possible to process  Many open source apps
complex data types support MYSQL but may
 Easy to learn not support postgreSQL
 Robust and powerful  Not owned by organization,
so trouble in getting its name

5. MangoDB  No complex joins  Uses high memory for data


 Structure of a single storage
object is clear  There is a limit for document
 Deep query ability
EXPERIMENT 1

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. 

Common ER Diagram symbols

Entity Relationship Diagram Symbols & Notations mainly contains three basic symbols which are rectangle,
oval and diamond to represent relationships between elements, entities and attributes.

Following are the main components and its symbols in ER Diagrams:

 Rectangles: This Entity Relationship Diagram symbol represents entity types


 Ellipses : Symbol represent attributes
 Diamonds: This symbol represents relationship types
 Lines: It links attributes to entity types and entity types with other relationship types
 Primary key: attributes are underlined
 Double Ellipses: Represent multi-valued 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 design: In software engineering, an ER diagram is often an initial step in determining


requirements for an information systems project. It’s also later used to model a particular database or
databases. A relational database has an equivalent relational table and can potentially be expressed that way
as needed.

 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

The above ER diagram have


 two entities Student and Teacher
 the relationship between Student and Teacher is one-to-many as one student can learn from more than
one teacher
 Student entity has 5 attributes namely :
 Roll No.(Key Attribute)
 Name which is further divided into First Name and Last Name
 Phone number (Multivalued Attributes)
 Birth date
 Age(Derived Attribute)
 Teacher entity has 4 attributes :
 Teacher ID (Key Attribute)
 Name
 Department Name
 Course ID
Experiment – 2

Aim
Design a Database and create required tables.

1 Database Creation

Create Database db_name :

creates a database called db_name.

Show Databases :

Displays list of all the databases.

2 Table Creation :

Create Table Table_name (


Abc datatype1,
Cdf datatype2
);

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.

Select * from table_name;


Displays the contents of the table.

4 Addition of more attributes :


Alter Table table_name ;
Add column_name datatype ;
Make changes in the attributes of the table and adds an attribute called column_name of the given datatype in the
table.

5 Updation in existing records :

Update table_name

updates a particular attribute in a particular record depending upon a condition in the table.

Set column_name1 = value1


sets/changes the value of column_name1 attribute with value1.

Where column_name2 = value2 ;


this specifies the condition in which record exactly we have to make changes i.e. records in which column_name2 are
having values value2 are selected for the change.
6 Selection of specific attributes and display them :
Select column_name1, column_name2
From table_name;

It displays all the entries of column_name1 and column_name2 attributes of the table table_name.

7 Rename an existing attribute :

Alter table table_name


Rename Column column_name1 To column_name2 ;
renames the column_name1 to column_name2 of table table_name.
EXPERIMENT 3
Aim

Add constraints to the a ributes such as not null and primary key and use func ons sum, average, count,
max, min.

Create Table with Constraints

Created table Student with:

PRIMARY KEY : ID

NOT NULL a ributes : 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;

To count number of tuples:

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 & HAVING STATEMENT

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

Create database and Create table


• Created database employee.

• Created table employee_list.


Primary key

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.

To declare an attribute as primary key:

alter table table_name


add constraint pk
primary key(attribute);
Foreign 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.

Creating a table with a foreign key

create table table2


(attribute1 attribute_type,
------
------
foreign key(attribute_name) references table1(attribute));
Equi Join

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.

ALTER TABLE table_name


RENAME TO new_table_name; Optionally, you can write following command to rename the table.
RENAME old_table _name To new_table_name;

B) SQL DROP TABLE


A SQL DROP TABLE statement is used to delete a table definition and all data from a table. This is very
important to know that once a table is deleted all the information available in the table is lost forever, so we
have to be very careful when using this command.

DROP TABLE "table_name";

C) SQL TRUNCATE TABLE


A truncate SQL statement is used to remove all rows (complete data) from a table. It is similar to the DELETE
statement with no WHERE clause. Truncate table is faster and uses lesser resources than DELETE TABLE
command. Drop table command can also be used to delete complete table but it deletes table structure too.
TRUNCATE TABLE doesn't delete the structure of the table.

D) The SQL BACKUP DATABASE Statement


The BACKUP DATABASE statement is used in SQL Server to create a full back up of an existing SQL
database.
Syntax : Priyank Rawat 02596402719 BACKUP DATABASE databasename TO DISK = 'filepath';

You might also like