DBMS Unit 1 Notes
DBMS Unit 1 Notes
Introduction
Unit: 1
DBMS Unit-1
1
Course Objective
1
11-04-2025
Unit Objective
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.
2
11-04-2025
3
11-04-2025
4
11-04-2025
Summary
5
11-04-2025
Short Quiz
2. What is a database?
a)Organized collection of information that cannot be
accessed, updated, and managed
b) Collectionof data or information without organizing
c)Organizedcollection of data or information that can be
accessed, updated, and managed
d) Organized collection of data that cannot be updated
1. Data Model gives us an idea that how the final system will look like
after its complete implementation.
2. It defines the data elements and the relationships between the data
elements.
6
11-04-2025
Data Models
Data Models
7
11-04-2025
Levels of Abstraction
8
11-04-2025
Levels of Abstraction
⚫ 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)
9
11-04-2025
Data Independence
10
11-04-2025
11
11-04-2025
Short Quiz
1. Which of the following is known as a set of entities of the same type that
share same properties, or attributes?
a) Relation set
b) Tuples
c) Entity set
d) Entity Relation model
12
11-04-2025
1. 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.
4. Data Query Language (DQL) is used to fetch the data from the database.
13
11-04-2025
14
11-04-2025
These commands are used to update the database schema that's why
they come under Data definition language.
15
11-04-2025
• TCL is used to run the changes made by the DML statement. TCL
can be grouped into a logical transaction.
16
11-04-2025
Short Quiz
1. The ability to query data, as well as insert, delete, and alter tuples, is
offered by
a) TCL (Transaction Control Language)
b) DCL (Data Control Language)
c) DDL (Data Definition Langauge)
d) DML (Data Manipulation Langauge)
2. One of the major goals of Object relational data model is to close the
gap between relational databases and the object oriented practises
frequently used in many programming languages such as C++, C#, Java
etc.
3. Be able to write SQL statements that edit existing data. Be able to write
SQL statements that create database objects.
17
11-04-2025
Relational Model
18
11-04-2025
SQL
SQL
19
11-04-2025
Database Users
Database Administrator
20
11-04-2025
Storage Management
21
11-04-2025
Query Processing
22
11-04-2025
Transaction Management
23
11-04-2025
24
11-04-2025
Short Quiz
25
11-04-2025
Introduction of ER Model
• 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
26
11-04-2025
Attributes
• An entity is represented by a set of attributes, that is descriptive
properties possessed by all members of an entity set.
Example: customer = (customer_id, customer_name, customer_street,
customer_city )
loan = (loan_number, amount )
27
11-04-2025
Attribute Type
Attribute Type
28
11-04-2025
Attribute Type
Relationship Type
29
11-04-2025
Relationship Set
– Unary Relationship
– Binary Relationship
– n-ary Relationship
30
11-04-2025
Unary Relationship
Binary Relationship
31
11-04-2025
n-ary Relationship
Mapping Cardinality
32
11-04-2025
One to one
• When each entity in each entity set can take part only once in the
relationship, the cardinality is one to one. Let us assume that a
male can marry to one female and a female can marry to one male.
So the relationship will be one to one.
Many to one
• When entities in one entity set can take part only once in the
relationship set and entities in other entity set can take part more
than once in the relationship set, cardinality is many to one
33
11-04-2025
Many to many
• When entities in all entity sets can take part more than once in the
relationship cardinality is many to many. Let us assume that a
student can take more than one course and one course can be
taken by many students. So the relationship will be many to many.
Participation Constraint
34
11-04-2025
35
11-04-2025
36
11-04-2025
Keys in DBMS
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.
74
37
11-04-2025
There are mainly Eight 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.
76
38
11-04-2025
Super key
77
Primary Key
78
39
11-04-2025
79
Alternate key
80
40
11-04-2025
Candidate Key
• 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.
81
82
41
11-04-2025
Foreign key
• FOREIGN KEY is a column that creates a relationship between two
tables. The purpose of Foreign keys is to maintain data integrity and
allow navigation between two different instances of an entity. It
acts as a cross-reference between two tables as it references the
primary key of another table.
Example:
DeptCode DeptName
001 Science
002 English
005 Computer
84
42
11-04-2025
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
Composite key
86
43
11-04-2025
Surrogate key
87
Example:
44
11-04-2025
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.
You can have the single Primary key in a You can have multiple foreign keys in a
table. table.
Short Quiz
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?
1. Weak entity
2. Strong entity
3. ID-dependent entity
4. ID- independent entity
45
11-04-2025
2. Specialization helps in defining the set of subclasses of the entity type. Also,
it helps in establishing extra specific attributes with all subclasses and added
specific relationship types between each subclass and the other entity types
or the other subclasses.
Generalization
• Generalization is the process of extracting common properties from
a set of entities and create a generalized entity from it.
46
11-04-2025
Example:
Specialization
47
11-04-2025
Example:
Aggregation
• An ER diagram is not capable of representing relationship between
an entity and a relationship which may be required in some
scenarios.
• In those cases, a relationship with its corresponding entities is
aggregated into a higher level entity.
• Aggregation is an abstraction through which we can represent
relationships as higher level entity sets.
• For Example, Employee working for a project may require some
machinery. So, REQUIRE relationship is needed between
relationship WORKS_FOR and entity MACHINERY. Using
aggregation, WORKS_FOR relationship with its entities EMPLOYEE
and PROJECT is aggregated into single entity and relationship
REQUIRE is created between aggregated entity and MACHINERY.
48
11-04-2025
Example:
Topic –
Reduction of an ER diagrams to tables
Objectives
49
11-04-2025
RULE-02
50
11-04-2025
RULE-03
RULE-04
Rule-04: Translating Relationship Set into a Table
• A relationship set will require one table in the relational model.
• Attributes of the table are-
– Primary key attributes of the participating entity sets
– Its own descriptive attributes if any.
– Set of non-descriptive attributes will be the primary key.
51
11-04-2025
RULE-05
RULE-05 (contd..)
52
11-04-2025
RULE-05 (contd..)
NOTE- Here, combined table will be drawn for the entity set B and
relationship set R.
RULE-05 (contd..)
NOTE- Here, combined table will be drawn for the entity set A and
relationship set R.
53
11-04-2025
RULE-05 (contd..)
• 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 )
RULE-06
54
11-04-2025
RULE-06 (contd..)
Case-01: For Binary Relationship With Cardinality Constraint and
Total Participation Constraint From One Side
RULE-06 (contd..)
55
11-04-2025
RULE-07
Examples of ER Diagram
56
11-04-2025
57
11-04-2025
Codd’s 12 Rule
Codd’s 12 Rule
Rule 0: The Foundation Rule
The database must be in relational form. So that the system can handle the
database through its relational capabilities.
Rule 1: Information Rule
A database contains various information, and this information must be stored in
each cell of a table in the form of rows and columns.
Rule 2: Guaranteed Access Rule
Every single or precise data (atomic value) may be accessed logically from a
relational database using the combination of primary key value, table name, and
column name.
Rule 3: Systematic Treatment of Null Values
This rule defines the systematic treatment of Null values in database records. The
null value has various meanings in the database, like missing the data, no value in
a cell, inappropriate information, unknown data and the primary key should not
be null.
58
11-04-2025
Codd’s 12 Rule
Rule 4: Active/Dynamic Online Catalog based on the relational model
It represents the entire logical structure of the descriptive database that must be
stored online and is known as a database dictionary. It authorizes users to access
the database and implement a similar query language to access the database.
Rule 5: Comprehensive Data SubLanguage Rule
The relational database supports various languages, and if we want to access the
database, the language must be the explicit, linear or well-defined syntax,
character strings and supports the comprehensive:
Data definition
View definition
Data manipulation
Integrity constraints
Transaction boundaries (begin, commit and rollback)
Rule 6: View Updating Rule
All views table can be theoretically updated and must be practically updated by
the database systems.
Codd’s 12 Rule
Rule 8: Physical Data Independence Rule
All stored data in a database or an application must be physically independent to
access the database. Each data should not depend on other data or an
application. If data is updated or the physical structure of the database is
changed, it will not show any effect on external applications that are accessing
the data from the database.
Rule 9: Logical Data Independence Rule
It is similar to physical data independence. It means, if any changes occurred to
the logical level (table structures), it should not affect the user's view
(application). For example, suppose a table either split into two tables, or two
table joins to create a single table, these changes should not be impacted on the
user view application.
Rule 10: Integrity Independence Rule
A database must maintain integrity independence when inserting data into
table's cells using the SQL query language. All entered values should not be
changed or rely on any external factor or application to maintain integrity. It is
also helpful in making the database-independent for each front-end application.
59
11-04-2025
Codd’s 12 Rule
Rule 11: Distribution Independence Rule
The distribution independence rule represents a database that must work
properly, even if it is stored in different locations and used by different end-users.
Suppose a user accesses the database through an application; in that case, they
should not be aware that another user uses particular data, and the data they
always get is only located on one site. The end users can access the database, and
these access data should be independent for every user to perform the SQL
queries.
Rule 12: Non Subversion Rule
The non-submersion rule defines RDBMS as a SQL language to store and
manipulate the data in the database. If a system has a low-level or separate
language other than SQL to access the database system, it should not subvert or
bypass integrity to transform data.
60
11-04-2025
Summary of ER (Contd.)
Daily Quiz
61
11-04-2025
Weekly Assignment
Topic Links
1. [Link]
2. [Link]
3. [Link]
questions/
4. [Link]
questions-set-2/
62
11-04-2025
MCQ s
MCQ s
63
11-04-2025
Glossary Questions
• [Link]
[Link]
• [Link]
[Link]
• [Link]
[Link]
• [Link]
[Link]
64
11-04-2025
Recap of Unit
65
11-04-2025
66