Final Lab Report
DBMS SE-206
Submitted to
Mr. Ram Murti
Department of Software Engineering
Submitted By
Vipul Sharma
2K20/ME/302
Department of Mechanical Engineering
Delhi Technological University, Rohini
Delhi-110042
(Govt. of NCT of Delhi)
TABLE OF CONTENTS
S. Laboratory Experiment Sign.
No.
1. Introduction to Database.
2. Introduction to ER diagram and symbol table.
3. Creation of a database and writing SQL queries to
retrieve information from the database.
4. To implement DDL (Data Definition Language).
1. Create
2. Alter
3. Drop
4. Truncate
5. To implement DML (Data
ManipulationLanguage) commands.
1. Select
2. Insert
3. Update
4. Delete
6.
7.
8.
9.
10.
Experiment No-1
Aim: Introduction to Database.
Theory:
A database, in the most general sense, is an organized collection of data. More
specifically, a database is an electronic system that allows data to be easily
accessed, manipulated and updated.
A database management system (DBMS) refers to the technology for creating
and managing databases. DBMS is a software tool to organize (create, retrieve,
update, and manage) data in a database.
The main aim of a DBMS is to supply a way to store up and retrieve database
information that is both convenient and efficient. By data, we mean known facts
that can be recorded and that have embedded meaning. Usually, people use
software such as DBASE IV or V, Microsoft ACCESS, or EXCEL to store data in
the form of a database. A datum is a unit of data. Meaningful data combined to
form information. Hence, information is interpreted data - data provided with
semantics. MS. ACCESS is one of the most common examples of database
management software.
More on Data, Information, and Knowledge
Knowledge refers to the useful use of information. As you know, that information
can be transported, stored, and shared without any problems and difficulties, but
the same cannot be said about knowledge. Knowledge necessarily involves
personal experience and practice.
Database systems are meant to handle an extensive collection of information.
Management of data involves both defining structures for storage of information
and providing mechanisms that can do the manipulation of those stored
information. Moreover, the database system must ensure the safety of the
information stored, despite system crashes or attempts at unauthorized access.
Why Use DBMS?
To develop software applications In less time.
Data independence and efficient use of data.
For uniform data administration.
For data integrity and security.
For concurrent access to data, and data recovery from crashes.
To use user-friendly declarative query language.
Where is a Database Management System (DBMS) being Used?
Airlines: reservations, schedules, etc
Telecom: calls made, customer details, network usage, etc
Universities: registration, results, grades, etc
Sales: products, purchases, customers, etc
Banking: all transactions etc
Advantages of DBMS
A DBMS manages data and has many benefits. These are:
Data independence: Application programs should be as free or
independent as possible from details of data representation and storage.
DBMS can supply an abstract view of the data for insulating application
code from such facts.
Efficient data access: DBMS utilizes a mixture of sophisticated
concepts and techniques for storing and retrieving data competently.
This feature becomes important in cases where the data is stored on
external storage devices.
Data integrity and security: If data is accessed through the DBMS,
the DBMS can enforce integrity constraints on the data.
Data administration: When several users share the data, integrating the
administration of data can offer significant improvements. Experienced
professionals understand the nature of the data being managed and can be
responsible for organizing the data representation to reduce redundancy
and make the data to retrieve efficiently.
Components of DBMS
Users: Users may be of any kind such as DB administrator,
System developer, or database users.
Database application: Database application may be Departmental,
Personal, organization's and / or Internal.
DBMS: Software that allows users to create and manipulate
database access,
Database: Collection of logical data as a single unit.
There are four types of Data Languages
1. Data Definition Language (DDL)
2. Data Manipulation Language(DML)
3. Data Control Language(DCL)
4. Transactional Control Language(TCL)
DDL is the short name for Data Definition Language, which deals with
database schemas and descriptions, of how the data should reside in the
database.
CREATE: to create a database and its objects like (table, index, views, store
procedure, function, and triggers)
ALTER: alters the structure of the existing database
DROP: delete objects from the database
TRUNCATE: remove all records from a table, including all spaces allocated
for the records are removed
COMMENT: add comments to the data dictionary
RENAME: rename an object
DML is the short name for Data Manipulation Language which deals with data
manipulation and includes most common SQL statements such SELECT,
INSERT, UPDATE, DELETE, etc., and it is used to store, modify, retrieve,
delete and update data in a database.
SELECT: retrieve data from a database
INSERT: insert data into a table
UPDATE: updates existing data within a table
DELETE: Delete all records from a database table
MERGE: UPSERT operation (insert or update)
CALL: call a PL/SQL or Java subprogram
EXPLAIN PLAN: interpretation of the data access path
LOCK TABLE: concurrency Control
DCL is short for Data Control Language which acts as an access specifier to the
database.(basically to grant and revoke permissions to users in the database
GRANT: grant permissions to the user for running DML(SELECT, INSERT,
DELETE,…) commands on the table
REVOKE: revoke permissions to the user for running DML(SELECT,
INSERT, DELETE,…) command on the specified table
TCL is short for Transactional Control Language which acts as an manager for
all types of transactional data and all [Link] of the command of TCL
are
Role Back: Used to cancel or Undo changes made in the database
Commit: It is used to apply or save changes in the database
Save Point: It is used to save the data on the temporary basis in the database
Database Management System: The software which is used to manage
databases is called Database Management System (DBMS). For Example,
MySQL, Oracle, etc. are popular commercial DBMS used in different
applications. DBMS allows users the following tasks:
Data Definition: It helps in the creation, modification, and removal of
definitions that define the organization of data in the database.
Data Updation: It helps in the insertion, modification, and deletion of the
actual data in the database.
Data Retrieval: It helps in the retrieval of data from the database which can
be used by applications for various purposes.
User Administration: It helps in registering and monitoring users, enforcing
data security, monitoring performance, maintaining data integrity, dealing
with concurrency control, and recovering information corrupted by
unexpected failure.
Experiment No-2
Aim: Introduction to ER diagram and symbol table.
Theory:
ER Model: Entity-relationship model is a high-level data model used to design
and represent relationships between data. The main data objects are Entities
along with their details defined as attributes, some of these attributes are
important and are used to identity the entity, and different entities are related
using relationships.
The following are the components of an ER diagram – Entities, Attributes and
Relationship
Entity and Entity Set
An Entity is generally a real-world object which has characteristics and holds
relationships in a DBMS.
For example, if a Student is an Entity, then the complete dataset of all the
students will represent the Entity Set
Attributes
Attributes are characteristic property of an entity. If Student is an Entity, then
student's roll no., student's name, student's age, student's gender etc will be its
attributes.
The different types of attributes defined in ER database model are as follows:
1. Simple attribute: The attributes with values that are atomic and cannot be
broken down further are simple attributes. For example, age.
2. Composite attribute: A composite attribute is made up of more than one
simple attribute. For example, student name consists of first name,middle
name and last name.
3. Derived attribute: These are the attributes which are not present in the
whole database management system, but are derived using other
attributes. For example, average age of students in a class.
4. Single-valued attribute: They have a single value.
5. Multi-valued attribute: They can have multiple values like phone number.
Relationships
When an Entity is related to another Entity, they are said to have a relationship.
Depending upon the number of entities involved, a degree is assigned to
relationships. For example, if 2 entities are involved, it is said to be Binary
relationship, if 3 entities are involved, it is said to be Ternary relationship, and
so on.
ER Diagram of a bank
Advantages of ER Diagram
The advantages of choosing an entity relation (ER) model over physical
design are as follows:
1. Conceptual simplicity. If relationships between entities and attributes are
known, an ERD can be quickly drawn.
2. Explicit visual representation. The database structure can be easily
comprehended after consulting the diagram.
3. Communication effectiveness. Standard symbols representing different
information facilitate understanding of the working of the database after
completion.
4. Immense flexibility. ER data model can be easily converted into any
other data model with minor manipulations.
Uses of Entity Relationship Diagrams
Database design: ER diagrams are used to model and design relational
databases, in terms of logic and business rules (in a logical data model) and in
terms of the specific technology to be implemented (in a physical data model.) 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 andcan potentially be expressed that way as needed.
Database troubleshooting: ER diagrams are used to analyse existing
databases to find and resolve problems in logic or [Link]
the diagram should reveal where it’s going wrong.
Business information systems: The diagrams are used to design or
analyse 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. It can streamline
processes, uncover information more easily and improve results.
Business process re-engineering (BPR): ER diagrams help in
analysing databases used in business process re-engineering and in
modelling a new database setup as well.
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 analyse
the data.
ER Diagram Symbols
Cardinality Symbols:
Learning/ Conclusion
We understood the ER diagrams, their need, components like entities, attributes
and relationships, its advantages, uses and the symbols to represents different
components.
Experiment No-3
Aim: - Creation of a database and writing SQL queries to retrieve information
from the database.
Theory:-
Creating a database involves the following steps:
1. Define the structure of the database, including the tables, columns, data
types, and relationships between tables.
2. Create the database using a database management system (DBMS) such as
MySQL, PostgreSQL or SQL Server.
3. Populate the tables with data.
Once the database has been created, you can write SQL queries to retrieve
information from it. Some common SQL queries include:
1. SELECT - used to retrieve data from one or more tables. Example:
SELECT * FROM customers;
2. WHERE - used to filter data based on specific conditions. Example:
SELECT * FROM customers WHERE country = 'USA';
3. JOIN - used to combine data from two or more tables based on a related
column between them. Example: SELECT * FROM customers JOIN orders
ON customers.customer_id = orders.customer_id;
4. GROUP BY - used to group data based on one or more columns. Example:
SELECT country, SUM(amount) FROM orders GROUP BY country;
5. HAVING - used to filter data after grouping it. Example: SELECT country,
SUM(amount) FROM orders GROUP BY country HAVING
SUM(amount) > 1000;
Code and Result:-
1. Create a Table:-
2. Insert Data in table
3. Retrieve information from database
Learnings/ Conclusion:
After this experiment, we learnt the different commands in SQL.
Experiment No-4
Aim: To implement DDL (Data Definition Language).
1. Create
2. Alter
3. Drop
4. Truncate
Theory:
DDL Statements
DDL or Data Definition Language actually consists of the SQL commands that
can be used to define the database schema. It simply deals with descriptions of
the database schema and is used to create and modify the structure ofdatabase
objects in the database.
CREATE
Used to create a Table in the database.
DROP Table
It is used to remove an existing table from the database.
ALTER Table
It is used to for altering the table structure, such as, to add a column to
existing table, to rename any existing column, to change datatype of any
column or to modify its size and to drop a column from the table.
RENAME Table
Using ALTER command, we can rename an existing column of a table.
TRUNCATE
It is used to remove all the records from a table
Learning/ Conclusion
In this experiment, we learnt about Data Definition Language (DDL) commands.
We implemented the commands- created tables, added columns, inserted data,
updated data, deleted rows, dropped tables etc
Experiment No-5
Aim: To implement DML (Data ManipulationLanguage) commands.
5. Select
6. Insert
7. Update
8. Delete
Theory:-
DML Statements
Data Manipulation Language (DML) commands are used for managing data in
database. DML commands are not auto-committed which means the changes
made by DML command are not permanent to database and can be rolled back.
SELECT
It is used to retrieve data from the database.
INSERT
It is used to insert data into the table.
UPDATE - It is used to update the existing data from the database.
DELETE
It is used to delete any existing record from the table.
Learning/ Conclusion
In this experiment, we learnt about DataManipulation Language (DML)
commands. We implemented the commands- created tables, added columns,
inserted data, updated data, deleted rows, dropped tables etc.