0% found this document useful (0 votes)
68 views179 pages

Final - DBMS UNIT-1

This document provides information about a Database Management Systems (DBMS) course being taught at Noida Institute of Engineering and Technology. It introduces the instructor, Neeti Taneja, and outlines the course details including evaluation scheme, syllabus, applications, objectives, outcomes, program outcomes, program specific outcomes, and program educational objectives. The document aims to provide students an overview of the DBMS course.

Uploaded by

Sunil Kumer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views179 pages

Final - DBMS UNIT-1

This document provides information about a Database Management Systems (DBMS) course being taught at Noida Institute of Engineering and Technology. It introduces the instructor, Neeti Taneja, and outlines the course details including evaluation scheme, syllabus, applications, objectives, outcomes, program outcomes, program specific outcomes, and program educational objectives. The document aims to provide students an overview of the DBMS course.

Uploaded by

Sunil Kumer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 179

Noida Institute of Engineering and Technology, Greater Noida

Introduction

Unit: 1

DBMS Neeti Taneja


Assistant Professor
Course Details CSE Department
(B Tech Vth Sem)

Neeti Taneja DBMS Unit-1


1
11/04/2023
Brief introduction of faculty Member

Neeti Taneja
Designation: Assistant Professor(CSE Department)
NIET, Greater Noida
Qualification:
 B.Tech(CSE) from SRMIET, Naraingarh ,Haryana affiliated
to
Kurukshetra University in 2011.
M.E(CSE) from Chitkara University, Rajpura,Punjab in 2015.
Pursuing PhD from Sharda University,Greater Noida.
Teaching Experience: 8 years
Research Publication
Particulars Journals
International 16
National Nil

11/04/2023 Neeti Taneja DBMS Unit-1 2


Evaluation Scheme

11/04/2023 Neeti Taneja DBMS Unit-1 3


Subject Syllabus

11/04/2023 Neeti Taneja DBMS Unit-1 4


Subject Syllabus

11/04/2023 Neeti Taneja DBMS Unit-1 5


Branch wise Applications

• Railway Reservation System


• Library Management System
• Banking
• Education Sector
• Credit card exchanges
• Social Media Sites
• Broadcast communications
• Account
• Online Shopping
• Human Resource Management
• Manufacturing
• Airline Reservation System
• Healthcare

11/04/2023 Neeti Taneja DBMS Unit-1 6


Course Objectives

Present an introduction to database management systems,


with an emphasis on how to organize, maintain and retrieve
- efficiently, and effectively - information from a DBMS.

Differentiate between database system and file system.

Knowledge of the different models like database


modeling, relational, hierarchical and network models.

Explain basic issues of transaction processing and


concurrency control.

11/04/2023 Neeti Taneja DBMS Unit-1 7


Course Outcomes
At the end of semester students will be able
CO1 Analyse database used to solve real world and
complex problem and design the ER, EER model
CO2 Analyse and apply structured Query Language (SQL)
or procedural Query Language (PL/SQL) to solve the
complex queries. Implement relational model,
integrity constraints.
CO3 Design and implement database for storing , managing
data efficiently by applying the Normalization process
on the database.
CO4 Synthesize the concepts of transaction management,
concurrency control and recovery
CO5 Understand and implement the concepts NOSQL with
cloud database

11/04/2023 Neeti Taneja DBMS Unit-1 8


Program Outcomes (POs)
Engineering Graduates will be able to:
1. Engineering knowledge: Apply the knowledge of mathematics, science,
engineering fundamentals, and an engineering specialization to the solution of
complex engineering problems.

2. Problem analysis: Identify, formulate, review research literature, and analyze


complex engineering problems reaching substantiated conclusions using first
principles of mathematics, natural sciences, and engineering sciences.

3. Design/development of solutions: Design solutions for complex engineering


problems and design system components or processes that meet the specified
needs with appropriate consideration for the public health and safety, and the
cultural, societal, and environmental considerations.

4. Conduct investigations of complex problems: Use research-based knowledge


and research methods including design of experiments, analysis and interpretation
of data, and synthesis of the information to provide valid conclusions.

11/04/2023 Neeti Taneja DBMS Unit-1 9


Program Outcomes (POs)

Contd..
5. Modern tool usage: Create, select, and apply appropriate techniques, resources,
and modern engineering and IT tools including prediction and modeling to
complex engineering activities with an understanding of the limitations.

6. The engineer and society: Apply reasoning informed by the contextual


knowledge to assess societal, health, safety, legal and cultural issues and the
consequent responsibilities relevant to the professional engineering practice.

7. Environment and sustainability: Understand the impact of the professional


engineering solutions in societal and environmental contexts, and demonstrate the
knowledge of, and need for sustainable development.

8. Ethics: Apply ethical principles and commit to professional ethics and


responsibilities and norms of the engineering practice.

11/04/2023 Neeti Taneja DBMS Unit-1 10


Program Outcomes (POs)

Contd..
9. Individual and team work: Function effectively as an individual, and as a
member or leader in diverse teams, and in multidisciplinary settings.

10. Communication: Communicate effectively on complex engineering


activities with the engineering community and with society at large, such as,
being able to comprehend and write effective reports and design
documentation, make effective presentations, and give and receive clear
instructions.
11. Project management and finance: Demonstrate knowledge and
understanding of the engineering and management principles and apply these
to one’s own work, as a member and leader in a team, to manage projects and
in multidisciplinary environments.

12. Life-long learning: Recognize the need for, and have the preparation and
ability to engage in independent and life-long learning in the broadest context
of technological change.

11/04/2023 Neeti Taneja DBMS Unit-1 11


CO-PO Mapping

CO-PO CORRELATION MATRIX


PO PO PO PO PO1 PO1 PO
CO.K PO3 PO5 PO6 PO7 PO9
1 2 4 8 0 1 12
ACSE0506.
2 2 3 2 3 3 - 1 - 2 2 3
1
ACSE0506.
2 2 2 2 2 2 - 1 - 1 2 2
2
ACSE0506.
2 2 3 2 3 2 - 2 - 1 2 3
3
ACSE0506.
3 3 3 3 3 2 - 2 - 2 1 3
4
ACSE0506.
3 2 2 2 3 2 - 2 1 3 3 3
5
AVERAGE 2.4 2.2 2.6 2.2 2.8 2.2 - 1.6 1 1.8 2 2.8

11/04/2023 Neeti Taneja DBMS Unit-1 12


Program Specific Outcomes

On successful completion of graduation degree the Computer


Science & Engineering graduates will be able to:
Work as a software developer, database administrator, tester
PSO1: or networking engineer for providing solutions to the real
world and industrial problems. ​
Apply core subjects of information technology related to
data structure and algorithm, software engineering, web
PSO2:
technology, operating system, database and networking to
solve complex IT problems. ​
Practice multi-disciplinary and modern computing
PSO3: techniques by lifelong learning to establish innovative
career.
Work in a team or individual to manage projects with ethical
PSO4: concern to be a successful employee or employer in IT
industry.

11/04/2023 Neeti Taneja DBMS Unit-1 13


CO-PSO Mapping

Program Specific
Outcomes
PSO1 PSO2 PSO3 PSO4
ACSE0506.1 3 1 3 1
ACSE0506.2 3 1 3 1
ACSE0506.3 3 1 3 1
ACSE0506.4 3 1 3 1
ACSE0506.5 3 1 3 1
AVG 3.00 1.00 3.00 1.00

11/04/2023 Neeti Taneja DBMS Unit-1 14


Program Educational Objectives (PEOs)

• PEO1:Apply sound knowledge in the field of information


technology to fulfill the needs of IT industry.
• PEO2:Design innovative and interdisciplinary systems
through latest digital technologies.
• PEO3:Inculcate professional – social ethics, team work and
leadership for serving the society.
• PEO4:Inculcate lifelong learning in the field of computing
for successful career in organizations and R&D sectors.

11/04/2023 Neeti Taneja DBMS Unit-1 15


Result Analysis

11/04/2023 Neeti Taneja DBMS Unit-1 16


Question Paper Template

11/04/2023 Neeti Taneja DBMS Unit-1 17


Question Paper Template
SECTION – A CO

1. Attempt all parts- [10×1=10]

1-a. Question- (1)


1-b. Question- (1)
1-c. Question- (1)
1-d. Question- (1)
1-e. Question- (1)
1-f. Question- (1)
1-g. Question- (1)
1-h. Question- (1)
1-i. Question- (1)
1-j. Question- (1)

2. Attempt all parts- [5×2=10] CO

2-a. Question- (2)


2-b. Question- (2)
2-c. Question- (2)
2-d. Question- (2)
2-e. Question- (2)

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]

4-a. Question- (10)

4-b. Question- (10)


5. Answer any one of the following-
5-a. Question- (10)

5-b. Question- (10)


6. Answer any one of the following-
6-a. Question- (10)

6-b. Question- (10)


7. Answer any one of the following-
7-a. Question- (10)

7-b. Question- (10)

8. Answer any one of the following-


8-a. Question- (10)

8-b. Question- (10)

11/04/2023 Neeti Taneja DBMS Unit-1 18


Prerequisite and Recap

• There is No prerequisite for learning DBMS from scratch


although having basic knowledge of discrete mathematics and
data structure is added advantage.
• Having knowledge of basic mathematics like - SUM,
DIFFERENCE, AVERAGE, MEAN, MEDIAN, MODE, etc will
definitely be a plus point.
• Having knowledge on Set Theory will help.
• The proper understanding of data structures (B and B+ trees)
will help you to understand the DBMS quickly.

11/04/2023 Neeti Taneja DBMS Unit-1 19


Brief Introduction about the Subject

1. 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.
2. 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.
3. 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.
Video Link:
https://www.youtube.com/watch?v=3EJlovevfcA&t=436s

11/04/2023 Neeti Taneja DBMS Unit-1 20


Content – Unit 1

• Introduction: An overview of database management system,


database system Vs file system, Database system concept and
architecture, data model schema and instances, data independence
and database language and interfaces, data definitions language,
DML.
• Data Modeling using the Entity Relationship Model: ER model
concepts, notation for ER diagram, mapping constraints, keys,
Concepts of Super Key, candidate key, primary key, Generalization,
aggregation, reduction of an ER diagrams to tables, extended ER
model, relationship of higher degree.

11/04/2023 Neeti Taneja DBMS Unit-1 21


Unit Objective

1. The main objectives of database management system are data


availability, data integrity, data security, and data independence.

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.

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

11/04/2023 Neeti Taneja DBMS Unit-1 22


Data & Information

What is Data?

Data : Data is the raw facts and figures. It is represented with


the help of characters like alphabets(A-Z), digits(0-9) and
special characters (+,-,/,*,<,>,= etc.)
Example : 26 , Rohit,
What is Information ?

Information . Processed data is called information.


It is a set of organized or classified data so that it has
some meaningful values.
Example : Age 26 is information, Name of Person is Rohit

11/04/2023 Neeti Taneja DBMS Unit-1 23


Database

What is Database?
The term ‘Database’ is made up of two separate words, i.e. Data and base
means database is a base of data.

Database is a collection of inter related data which is used to retrieve,


insert and delete the data efficiently. It is also used to organize the data
in the form of table, view and report etc.

Database is actually a place where related piece of information is stored


and various operations can be performed on it.
Example : The college database organizes the data about the admin staff,
student and faculty etc.

11/04/2023 Neeti Taneja DBMS Unit-1 24


Database Management System(DBMS)

A database Management System is a collection of programs that


enables users to create and maintain a database.
DBMS is a general purpose software system that facilitate the
process of defining , constructing , manipulating and sharing
database among various users and applications.
 Defining a database involves specifying the data types, structures
and constraints for the data to be stored in the database.
 Constructing the database is the process of storing the data itself
on some storage medium.
 Manipulating a database includes querying the database to
retrieve the information, updating the database and generating
the report.
 Sharing a database allows multiple users and programs to access
the database concurrently.

11/04/2023 Neeti Taneja DBMS Unit-1 25


What is a DBMS? (CO1)

• A very large, integrated collection of related data.


• Models real-world enterprise.
– Entities (e.g., students, courses)
– Relationships (e.g., Madonna is taking CS564)
• A Database Management System (DBMS) is a software package
designed to define,construct and manipulate database.
• Database + Database Management System= Database System.

11/04/2023 Neeti Taneja DBMS Unit-1 26


Example Of DBMS Software

A software package/ system to facilitate the creation and


maintenance of a computerized database.
Example :

11/04/2023 Neeti Taneja DBMS Unit-1 27


Need of Database Management System

Good data management is an essential prerequisite to


corporate success.

Data Information
Information Knowledge
Knowledge Judgment
Judgment Decision
Decision Success

provided that data is:


• complete
• accurate
• timely
• easily available
11/04/2023 Neeti Taneja DBMS Unit-1 28
Why Use a DBMS?

• Data independence and efficient access.


• Reduced application development time.
• Data integrity and security.
• Uniform data administration.
• Concurrent access, recovery from crashes.

11/04/2023 Neeti Taneja DBMS Unit-1 29


How to maintain database in real life

Database in real life can be maintained in two ways

1. Manually:- By Human like as Register, paper and copy etc.

2. Automatic :- By Computerized like as Spread sheet, Flat file


system, and by specific database Software tools etc .

Example :- Student, University, Company, Government etc.

11/04/2023 Neeti Taneja DBMS Unit-1 30


Purpose of Database Systems
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

11/04/2023 Neeti Taneja DBMS Unit-1 31


Purpose of Database Systems (Cont.)

• Drawbacks of using file systems (cont.)


– Atomicity of updates
• Failures may leave database in an inconsistent state with
partial updates carried out
• Example: Transfer of funds from one account to another
should either complete or not happen at all
– Concurrent access by multiple users
• Concurrent access needed for performance
• Uncontrolled concurrent accesses can lead to inconsistencies
– Example: Two people reading a balance and updating it
at the same time
– Security problems
• Hard to provide user access to some, but not all, data
• Database systems offer solutions to all the above problems

11/04/2023 Neeti Taneja DBMS Unit-1 32


Database System Vs. File System

The database management system has a number of advantages as


compared to traditional computer file-based processing approach.
1. Controlling Data Redundancy
In non-database systems each application program has its own
private files. In this case, the duplicated copies of the same data is
created in many places. In DBMS, all data of an organization is
integrated into a single database file. The data is recorded in only
one place in the database and it is not duplicated.
2.Data Consistency
By controlling the data redundancy, the data consistency is
obtained. If a data item appears only once, any update to its value
has to be performed only once and the updated value is
immediately available to all users. If the DBMS has controlled
redundancy, the database system enforces consistency.
11/04/2023 Neeti Taneja DBMS Unit-1 33
Database System Vs. File System

3. Data Isolation problem:- In file system the data are scattered in


various files, and files may have different formats. So writing new
application program to retrieve the appropriate data is difficult.

4. Integration of Data
When new constraints are added in file processing system, It is
difficult to change the program to enforce them, The problem is
compounded when constraint involve several data items from
different files.
Integrity constraints or consistency rules can be applied to database,
the constraints are such that it can be applied to data item within
a single record or it may be applied to relationships between
records.

11/04/2023 Neeti Taneja DBMS Unit-1 34


Database System Vs. File System

5. Sharing of Data
In DBMS, data can be shared by authorized users of the organization.
The database administrator manages the data and gives rights to
users to access the data. Many users can be authorized to access the
same piece of information simultaneously. The remote users can
also share the same data. Similarly, the data of same database can
be shared between different application programs.

6. Atomicity Problem
In many applications , It is crucial that if failure occur, the data is
restored to the consistent state that existed prior to the failure.
Atomicity means:- either all or not at all.

11/04/2023 Neeti Taneja DBMS Unit-1 35


Database System Vs. File System

7. Control Over Concurrency


In a computer file-based system, if two users are allowed to access data
simultaneously, it is possible that they will interfere with each other. For
example, if both users attempt to perform update operation on the same
record, then one may overwrite the values recorded by the other. Most
database management systems have sub-systems to control the concurrency
so that transactions are always recorded with accuracy.

8. Backup and Recovery Procedures


In a computer file-based system, the user creates the backup of data
regularly to protect the valuable data from damage due to failures to the
computer system or application program. It is very time consuming method,
if amount of data is large. Most of the DBMSs provide the 'backup and
recovery' sub-systems that automatically create the backup of data and
restore data if required.

11/04/2023 Neeti Taneja DBMS Unit-1 36


Database System Vs. File System

9. Data Independence
The separation of data structure of database from the application program
that uses the data is called data independence. In DBMS, you can easily
change the structure of database without modifying the application
program.

11/04/2023 Neeti Taneja DBMS Unit-1 37


Advantages of DBMS

There are various advantages of DBMS are:-


1. Control database redundancy
2. Data Sharing
3. Easy maintenance
4. Backup and Recovery
5. Multiuser or multiple User interface

11/04/2023 Neeti Taneja DBMS Unit-1 38


Disadvantages of DBMS

There are various disadvantages of DBMS are:-


1. Cost of Hardware and Software
2. Complexity of Backup and recovery
3. Cost of Staff training
4. Cost of Data conversion
5. Higher impact of failure

11/04/2023 Neeti Taneja DBMS Unit-1 39


Database Applications

There are some examples of database applications:-

Banking: all transactions


Airlines: reservations, schedules
Universities: registration, grades
Sales: customers, products, purchases
Manufacturing: production, inventory, orders, supply
chain
Human resources: employee records, salaries, tax
deductions.

11/04/2023 Neeti Taneja DBMS Unit-1 40


Summary

• DBMS used to maintain, query large datasets.


• Benefits include recovery from system crashes, concurrent access, quick
application development, data integrity and security.
• Levels of abstraction give data independence.
• A DBMS typically has a layered architecture.
• DBAs hold responsible jobs and are well-paid! 
• DBMS R&D is one of the broadest, most exciting areas in CS.

11/04/2023 Neeti Taneja DBMS Unit-1 41


Short Quiz

1. What is the full form of DBMS?


a) Data of Binary Management System
b) Database Management System
c) Database Management Service
d) Data Backup Management System

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

11/04/2023 Neeti Taneja DBMS Unit-1 42


Components of DBMS

A database System involves four major components

I. Data
II. Hardware
III. Software
IV. Users

11/04/2023 Neeti Taneja DBMS Unit-1 43


Three Views of Data
 The database can be viewed from different levels of abstraction to reveal
different levels of details. From a bottom-up manner, we may find that
there are three levels of abstraction or views in the database.
 The term Abstraction is very important here. Generally it means the
amount of details you want to hide. Any entity can be seen from different
perspectives and levels of complexity to make it a reveal its current
amount of abstraction.
• Physical level: describes how a record (e.g., customer) is stored

• Logical level: describes data stored in database, and the relationships


among the data.

• View level: application programs hide details of data types. Views can
also hide information (such as an employee’s salary) for security purposes.

11/04/2023 Neeti Taneja DBMS Unit-1 44


Three Views of Data

The word schema means arrangement – how we want to arrange things


that we have to store. The diagram above shows the three different
schemas used in DBMS, seen from different levels of abstraction.
Instance – the actual content of the database at a particular point in
time. Analogous to the value of a variable.
11/04/2023 Neeti Taneja DBMS Unit-1 45
Schema

Schema
 A database schema is the skeleton structure that represents the logical
view of the entire database.
 It is not expected to change frequently.
 When we define a new database we specify its database schema.
 It defines how the data is organized and how the relations among them
are associated.
 It formulates all the constraints that are to be applied on the data.
Example:

Roll _No S_name Age Address Pincode

11/04/2023 Neeti Taneja DBMS Unit-1 46


Instance
Instance
Database Instance change overtime as information is inserted and deleted.
The collection of information stored in the database at a particular moment is
called an instance of the database.
It is also called database state or snapshot.( actual content of the database at
a particular point in time)
For example, lets say we have a single table student in the database, today the
table has 100 records, so today the instance of the database has 100 records.
Lets say we are going to add another 100 records in this table by tomorrow so
the instance of database tomorrow will have 200 records in table. In short, at
a particular moment the data stored in database is called the instance, that
changes over time when we add or delete data from the database.

11/04/2023 Neeti Taneja DBMS Unit-1 47


Three Schemas of Data
Internal Schema
• The lowest level, called the Internal or Physical schema, deals with the
description of how raw data items (like 1, ABC, KOL, H2 etc.) are stored in
the physical storage (Hard Disc, CD, Tape Drive etc.).
• It also describes the data type of these data items, the size of the items in
the storage media, the location (physical address) of the items in the
storage device and so on.
• This schema is useful for database application developers and database
administrator.
Conceptual or Logical Schema
• The middle level is known as the Conceptual or Logical Schema, and deals
with the structure of the entire database. Please note that at this level we
are not interested with the raw data items anymore, we are interested
with the structure of the database.

11/04/2023 Neeti Taneja DBMS Unit-1 48


Three Schemas of Data
•This means we want to know the information about the attributes of
each table, the common attributes in different tables that help them to be
combined, what kind of data can be input into these attributes, and so
on.
•Conceptual or Logical schema is very useful for database
administrators whose responsibility is to maintain the entire database.
External or View Schema.
•This is targeted for the end users. Now, an end user does not need to
know everything about the structure of the entire database, rather than
the amount of details he/she needs to work with. We may also not allow
this for the purpose of security, where sensitive information must remain
hidden from unwanted persons.
•The database administrator may want to create custom made tables,
keeping in mind the specific kind of need for each user. These tables are
also known as virtual tables, because they have no separate physical
existence. They are created dynamically for the users at runtime.

11/04/2023 Neeti Taneja DBMS Unit-1 49


Three schema architecture

11/04/2023 Neeti Taneja DBMS Unit-1 50


Levels of Abstraction

• Physical Schema/Level: describes how a record (e.g., customer) is


stored.
• Logical Schema/Level: describes data stored in database, and the
relationships among the data.
type customer = record
customer_id : string;
customer_name : string;
customer_street : string;
customer_city : string;
end;
• External Schema/Level: application programs hide details of data
types. Views can also hide information (such as an employee’s
salary) for security purposes.

11/04/2023 Neeti Taneja DBMS Unit-1 51


Levels of Abstraction

• Three Schema Architecture for a Database System

11/04/2023 Neeti Taneja DBMS Unit-1 52


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)

11/04/2023 Neeti Taneja DBMS Unit-1 53


Data Independence

• Data Independence is defined as a property of DBMS that helps you


to change the Database schema at one level of a database system
without requiring to change the schema at the next higher level.

• Data independence helps you to keep data separated from all


programs that make use of it.

• In DBMS there are two types of data independence


– Physical data independence
– Logical data independence.

 One of the most important benefits of using a DBMS!

11/04/2023 Neeti Taneja DBMS Unit-1 54


Physical Data Independence

• Physical data independence can be defined as the capacity to


change the internal schema without having to change the
conceptual schema.

• If we do any changes in the storage size of the database system


server, then the Conceptual structure of the database will not be
affected.

• Physical data independence is used to separate conceptual levels


from the internal levels.

• Physical data independence occurs at the logical interface level.

11/04/2023 Neeti Taneja DBMS Unit-1 55


Physical Data Independence (contd..)

• Due to Physical independence, any of the below change will not


affect the conceptual layer.
– Using a new storage device like Hard Drive or Magnetic Tapes
– Modifying the file organization technique in the Database
– Switching to different data structures.
– Changing the access method.
– Modifying indexes.
– Changes to compression techniques or hashing algorithms.
– Change of Location of Database from say C drive to D Drive

11/04/2023 Neeti Taneja DBMS Unit-1 56


Logical Data Independence

• Logical data independence refers to the characteristic of being able


to change the conceptual schema without having to change the
external schema.

• Logical data independence is used to separate the external level


from the conceptual view.

• If we do any changes in the conceptual view of the data, then the


user view of the data would not be affected.

• Logical data independence occurs at the user interface level.

11/04/2023 Neeti Taneja DBMS Unit-1 57


Logical Data Independence (contd..)

• Due to Logical independence, any of the below change will not


affect the external layer.
– Add/Modify/Delete a new attribute, entity or relationship is
possible without a rewrite of existing application programs
– Merging two records into one
– Breaking an existing record into two or more records

11/04/2023 Neeti Taneja DBMS Unit-1 58


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

2. The values appearing in given attributes of any tuple in the referencing


relation must likewise occur in specified attributes of at least one tuple
in the referenced relation, according to _____________________
integrity constraint.
a) Referential
b) Primary
c) Referencing
d) Specific
11/04/2023 Neeti Taneja DBMS Unit-1 59
DATA BASE LANGUAGE (CO1)

• A DBMS has appropriate languages and interfaces to express


database queries and updates.
• Database languages can be used to read, store and update the data
in the database.
• Two classes of languages
– Procedural – user specifies what data is required and how to get
those data
– Declarative (nonprocedural) – user specifies what data is
required without specifying how to get those data
• SQL is the most widely used query language

11/04/2023 Neeti Taneja DBMS Unit-1 60


DATA BASE LANGUAGE

11/04/2023 Neeti Taneja DBMS Unit-1 61


Data Definition Language (DDL)

• DDL stands for Data Definition Language. It is used to define


database structure or pattern.
• It is used to create schema, tables, indexes, constraints, etc. in the
database.
• Using the DDL statements, you can create the skeleton of the
database.
• Data definition language is used to store the information of
metadata like the number of tables and schemas, their names,
indexes, columns in each table, constraints, etc.

11/04/2023 Neeti Taneja DBMS Unit-1 62


Data Definition Language (DDL)

• Here are some tasks that come under DDL:


– Create: It is used to create objects in the database.
– Alter: It is used to alter the structure of the database.
– Drop: It is used to delete objects from the database.
– Truncate: It is used to remove all records from a table.
– Rename: It is used to rename an object.

These commands are used to update the database schema that's why
they come under Data definition language.

11/04/2023 Neeti Taneja DBMS Unit-1 63


Data Manipulation Language (DML)

• DML stands for Data Manipulation Language. It is used for accessing


and manipulating data in a database. It handles user requests.
• Here are some tasks that come under DML:
– Select: It is used to retrieve data from a database.
– Insert: It is used to insert data into a table.
– Update: It is used to update existing data within a table.
– Delete: It is used to delete all records from a table.

11/04/2023 Neeti Taneja DBMS Unit-1 64


Data Control Language (DCL)

• DCL stands for Data Control Language. It is used to retrieve the


stored or saved data.
• The DCL execution is transactional. It also has rollback parameters.
(But in Oracle database, the execution of data control language does
not have the feature of rolling back.)

• Here are some tasks that come under DCL:


– Grant: It is used to give user access privileges to a database.
– Revoke: It is used to take back permissions from the user.
There are the following operations which have the authorization of
Revoke:

• CONNECT, INSERT, EXECUTE, DELETE, UPDATE and SELECT.

11/04/2023 Neeti Taneja DBMS Unit-1 65


Transaction Control Language (TCL)

• TCL is used to run the changes made by the DML statement. TCL can
be grouped into a logical transaction.

• Here are some tasks that come under TCL:


– Commit: It is used to save the transaction on the database.
– Rollback: It is used to restore the database to original since the
last Commit.

11/04/2023 Neeti Taneja DBMS Unit-1 66


Database Users
 End Users: These are:
1) Casual Users: These are the users who communicate with the database
for little period of time. They are occasionally using the database. So
these are the temporary users.
2) Parametric Or Naive Users: These are the users who communicate with
the database for a regular period. Their main job is to constantly querying
and updating the database using standard queries.
3) Sophisticated End Users: These are engineers, scientists, business
analysts who are familiar with the database and when they want to use
the database, they use it regularly and when they don’t want then they
are temporarily using .
4) Stand alone users: These are the users who maintain their personal
database using ready made software which is available in the market
easily and provide the menu based interface through which they can
easily use the database.

11/04/2023 Neeti Taneja DBMS Unit-1 67


Database Administrator

• Coordinates all the activities of the database system


– has a good understanding of the enterprise’s information
resources and needs.
• Database administrator's duties include:
– Storage structure and access method definition
– Schema and physical organization modification
– Granting users authority to access the database
– Backing up data
– Monitoring performance and responding to changes
• Database tuning

11/04/2023 Neeti Taneja DBMS Unit-1 68


Data storage and Querying

• The database system is divided into three components


– Storage management
– Query processing
– Transaction processing

11/04/2023 Neeti Taneja DBMS Unit-1 69


Storage Management

They provide the interface between the low-level data stored in the database
and application programs and queries submitted to the system.

• Authorization and Integrity Manager : It tests for the satisfaction of


integrity constraints checks the authority of users to access data.

• Transaction Manager : It ensures that the database remains in a


consistent state despite the system failures and that concurrent
transaction execution proceeds without conflicting.

• File Manager : It manages the allocation of space on disk storage and


the data structures used to represent information stored on disk.

• Buffer Manager : It is responsible for fetching data from disk storage into
main memory and deciding what data to cache in memory.

11/04/2023 Neeti Taneja DBMS Unit-1 70


Query Processing

1. Parsing and translation


2. Optimization
3. Evaluation

11/04/2023 Neeti Taneja DBMS Unit-1 71


Query Processing (Cont.)

• Alternative ways of evaluating a given query


– Equivalent expressions
– Different algorithms for each operation
• Cost difference between a good and a bad way of evaluating a
query can be enormous
• Need to estimate the cost of operations
– Depends critically on statistical information about relations
which the database must maintain
– Need to estimate statistics for intermediate results to compute
cost of complex expressions

11/04/2023 Neeti Taneja DBMS Unit-1 72


Transaction Management

• A transaction is a collection of operations that performs a single


logical function in a database application
• Transaction-management component ensures that the database
remains in a consistent (correct) state despite system failures (e.g.,
power failures and operating system crashes) and transaction
failures.
• Concurrency-control manager controls the interaction among the
concurrent transactions, to ensure the consistency of the database.

11/04/2023 Neeti Taneja DBMS Unit-1 73


Topic – Data models Objective

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.

3. Data Models are used to show how data is stored, connected,


accessed and updated in the database management system.

11/04/2023 Neeti Taneja DBMS Unit-1 74


Data Models

• A data model is a collection of concepts for describing data.

• Categories of Data Models :-


– High level or Conceptual Data Model
• Concept of entities, attributes and relationships
– Low level or physical Data Model
• Details of how data is stored in computer
– Representational Data Model
• Traditional commercial DBMS so called legacy data models-
network or hierarchical models.

11/04/2023 Neeti Taneja DBMS Unit-1 75


Data Models

A collection of tools for describing


Data
Data relationships
Data semantics
Data constraints
Relational model
Entity-Relationship data model (mainly for database design)
Object-based data models (Object-oriented and Object-relational)
Semi structured data model (XML)
Other older models:
Network model
Hierarchical model

11/04/2023 Neeti Taneja DBMS Unit-1 76


Data Models

A collection of tools for describing


Data
Data relationships
Data semantics
Data constraints
Relational model
Entity-Relationship data model (mainly for database design)
Object-based data models (Object-oriented and Object-relational)
Semi structured data model (XML)
Other older models:
Network model
Hierarchical model

11/04/2023 Neeti Taneja DBMS Unit-1 77


1. Hierarchical Data Model
Hierarchical Model was the first DBMS model. This model
organizes the data in the hierarchical tree structure. The
hierarchy starts from the root which has root data and then it
expands in the form of a tree adding child node to the parent
node.
 Features of a Hierarchical Model
 One-to-many relationship: The data here is organized in a tree-like
structure where the one-to-many relationship is between the data types.
Also, there can be only one path from parent to any node.
 Parent-Child Relationship: Each child node has a parent node but a parent
node can have more than one child node. Multiple parents are not
allowed.
 Deletion Problem: If a parent node is deleted then the child node is
automatically deleted.
 Pointers: Pointers are used to link the parent node with the child node
and are used to navigate between the stored data.
11/04/2023 Neeti Taneja DBMS Unit-1 78
Example

11/04/2023 Neeti Taneja DBMS Unit-1 79


Continued
Example :- Company has its department, its suppliers, its employees,
different projects of the company etc are the different entities we need to
take care of. If we observe each of the entity they have parent –child
relationship.

In above example , Company is the parent and rests of them are its
children. Department has employees and projects as its children and so
on. This type of data modeling is called hierarchical data model.
One company has multiple departments (1:N), one company has multiple
suppliers (1:N),one department has multiple employees (1:N), each
department has multiple projects(1:N)

Complexity in Hierarchal diagram:-If we have M:N relationships, then we


have to duplicate the entities and show it in the diagram. For example, if a
project in the company involves multiple departments, then our
hierarchical representation changes as below:-
11/04/2023 Neeti Taneja DBMS Unit-1 80
Continued

11/04/2023 Neeti Taneja DBMS Unit-1 81


1. Hierarchical Data Model
Major problem in Hierarchical Model

Redundancy: – When data is stored in a flat file, there might be repetition


of same data multiple times and any changes required for the data will
need to change in all the places in the flat file. Missing to update at any
one place will cause incorrect data. This kind redundancy is solved by
hierarchical model to some extent. (1:M)

Since records are grouped under related table, it solves the flat file
redundancy issue. But look at the many to many relationship examples
given above. In such case, we have to store same project information for
more than one department. This is duplication of data and hence a
redundancy. So, this model does not reduce the redundancy issue to a
significant level.(M:M)

11/04/2023 Neeti Taneja DBMS Unit-1 82


1. Hierarchical Data Model
Advantages of Hierarchical Model
 It is very simple and fast to traverse through a tree-like structure.
 It helps to address the issues of flat file data storage. In flat files, data will
be scattered and there will not be any proper structuring of the data. This
model groups the related data into tables and defines the relationship
between the tables, which is not addressed in flat files.
 Any change in the parent node is automatically reflected in the child node
so, the integrity of data is maintained.
Disadvantages of Hierarchical Model
 Redundancy
 Complex relationships are not supported.
 As it does not support more than one parent of the child node so if we
have some complex relationship where a child node needs to have two
parent node then that can't be represented using this model.
 If a parent node is deleted then the child node is automatically deleted.

11/04/2023 Neeti Taneja DBMS Unit-1 83


2. Network Model

This is the enhanced version of hierarchical data model. It is designed to


address the drawbacks of the hierarchical model. It helps to address M:N
relationship. This data model is also represented as hierarchical, but this
model will not have single parent concept. Any child in the tree can have
multiple parents here. It was the most popular model before the relational
model.
Features of a Network Model
 Ability to Merge more Relationships: In this model, as there are more
relationships so data is more related. This model has the ability to manage
one-to-one relationships as well as many-to-many relationships.
 Many paths: As there are more relationships so there can be more than
one path to the same record. This makes data access fast and simple.
 Circular Linked List: The operations on the network model are done with
the help of the circular linked list. The current position is maintained with
the help of a program and this position navigates through the records
according to the relationship.
11/04/2023 Neeti Taneja DBMS Unit-1 84
Example

11/04/2023 Neeti Taneja DBMS Unit-1 85


2. Network Data Model

Let us revisit our company example. A company has different projects and
departments in the company own those projects. Even suppliers of the
company give input for the project.

Here Project has multiple parents and each department and supplier have
multiple projects.

11/04/2023 Neeti Taneja DBMS Unit-1 86


2. Network Data Model
Advantages of Network Model
 The data can be accessed faster as compared to the
hierarchical model. This is because the data is more related in
the network model and there can be more than one path to
reach a particular node. So the data can be accessed in many
ways.
 As there is a parent-child relationship so data integrity is
present. Any change in parent record is reflected in the child
record.

11/04/2023 Neeti Taneja DBMS Unit-1 87


Continued

Disadvantages of Network Model


 As more and more relationships need to be handled the
system might get complex. So, a user must be having detailed
knowledge of the model to work with.
 If there is any requirement for the changes to the entities, it
requires entire changes to the database. There is no
independence between any objects. Hence any changes to
any of the object will need changes to the whole model.
Hence difficult to manage.
 It would be little difficult to design the relationship between
the entities, since all the entities are related in some way. It
requires thorough practice and knowledge about the
designing.
11/04/2023 Neeti Taneja DBMS Unit-1 88
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. Which command is used to remove a relation from an SQL?


a) Drop table
b) Delete
c) Purge
d) Remove

11/04/2023 Neeti Taneja DBMS Unit-1 89


Topic- Relational Model and SQL Objective

1. The purpose of the relational model is to provide a declarative method


for specifying data and queries: users directly state what information
the database contains and what information they want from it.

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.

4. Understand the structure and design of relational databases.


Understand the importance and major issues of database security and
the maintenance of data integrity.

11/04/2023 Dr Kumud Saxena


Neeti Taneja ACSAI-0402
DBMS and DBMS
Unit-1 Unit-1 90
Relational Model

• Example of tabular data in the relational model


Attributes

Neeti Taneja DBMS Unit-1


11/04/2023 91
A Sample Relational Database

11/04/2023 Neeti Taneja DBMS Unit-1 92


SQL

• SQL: widely used non-procedural language


– Example: Find the name of the customer with customer-id 192-
83-7465
select customer.customer_name
from customer
where customer.customer_id = ‘192-83-7465’
– Example: Find the balances of all accounts held by the customer
with customer-id 192-83-7465
select account.balance
from depositor, account
where depositor.customer_id = ‘192-83-7465’ and
depositor.account_number =
account.account_number

11/04/2023 Neeti Taneja DBMS Unit-1 93


SQL

• Application programs generally access databases through one of


– Language extensions to allow embedded SQL
– Application program interface (e.g., ODBC/JDBC) which allow
SQL queries to be sent to a database

11/04/2023 Neeti Taneja DBMS Unit-1 94


Database Architecture (CO1)

The architecture of a database systems is greatly influenced by the


underlying computer system on which the database is running:
Centralized
Client-server
Parallel (multiple processors and disks)
Distributed

11/04/2023 Neeti Taneja DBMS Unit-1 95


Overall System Structure

11/04/2023 Neeti Taneja DBMS Unit-1 96


Database Application Architectures

11/04/2023 Neeti Taneja DBMS Unit-1 97


Database Design (CO1)

• Conceptual design: (ER Model is used at this stage.)


– What are the entities and relationships in the enterprise?
– What information about these entities and relationships should
we store in the database?
– What are the integrity constraints or business rules that hold?
– A database `schema’ in the ER Model can be represented
pictorially (ER diagrams).
– Can map an ER diagram into a relational schema.

11/04/2023 Neeti Taneja DBMS Unit-1 98


Short Quiz

1. After groups have been established, SQL applies predicates in the


___________ clause, allowing aggregate functions to be used.
a) Where
b) Having
c) Group by
d) With

2. Why the following statement is erroneous?

SELECT dept_name, ID, avg (salary) FROM instructor GROUP BY


dept_name;

a) Dept_id should not be used in group by clause


b) Group by clause is not valid in this query
c) Avg(salary) should not be selected
d) None

11/04/2023 Neeti Taneja DBMS Unit-1 99


Topic- ER Model Objective

1. An entity relationship diagram gives a snapshot of how these


entities relate to each other. You could call it the blueprint that
underpins your business architecture, offering a visual
representation of the relationships between different sets of data
(entities).

2. An Entity Relationship (ER) Diagram is a type of flowchart


that illustrates how “entities” such as people, objects or concepts
relate to each other within a system.

11/04/2023 Neeti Taneja DBMS Unit-1 100


Introduction of ER Model

• A database can be modeled as:


– a collection of entities,
– relationship among entities.
• An entity is an object that exists and is distinguishable from other
objects.

– Example: specific person, company, event, plant


• Entities have attributes
– Example: people have names and addresses

• 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

11/04/2023 Neeti Taneja DBMS Unit-1 101


Entity Sets customer and loan

customer_id customer_ customer_ customer_ loan_


amount
name street city number

11/04/2023 Neeti Taneja DBMS Unit-1 102


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 )

• In ER diagram, attribute is represented by an oval.

• Domain – the set of permitted values for each attribute

11/04/2023 Neeti Taneja DBMS Unit-1 103


Attribute Type

• Key Attribute – The attribute which uniquely identifies each entity


in the entity set is called key attribute. For example, Roll_No will be
unique for each student. In ER diagram, key attribute is represented
by an oval with underlying lines.

• Composite Attribute – An attribute composed of many other


attribute is called as composite attribute. For example, Address
attribute of student Entity type consists of Street, City, State, and
Country. In ER diagram, composite attribute is represented by an
oval comprising of ovals.

11/04/2023 Neeti Taneja DBMS Unit-1 104


Attribute Type

• Multivalued Attribute – An attribute consisting more than one


value for a given entity. For example, Phone_No (can be more than
one for a given student). In ER diagram, multivalued attribute is
represented by double oval.

• Derived Attribute – An attribute which can be derived from other


attributes of the entity type is known as derived attribute. e.g.; Age
(can be derived from DOB). In ER diagram, derived attribute is
represented by dashed oval.

11/04/2023 Neeti Taneja DBMS Unit-1 105


Attribute Type

• The complete entity type Student with its attributes can be


represented as:

11/04/2023 Neeti Taneja DBMS Unit-1 106


Relationship Type

• A relationship type represents the association between entity types.

• For example, ‘Enrolled in’ is a relationship type that exists between


entity type Student and Course.

• In ER diagram, relationship type is represented by a diamond and


connecting the entities with lines.

11/04/2023 Neeti Taneja DBMS Unit-1 107


Relationship Set

• A set of relationships of same type is known as relationship set.

• The following relationship set depicts S1 is enrolled in C2, S2 is


enrolled in C1 and S3 is enrolled in C3.

11/04/2023 Neeti Taneja DBMS Unit-1 108


Degree of Relationship Set

• The number of different entity sets participating in a relationship


set is called as degree of a relationship set.

– Unary Relationship
– Binary Relationship
– n-ary Relationship

11/04/2023 Neeti Taneja DBMS Unit-1 109


Unary Relationship

• When there is only ONE entity set participating in a relation, the


relationship is called as unary relationship.

• For example, one person is married to only one person.

11/04/2023 Neeti Taneja DBMS Unit-1 110


Binary Relationship

• When there are TWO entities set participating in a relation, the


relationship is called as binary relationship.

• For example, Student is enrolled in Course.

11/04/2023 Neeti Taneja DBMS Unit-1 111


n-ary Relationship

• When there are n entities set participating in a relation, the


relationship is called as n-ary relationship.

11/04/2023 Neeti Taneja DBMS Unit-1 112


Mapping Cardinality

• The number of times an entity of an entity set participates in a


relationship set is known as cardinality.

• Cardinality can be of different types:


– One to one
– One to many
– Many to one
– Many to many

11/04/2023 Neeti Taneja DBMS Unit-1 113


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.

• Using Sets, it can be represented as:

11/04/2023 Neeti Taneja DBMS Unit-1 114


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

• Using Sets, it can be represented as:

11/04/2023 Neeti Taneja DBMS Unit-1 115


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.

• Using sets, it can be represented as:

11/04/2023 Neeti Taneja DBMS Unit-1 116


Participation Constraint

• Total Participation – Each entity in the entity set must participate in


the relationship. If each student must enroll in a course, the
participation of student will be total. Total participation is shown by
double line in ER diagram.
• Partial Participation – The entity in the entity set may or may NOT
participate in the relationship. If some courses are not enrolled by
any of the student, the participation of course will be partial.

11/04/2023 Neeti Taneja DBMS Unit-1 117


Participation Constraint (contd..)

• Using set, it can be represented as

• Every student in Student Entity set is participating in relationship


but there exists a course C4 which is not taking part in the
relationship.
11/04/2023 Neeti Taneja DBMS Unit-1 118
Partial Participation: Example

11/04/2023 Neeti Taneja DBMS Unit-1 119


Weak and strong Entity
• An entity type should have a key attribute which uniquely identifies each entity in the
entity set, but there exists some entity type for which key attribute can’t be defined.
These are called Weak Entity type.
• The entity sets which do not have sufficient attributes to form a primary key are known
as weak entity sets and the entity sets which have a primary key are known as strong
entity sets.
• As the weak entities do not have any primary key, they cannot be identified on their
own, so they depend on some other entity (known as owner entity). The weak entities
have total participation constraints(existence dependency) in its identifying relationship
with owner entity.
• Weak entity types have partial keys. Partial Keys are set of attributes with the help of
which the tuples of the weak entities can be distinguished and identified.
• Note – Weak entity always has total participation but Strong entity may not have total
participation.

11/04/2023 Neeti Taneja DBMS Unit-1 120


Weak and Strong Entity(Cont.)
Weak entity depends on strong entity to ensure the existence of weak
entity. Like strong entity, weak entity does not have any primary key, It has
partial discriminator key. Weak entity is represented by double rectangle.
The relation between one strong and one weak entity is represented by
double diamond.

11/04/2023 Neeti Taneja DBMS Unit-1 121


Weak Entity set

In the below ER Diagram, ‘Payment’ is the weak entity. ‘Loan Payment’ is


the identifying relationship and ‘Payment Number’ is the partial key.
Primary Key of the Loan along with the partial key would be used to
identify the records.

11/04/2023 Neeti Taneja DBMS Unit-1 122


Weak Entity Type & Identifying Relationship

• A weak entity type is represented by a double rectangle. The


participation of weak entity type is always total. The relationship
between weak entity type and its identifying strong entity type is
called identifying relationship and it is represented by double
diamond.

11/04/2023 Neeti Taneja DBMS Unit-1 123


Keys
• Values in a column (or columns) of a relation are unique: at
most one row in a relation instance can contain a particular
value(s)

• Key - set of attributes satisfying key constraint


– e.g., Id in Student,
– e.g., (StudId,, CrsCode,Semester) in Transcript
• Super Key
Super Key is defined as a set of attributes within a table that
uniquely identifies each record within a table. Super Key is a
superset of Candidate key.

11/04/2023 Neeti Taneja DBMS Unit-1 124


Keys(Cont.)
• Candidate Key
Candidate keys are defined as the set of fields from which primary key can be selected. It is an
attribute or set of attribute that can act as a primary key for a table to uniquely identify each
record in that table.
• Primary Key
Primary key is a candidate key that is most appropriate to become main key of the table. It is a
key that uniquely identify each record in a table. PK must be unique and Not Null.
• Foreign Key
Foreign Key is a field or set of fields that are identical to a primary key in another table.

Here,
• One student can enroll in at most one course.
• One course can be enrolled by at most one student.
11/04/2023 Neeti Taneja DBMS Unit-1 125
Keys Example

Primary Key
Customers

11/04/2023 Neeti Taneja DBMS Unit-1 126


Keys Example(Cont.)

11/04/2023 Neeti Taneja DBMS Unit-1 127


Keys in DBMS

• KEYS in DBMS is an attribute or set of attributes which helps you to


identify a row(tuple) in a relation(table).
• They allow you to find the relation between two tables.
• Keys help you uniquely identify a row in a table by a combination of
one or more columns in that table.
Example:-
Employee ID FirstName LastName
11 Andrew Johnson
22 Tom Wood
33 Alex Hale
• In the above-given example, employee ID is a primary key because
it uniquely identifies an employee record. In this table, no other
employee can have the same employee ID.

11/04/2023 Neeti Taneja DBMS Unit-1 128


Why we need a Key?

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.

11/04/2023 Neeti Taneja DBMS Unit-1 129


Types of Keys in DBMS

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.

11/04/2023 Neeti Taneja DBMS Unit-1 130


Types of Keys in DBMS (contd..)

– 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.
– 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.
– Composite Key – is a combination of two or more columns that
uniquely identify rows in a table. The combination of columns
guarantees uniqueness, though individual uniqueness is not
guaranteed.
– Surrogate Key – An artificial key which aims to uniquely identify
each record is called a surrogate key. These kind of key are
unique because they are created when you don’t have any
natural primary key.
11/04/2023 Neeti Taneja DBMS Unit-1 131
Super key

• A superkey is a group of single or multiple keys which identifies


rows in a table. A Super key may have additional attributes that are
not needed for unique identification.
Example:
EmpSSN EmpNum Empname
9812345098 AB05 Shown
9876512345 AB06 Roslyn
199937890 AB07 James

• In the above-given example, EmpSSN and EmpNum name are


superkeys.

11/04/2023 Neeti Taneja DBMS Unit-1 132


Primary Key

• PRIMARY KEY in DBMS is a column or group of columns in a table


that uniquely identify every row in that table. The Primary Key can’t
be a duplicate meaning the same value can’t appear more than
once in the table. A table cannot have more than one primary key.
Example:
StudID Roll No First Name LastName Email
1 11 Tom Price [email protected]
2 12 Nick Wright [email protected]
3 13 Dana Natan [email protected]

• In the following example, StudID is a Primary Key.

11/04/2023 Neeti Taneja DBMS Unit-1 133


Primary Key (contd..)

Rules for defining Primary key:


• Two rows can’t have the same primary key value
• It must for every row to have a primary key value.
• The primary key field cannot be null.
• The value in a primary key column can never be modified or
updated if any foreign key refers to that primary key.

11/04/2023 Neeti Taneja DBMS Unit-1 134


Alternate key

• ALTERNATE KEYS is a column or group of columns in a table that


uniquely identify every row in that table. A table can have multiple
choices for a primary key but only one can be set as the primary
key. All the keys which are not primary key are called an Alternate
Key.
Example:
StudID Roll No First Name LastName Email
1 11 Tom Price [email protected]
2 12 Nick Wright [email protected]
3 13 Dana Natan [email protected]
• In this table, StudID, Roll No, Email are qualified to become a
primary key. But since StudID is the primary key, Roll No, Email
becomes the alternate keys.

11/04/2023 Neeti Taneja DBMS Unit-1 135


Candidate Key

• CANDIDATE KEY in SQL is a set of attributes that uniquely identify


tuples in a table. Candidate Key is a super key with no repeated
attributes. The Primary key should be selected from the candidate
keys. Every table must have at least a single candidate key. A table
can have multiple candidate keys but only a single primary key.
Example:
StudID Roll No First Name LastName Email
1 11 Tom Price [email protected]
2 12 Nick Wright [email protected]
3 13 Dana Natan [email protected]

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

11/04/2023 Neeti Taneja DBMS Unit-1 136


Candidate Key (contd..)

Properties of Candidate key:


• It must contain unique values
• Candidate key in SQL may have multiple attributes
• Must not contain null values
• It should contain minimum fields to ensure uniqueness
• Uniquely identify each record in a table

11/04/2023 Neeti Taneja DBMS Unit-1 137


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

Teacher ID Fname Lname


B002 David Warner
B017 Sara Joseph
B009 Mike Brunton
11/04/2023 Neeti Taneja DBMS Unit-1 138
Foreign key (contd..)

• In this example, we have two tables, teacher and department in a


school. However, there is no way to see which teacher work in
which department.

• In this table, adding the foreign key Deptcode to the Teacher, we


can create a relationship between the two tables.

Teacher ID DeptCode Fname Lname


B002 002 David Warner
B017 002 Sara Joseph
B009 001 Mike Brunton

• This concept is also known as Referential Integrity.

11/04/2023 Neeti Taneja DBMS Unit-1 139


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 ProductID 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

• In this example, OrderNo and ProductID can’t be a primary key as it


does not uniquely identify a record. However, a compound key of Order
No and Product ID could be used as it uniquely identifies each record.
11/04/2023 Neeti Taneja DBMS Unit-1 140
Composite key

• COMPOSITE KEY is a combination of two or more columns that


uniquely identify rows in a table. The combination of columns
guarantees uniqueness, though individually uniqueness is not
guaranteed. Hence, they are combined to uniquely identify records
in a table.

• The difference between compound and the composite key is that


any part of the compound key can be a foreign key, but the
composite key may or may not be a part of the foreign key.

11/04/2023 Neeti Taneja DBMS Unit-1 141


Difference b/w Primary key & Foreign key

Primary Key Foreign Key

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.

A foreign key may accept multiple null


Primary Key never accept null values.
values.

A foreign key cannot automatically create


Primary key is a clustered index and data
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.

11/04/2023 Neeti Taneja DBMS Unit-1 142


Short Quiz

Q. Given the basic ER and relational models, which of the following is


INCORRECT?
answer choices
1. An attribute of an entity can have more than one value.
2. An attribute of an entity can be composite.
3. In a row of a relational table, an attribute can have more than one
value.
4. In a row of a relational table, an attribute can have exactly one value
or a NULL value.

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
11/04/2023 Neeti Taneja DBMS Unit-1 143
Topic- Generalization, Specialization and
Aggregation Objective

1. Generalization of Entities helps in establishing relationships between the


tables, as they have common attributes to be identified. It makes the
structuring of the database management simpler and easy to identify all the
relevant attributes.

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.

3. Inheritance is an important feature of Generalization and Specialization.


It allows lower-level entities to inherit the attributes of higher-level entities.
For example, the attributes of a Person class such as name, age, and gender
can be inherited by lower-level entities such as Student or Teacher.
11/04/2023 Neeti Taneja DBMS Unit-1 144
Generalization
• Generalization is the process of extracting common properties from
a set of entities and create a generalized entity from it.

• It is a bottom-up approach in which two or more entities can be


generalized to a higher level entity if they have some attributes in
common.

• For Example, STUDENT and FACULTY can be generalized to a higher


level entity called PERSON as shown in Figure.

• In this case, common attributes like P_NAME, P_ADD become part


of higher entity (PERSON) and specialized attributes like S_FEE
become part of specialized entity (STUDENT).

11/04/2023 Neeti Taneja DBMS Unit-1 145


Example:

11/04/2023 Neeti Taneja DBMS Unit-1 146


Specialization

• In specialization, an entity is divided into sub-entities based on their


characteristics.

• It is a top-down approach where higher level entity is specialized


into two or more lower level entities.

• For Example, EMPLOYEE entity in an Employee management system


can be specialized into DEVELOPER, TESTER etc. as shown in Figure.

• In this case, common attributes like E_NAME, E_SAL etc. become


part of higher entity (EMPLOYEE) and specialized attributes like
TES_TYPE become part of specialized entity (TESTER).

11/04/2023 Neeti Taneja DBMS Unit-1 147


Example:

11/04/2023 Neeti Taneja DBMS Unit-1 148


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.

11/04/2023 Neeti Taneja DBMS Unit-1 149


Example:

11/04/2023 Neeti Taneja DBMS Unit-1 150


Topic –
Reduction of an ER diagrams to tables
Objectives

1. Mapping an Entity Relationship (ER) model gives a good overview of


the design of a system with the goal of making the system easier to
understand at a technical level.

2. The ER diagrams can be mapped to a relation schema, which means


we can clearly display the relationship between its members.

3. An Entity Relationship (ER) Diagram is a type of flowchart


that illustrates how “entities” such as people, objects or concepts
relate to each other within a system.

11/04/2023 Neeti Taneja DBMS Unit-1 151


Reduction of an ER diagrams to tables

Rule-01: For Strong Entity Set With Only Simple Attributes


• A strong entity set with only simple attributes will require only one
table in relational model.
– Attributes of the table will be the attributes of the entity set.
– The primary key of the table will be the key attribute of the
entity set.

Schema : Student ( Roll_no , Name , Sex )

11/04/2023 Neeti Taneja DBMS Unit-1 152


RULE-02

Rule-02: For Strong Entity Set With Composite Attributes


• A strong entity set with any number of composite attributes will
require only one table in relational model.
• While conversion, simple attributes of the composite attributes are
taken into account and not the composite attribute itself.

Schema : Student ( Roll_no , First_name , Last_name , House_no , Street , City )


11/04/2023 Neeti Taneja DBMS Unit-1 153
RULE-03
Rule-03: For Strong Entity Set With Multi Valued Attributes
• A strong entity set with any number of multi valued attributes will
require two tables in relational model.
– One table will contain all the simple attributes with the primary
key.
– Other table will contain the primary key and all the multi valued
attributes.

Roll_no City Roll_no Mobile_no

11/04/2023 Neeti Taneja DBMS Unit-1 154


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.

Schema : Works in ( Emp_no , Dept_id ,


since )
11/04/2023 Neeti Taneja DBMS Unit-1 155
RULE-05

Rule-05: For Binary Relationships With Cardinality Ratios

• The following four cases are possible-

– Case-01: Binary relationship with cardinality ratio m:n

– Case-02: Binary relationship with cardinality ratio 1:n

– Case-03: Binary relationship with cardinality ratio m:1

– Case-04: Binary relationship with cardinality ratio 1:1


11/04/2023 Neeti Taneja DBMS Unit-1 156
RULE-05 (contd..)

Case-01: For Binary Relationship With Cardinality Ratio m:n

• Here, three tables will be required-


1. A ( a1 , a2 )
2. R ( a1 , b1 )
3. B ( b1 , b2 )

11/04/2023 Neeti Taneja DBMS Unit-1 157


RULE-05 (contd..)

Case-02: For Binary Relationship With Cardinality Ratio 1:n

• Here, two tables will be required-


1. A ( a1 , a2 )
2. BR ( a1 , b1 , b2 )

NOTE- Here, combined table will be drawn for the entity set B and
relationship set R.
11/04/2023 Neeti Taneja DBMS Unit-1 158
RULE-05 (contd..)

Case-03: For Binary Relationship With Cardinality Ratio m:1

• Here, two tables will be required-


1. AR ( a1 , a2 , b1 )
2. B ( b1 , b2 )

NOTE- Here, combined table will be drawn for the entity set A and
relationship set R.

11/04/2023 Neeti Taneja DBMS Unit-1 159


RULE-05 (contd..)
Case-04: For Binary Relationship With Cardinality Ratio 1:1

• 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 )

11/04/2023 Neeti Taneja DBMS Unit-1 160


RULE-06

Rule-06: For Binary Relationship With Both Cardinality Constraints


and Participation Constraints-

• Case-01: For Binary Relationship With Cardinality Constraint and


Total Participation Constraint From One Side

• Case-02: For Binary Relationship With Cardinality Constraint and


Total Participation Constraint From Both Sides-

11/04/2023 Neeti Taneja DBMS Unit-1 161


RULE-06 (contd..)
Case-01: For Binary Relationship With Cardinality Constraint and
Total Participation Constraint From One Side

• Because cardinality ratio = 1 : n , so we will combine the entity set B


and relationship set R.
• Then, two tables will be required-
1. A ( a1 , a2 )
2. BR ( a1 , b1 , b2 )
• Because of total participation, foreign key a1 has acquired NOT
NULL constraint, so it can’t be null now.
11/04/2023 Neeti Taneja DBMS Unit-1 162
RULE-06 (contd..)

Case-02: For Binary Relationship With Cardinality Constraint and


Total Participation Constraint From Both Sides
• If there is a key constraint from both the sides of an entity set with
total participation, then that binary relationship is represented
using only single table.

• Here, Only one table is required.


1. ARB ( a1 , a2 , b1 , b2 )

11/04/2023 Neeti Taneja DBMS Unit-1 163


RULE-07

Rule-07: For Binary Relationship With Weak Entity Set


• Weak entity set always appears in association with identifying
relationship with total participation constraint.

• Here, two tables will be required-


1. A ( a1 , a2 )
2. BR ( a1 , b1 , b2 )

11/04/2023 Neeti Taneja DBMS Unit-1 164


Examples of ER Diagram

11/04/2023 Neeti Taneja DBMS Unit-1 165


ER Diagram For Department

11/04/2023 Neeti Taneja DBMS Unit-1 166


ER Diagram for Company

11/04/2023 Neeti Taneja DBMS Unit-1 167


Summary of Conceptual Design

• Conceptual design follows requirements analysis,


– Yields a high-level description of data to be stored
• ER model popular for conceptual design
– Constructs are expressive, close to the way people think about
their applications.
• Basic constructs: entities, relationships, and attributes (of entities
and relationships).
• Some additional constructs: weak entities, ISA hierarchies, and
aggregation.
• Note: There are many variations on ER model.

11/04/2023 Neeti Taneja DBMS Unit-1 168


Summary of ER (Contd.)

• ER design is subjective. There are often many ways to model a given


scenario! Analyzing alternatives can be tricky, especially for a large
enterprise. Common choices include:
– Entity vs. attribute, entity vs. relationship, binary or n-ary
relationship, whether or not to use ISA hierarchies, and whether
or not to use aggregation.
• Ensuring good database design: resulting relational schema should
be analyzed and refined further. FD information and normalization
techniques are especially useful.

11/04/2023 Neeti Taneja DBMS Unit-1 169


Daily Quiz

• Define Database System.


• What do you understand by data independence?
• Explain types of attributes in ER diagram.
• What is generalization.
• What do you understand by primary key?
• Explain participation cardinality.

11/04/2023 Neeti Taneja DBMS Unit-1 170


Weekly Assignment

• Define: Data, Database, and Database System.


• What is data independence? What are differences between Logical
Data Independence and Physical Data Independence?
• Give example of Simple, Composite, Single –valued and Multi-
valued attributes of an entity.
• What is the difference between Generalization & Specialization
with respect to Database?
• What is difference between total and partial participation? Explain
by suitable example.
• Construct an E-R diagram for a hospital with a set of patients and a
set of medical doctors. Associated with each patient, a log of the
various tests and examinations conducted.

11/04/2023 Neeti Taneja DBMS Unit-1 171


Topic Links

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/

11/04/2023 Neeti Taneja DBMS Unit-1 172


MCQ s

• The entity relationship set is represented in E-R diagram as


a) Double diamonds
b) Undivided rectangles
c) Dashed lines
d) Diamond

• The Rectangles divided into two parts represents


a) Entity set
b) Relationship set
c) Attributes of a relationship set
d) Primary key

11/04/2023 Neeti Taneja DBMS Unit-1 173


MCQ s

• An entity set that does not have sufficient attributes to form a


primary key is termed a __________
a) Strong entity set
b) Variant set
c) Weak entity set
d) Variable set

• What term is used to refer to a specific record in your music


database; for instance; information stored about a specific album?
a) Relation
b) Instance
c) Table
d) Column

11/04/2023 Neeti Taneja DBMS Unit-1 174


Glossary Questions

1. What are the features of Database language?


2. What do database languages do?
3. Define database model.
4. What is SQL?
5. Enlist the various relationships of database.
6. Define DDL and DML.
7. Enlist some commands of DDL.

11/04/2023 Neeti Taneja DBMS Unit-1 175


Old Question Papers

• 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

11/04/2023 Neeti Taneja DBMS Unit-1 176


Expected Questions for University Exam

• Explain types of attributes in ER diagram.


• Explain the difference between a weak and a strong entity set with
example.
• Discuss three level of abstractions or schemas architecture of
DBMS.
• Define constraint and its types in DBMS.
• Compare Generalization, Specialization and aggregation with
suitable examples.
• Draw overall structure of DBMS and explain its components in brief.
• Construct an E-R diagram for a hospital with a set of patients and a
set of medical doctors. Associated with each patient, a log of the
various tests and examinations conducted.

11/04/2023 Neeti Taneja DBMS Unit-1 177


Recap of Unit

• Knowledge of database architecture.

• Knowledge of Entity Relationship model and its concepts.

• Databse V/S File system.

11/04/2023 Neeti Taneja DBMS Unit-1 178


Thank You

11/04/2023 Neeti Taneja DBMS Unit-1 179

You might also like