DBMS Unit-I
DBMS Unit-I
DBMS Unit-I
Introduction
Unit: 1
DBMS
ACSAI0402 Shabnam Firdaus
Assistant Professor
Course Details (AI)
(B Tech IVth Sem)
2. IoT - IoT devices' primary purpose is often to collect and/or generate data and
share it for some higher purpose such as analytics, machine learning and artificial
intelligence. Consequently, IoT DBMSs need to manage not just data at rest, but
also data in transit.
Contd..
Contd..
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
ASCAI0402.1
2 2 3 3 3 2 3 2 2 2 2 3
ACSAI0402.2
3 3 3 2 2 2 2 2 2 2 2 3
ACSAI0402.3
2 3 3 3 3 2 2 2 2 2 2 2
ACSAI0402.4
2 3 2 2 2 2 2 2 2 3 2 2
ACSAI0402.5
2 3 2 2 2 3 2 2 3 2 2 2
AVG
2.20 2.80 2.60 2.40 2.40 2.20 2.20 2.00 2.20 2.20 2.00 2.40
PSO1: The ability to identify, analyze real world problems and design their ethical
solutions using artificial intelligence, robotics, virtual/augmented reality, data
analytics, block chain technology, and cloud computing.
PSO2:The ability to design and develop the hardware sensor devices and related
interfacing software systems for solving complex engineering problems.
PSO4: The ability to conduct investigation of complex problem with the help of
technical, managerial, leadership qualities, and moder engineering tools provided
by industry sponsored laboratories.
ACSAI0402.1
3 1 3 1
ACSAI0402.2
3 1 3 1
ACSAI0402.3
3 1 3 1
ACSAI0402.4
3 1 3 1
ACSAI0402.5
3 1 3 1
AVG
3.00 1.00 3.00 1.00
PEO4: To have life-long learning for up-skilling and re-skilling for successful
professional career as engineer, scientist, entrepreneur and bureaucrat for betterment
of society
ACSAI0402.1
3 1 3 1
ACSAI0402.2
3 1 3 1
ACSAI0402.3
3 1 3 1
ACSAI0402.4
3 1 3 1
ACSAI0402.5
3 1 3 1
AVG
3.00 1.00 3.00 1.00
SECTION – B CO
3. Answer any five of the following- [5×6=30]
3-a. Question- (6)
3-b. Question- (6)
3-c. Question- (6)
3-d. Question- (6)
3-e. Question- (6)
3-f. Question- (6)
3-g. Question- (6)
SECTION – C CO
4 Answer any one of the following- [5×10=50]
2. DDL stands for Data Definition Language. DML stands for Data
Manipulation Language. DDL statements are used to create
database, schema, constraints, users, tables etc. DML statement is
used to insert, update or delete the records.
Topic CO
Database system Vs File system CO1
05/12/2023 24
Topic mapping with CO
Topic CO
Candidate key CO1
Primary key CO1
Generalization, Aggregation CO1
Reduction CO1
of an ER diagrams to tables
Extended ER model CO1
05/12/2023 25
Lecture 1
• Why we use DBMS
• File vs DBMS
• Purpose of Database system
05/12/2023 26
Topic – DBMS Objective
The file system is software that manages DBMS is software for managing the
Structure and organizes the files in a storage
database.
medium within a computer.
In the early days, database applications were built directly on top of
file systems
Drawbacks of using file systems to store data:
Data redundancy and inconsistency
Multiple file formats, duplication of information in different
files
Difficulty in accessing data
Need to write a new program to carry out each new task
Data isolation — multiple files and formats
Integrity problems
Integrity constraints (e.g. account balance > 0) become
“buried” in program code rather than being stated explicitly
Hard to add new constraints or change existing ones
2. What is a database?
a) Organized collection of information that cannot be
accessed, updated, and managed
b) Collection of data or information without organizing
c) Organized collection of data or information that can be
accessed, updated, and managed
d) Organized collection of data that cannot be updated
05/12/2023 38
Topic – Data models Objective
1) Relational Data Model: This type of model designs the data in the form
of rows and columns within a table. Thus, a relational model uses tables for
representing data and in-between relationships. Tables are also called
relations.
• Two-tier architecture:
The two-tier architecture is similar to a basic client-server model.
• The application at the client end directly communicates with the
database at the server side using API.
• (Application Programming Interface (API) is a software
interface that allows two applications to interact with each
other without any user intervention. API is a collection of
software functions and procedures. In simple terms, API means
a software code that can be accessed or executed. API is defined
as a code that helps two different software’s to communicate
and exchange data with each other.)
• What is a Schema?
•Physical Database Schema − This schema pertains to the actual storage of data and
its form of storage like files, indices, etc. It defines how the data will be stored in a
secondary storage.
•Logical Database Schema − This schema defines all the logical constraints that
need to be applied on the data stored. It defines tables, views, and integrity
constraints.
Conceptual Schema
• The conceptual schema describes the design of a database at
the conceptual level. Conceptual level is also known as
logical level.
• The conceptual schema describes the structure of the whole
database.
• The conceptual level describes what data are to be stored in
the database and also describes what relationship exists
among those data.
• In the conceptual level, internal details such as an
implementation of the data structure are hidden.
• Programmers and database administrators work at this level.
View Layer
• Each view schema describes the database part
that a particular user group is interested and
hides the remaining database from that user
group.
• The view schema describes the end user
interaction with database systems.
• It also simplifies interaction with the user and it
provides many views or multiple views of the
same database.
05/12/2023 Shabnam Firdaus ACSAI-0402 -DBMS Unit-1 62
Example: University Database
Physical schema:
Relations stored as unordered files.
Index on first column of Students.
Conceptual schema:
Students(sid: string, name: string, login: string, age: integer,
gpa:real)
Courses(cid: string, cname:string, credits:integer)
Enrolled(sid:string, cid:string, grade:string)
External Schema (View):
View1- Course_info(cid:string,enrollment:integer)
View2-studeninfo(id:int. name:string)
• Data independence helps you to keep data separated from all programs
that make use of it.
• We know the main purpose of the three levels of data abstraction is to achieve
data independence. If the database changes and expands over time, it is very
important that the changes in one level should not affect the data at other levels of
the database. This would save time and cost required when changing the database.
• There are two levels of data independence based on three levels of abstraction.
These are as follows −
• Physical Data Independence
• Logical Data Independence
One of the most important benefits of using a DBMS!
• Logical view of data is the user view of the data. It presents data in
the form that can be accessed by the end users.
• Logical data independence refers characteristic of being able to
change the conceptual schema without having to change the
external schema.
05/12/2023 71
DATA BASE LANGUAGE (CO1)
Language The DELETE command is Data Manipulation The DROP command is Data The TRUNCATE command is a Data
Language Command. Definition Language Command. Definition Language Command.
The DELETE command deletes one or more The DROP Command drops the The TRUNCATE Command deletes all the
Use existing records from the table in the rows from the existing table, leaving the
database. complete table from the database. row with the column names.
We can restore any deleted row or multiple We cannot get the complete table We cannot restore all the deleted rows
Transition rows from the database using the deleted from the database using from the database using the ROLLBACK
ROLLBACK command. the ROLLBACK command. command.
The DELETE command does not free the The DROP command removes the The TRUNCATE command does not free
Memory Space space allocated for the table from the space allocated for the table from
allocated space of the table from memory. memory. memory.
• Mapping Cardinality
• Participation Constraint
• Keys in DBMS
05/12/2023 83
Topic- ER Model Objective
• An entity set is a set of entities of the same type that share the
same properties.
– Example: set of all persons, companies, trees, holidays
– Unary Relationship
– Binary Relationship
– n-ary Relationship
Example:
In a particular hospital, the surgeon department has one head of department. They both
serve one-to-one relationships.
Example:
A doctor can prescribe more than one medicine
Example:
In a particular hospital, multiple surgeries are done by a single surgeon. Such a
type of relationship is known as a many-to-one relationship.
Example:
In a particular company, multiple people work on multiple projects. They serve many-
to-many relationships.
Here are some reasons for using SQL key in the DBMS system.
• Keys help you to identify any row of data in a table.
• In a real-world application, a table could contain thousands of
records. Moreover, the records could be duplicated.
• Keys in RDBMS ensure that you can uniquely identify a table record
despite these challenges.
• Allows you to establish a relationship between and identify the
relation between tables
• Help you to enforce identity and integrity in the relationship.
There are mainly seven different types of Keys in DBMS and each key
has it’s different functionality:
– Super Key – A super key is a group of single or multiple keys
which identifies rows in a table.
– Primary Key – is a column or group of columns in a table that
uniquely identify every row in that table.
– Candidate Key – is a set of attributes that uniquely identify
tuples in a table. Candidate Key is a super key with no
repeated attributes.
– Alternate Key – is a column or group of columns in a table that
uniquely identify every row in that table.
• Candidate key Example: In the given table Stud ID, Roll No, and
email are candidate keys which help us to uniquely identify the
student record in the table.
• Syntax:
CREATE TABLE Orders (
OrderID int NOT NULL,
OrderNumber int NOT NULL,
PersonID int,
PRIMARY KEY (OrderID),
FOREIGN KEY (PersonID) REFERENCES Persons(PersonID));
• This concept is also known as Referential Integrity.
05/12/2023 Shabnam Firdaus ACSAI-0402 -DBMS Unit-1 118
Compound key
• COMPOUND KEY has two or more attributes that allow you to uniquely
recognize a specific record. It is possible that each column may not be
unique by itself within the database. However, when combined with
the other column or columns the combination of composite keys
become unique.
Example:
OrderNo PorductID Product Name Quantity
B005 JAP102459 Mouse 5
B005 DKT321573 USB 10
B005 OMG446789 LCD Monitor 20
B004 DKT321573 USB 15
B002 OMG446789 Laser Printer 3
Helps you to uniquely identify a record in It is a field in the table that is the primary
the table. key of another table.
Primary key is a clustered index and data A foreign key cannot automatically create
an index, clustered or non-clustered.
in the DBMS table are physically organized
However, you can manually create an
in the sequence of the clustered index. index on the foreign key.
You can have the single Primary key in a You can have multiple foreign keys in a
table. table.
Q. Which type of entity cannot exist in the database unless another type
of entity also exists in the database, but does not require that the
identifier of that other entity be included as part of its own identifier?
5. Weak entity
6. Strong entity
7. ID-dependent entity
8. ID- independent entity
05/12/2023 Shabnam Firdaus ACSAI-0402 -DBMS Unit-1 122
Lecture 6
• Generalization, Specialization and Aggregation
• Reduction of an ER diagram to tables
• Examples of ER Diagram
05/12/2023 123
Topic- Generalization, Specialization and Aggregation
Objective
•
05/12/2023 Shabnam Firdaus ACSAI-0402 -DBMS Unit-1 135
RULE-05 (contd..)
NOTE- Here, combined table will be drawn for the entity set B and
relationship set R.
NOTE- Here, combined table will be drawn for the entity set A and
relationship set R.
• Here, two tables will be required. Either combine ‘R’ with ‘A’ or ‘B’
• Way-01:
1. AR ( a1 , a2 , b1 )
2. B ( b1 , b2 )
• Way-02:
1. A ( a1 , a2 )
2. BR ( a1 , b1 , b2 )
1. https://www.geeksforgeeks.org/last-minute-notes-dbms/
2. https://www.geeksforgeeks.org/quiz-corner-gq/#DBMS%20Mock%20Tests
3. https://www.geeksforgeeks.org/commonly-asked-dbms-interview-questio
ns/
4. https://www.geeksforgeeks.org/commonly-asked-dbms-interview-questio
ns-set-2/
• Which of the following is generally used for performing tasks like creating the
structure of the relations, deleting relation?
DML(Data Manipulation Language)
Query
Relational Schema
DDL(Data Definition Language)
• Which of the following provides the ability to query information from the database
and insert tuples into, delete tuples from, and modify tuples in the database?
1. Attempt all the parts. Pick the correct option from glossary. [CO1]
(i) Double diamonds (ii) Database Management System (iii) Diamond (iv) Entity set
(a). _____________is the full form of DBMS.
(b). A weak relationship is represented in E-R diagram as___________.
(c) The Rectangles in E-R diagram represents____________________.
(d). The relationship is represented in E-R diagram as_____________.
2. Attempt all the parts. Pick the correct option from glossary. [CO1]
(i ) FALSE (ii) TRUE (iii) Tuple (iv) Meta Data
(a) A row of a relation is known as____________.
(b)_____________________refers to the "data about data"?
(c) Alternate Key is a kind of partial key in DBMS, which is created when you don’t have any
natural primary key._______
(d) Generalization
05/12/2023 is a bottom-up Shabnam
approach.______
Firdaus ACSAI-0402 -DBMS Unit-1 155
Sessional Paper-1
05/12/2023 162
Conti….
05/12/2023 166
Conti….
• http://www.aktuonline.com/papers/btech-cs-5-sem-data-base-man
agement-system-KCS501-2020.pdf
• http://www.aktuonline.com/papers/btech-cs-5-sem-database-man
agement-system-KCS-501-2018-19.pdf
• http://www.aktuonline.com/papers/btech-cs-5-sem-database-man
agement-system-ncs-502-2017-18.pdf
• http://www.aktuonline.com/papers/btech-cs-5-sem-database-man
agement-system-ncs-502-2016-17.pdf