DBMS_Unit_1
DBMS_Unit_1
Priyadarshini R,
Assistant Professor, NMIT.
Syllabus
UNIT -1- (8 Hrs.) Advantages of using DBMS approach; Data models, schemas and instances;
DBMS component module Three- schema architecture and data independence; Database
languages; Classification of Database Management systems Using High-Level Conceptual Data
Models for Database Design; An Example Database Application; Entity Types, Entity Sets,
Attributes and Keys; Relationship types, Relationship Sets, Roles and Structural Constraints;Weak
Entity Types; ER Diagrams, Naming Conventions and Design Issues; Relationship types of degree
higher than two.
UNIT -2- (9 Hrs.) Relational database design using ER to relational mapping; Relational Model
Concepts; Relational Model Constraints and Relational Database Schemas; Update Operations,
Transactions and dealing with constraint violations;Unary Relational Operations: SELECT and
PROJECT; Relational Algebra Operations from Set Theory; Binary Relational Operations: JOIN
and DIVISION; Additional Relational Operations; Examples of Queries in Relational Algebra;
2
Syllabus
UNIT -3- (7 Hrs.) Informal Design Guidelines for Relation Schemas; Functional Dependencies:
Definition of FD, Inference rules for FD; Normal Forms Based on Primary Keys; General Definitions of
Second and Third Normal Forms; Boyce-Codd Normal Form. Multi-valued Dependencies and Fourth
Normal Form ; Join Dependencies .
UNIT -4- (8 Hrs.) SQL Data Definition and Data Types; Specifying basic constraints in SQL; Schema
change statements in SQL;Basic queries in SQL; More complex SQL Queries .Insert, Delete and Update
statements in SQL; Specifying constraints as Assertion and Trigger; Views (Virtual Tables) in SQL .
UNIT -5- (7 Hrs.) Introduction to transaction processing: Transaction and system concepts; Desirable
Properties of transactions; Transactions and Schedules; Characterizing schedules based on recoverability;
Characterizing schedules based on Serializability; Concurrency Control Techniques: 2PL techniques for
concurrency control;
3
COURSE LEARNING OUTCOMES
4
Text Book and Reference Books
1. All Fundamentals of Database Systems Elmasri and Navathe McGraw-Hill 7th Edition, 2017 .
2. All Database Raghu McGraw-Hill 3rd Edition,2003
3. Database System Concepts Silberschatz, Korth and Sudharshan Mc- GrawHill 7th Edition,2019
5
COURSE ASSESSMENT METHOD:
6
Unit 1
Advantages of using DBMS approach; Data models, schemas and instances;
DBMS component module Three- schema architecture and data
independence; Database languages; Classification of Database Management
systems Using High-Level Conceptual Data Models for Database Design; An
Example Database Application; Entity Types, Entity Sets, Attributes and
Keys; Relationship types, Relationship Sets, Roles and Structural
Constraints;Weak Entity Types; ER Diagrams, Naming Conventions and
Design Issues; Relationship types of degree higher than two.
7
BASIC DEFINITIONS
● Data:
○ Known facts that can be recorded and have an implicit meaning.
● Database:
○ A collection of related data.
● Mini-world:
○ Some part of the real world about which data is stored in a database. For
example, student grades and transcripts at a university.
● Database Management System (DBMS):
○ A software package/ system to facilitate the creation and maintenance of a
computerized database.
● Database System:
○ The DBMS software together with the data itself. Sometimes, the applications
are also included.
SIMPLIFIED DATABASE SYSTEM ENVIRONMENT
TYPICAL DBMS FUNCTIONALITY
Define
Construct
● Retrieval
● Modification
● Accessing the database through Web applications
● Allowing a set of concurrent users to retrieve from and to update the database.
● Concurrency control
● Recovery
● OLTP (Online Transaction Processing)
DATABASE USERS
Users may be divided into
● Actors on the Scene- who control - Database administrators, End user
● Workers Behind the Scene- designer- Designers (Maintenance personal, System
Developer)
CATEGORIES OF END-USERS
ADVANTAGES OF USING THE DATABASE
APPROACH
● Data Redundancy Control - Centralizing data storage
● Data Integrity - Ensuring that data is accurate, consistent, and reliable
● Data Security - Access control and user authentication
● Concurrent Access - Access and manipulate data simultaneously
● Backup and Recovery
● Efficient Data Access - Optimized query processing techniques
● Data Independence - Changes in the storage structure do not affect the application
● Centralized Data Management
ADVANTAGES OF USING THE DATABASE
APPROACH (CONTINUED)
○ Web contains data in HTML (Hypertext markup language) with links among pages.
○ This has given rise to a new set of applications and E-commerce is using new
standards like XML (eXtended Markup Language). (see Ch. 27).
30
31
Types of Data Models
Key Types:
● Hierarchical Model
● Network Model
● Relational Model
● Object-Oriented Model
● Entity-Relationship Model (ER Model)
32
Hierarchical Data Model
Data is organized in a tree-like structure,
with a single root and child nodes.
○ Parent-child relationship
○ Each child can have only one
parent
○ Example: XML data
representation
● Pros:
○ Simple to understand and use
○ Fast access for hierarchical
queries
● Cons:
○ Limited flexibility for complex
relationships
33
Network Data Model
Data is represented using a graph, where entities are nodes and relationships are edges
34
Relational Data Model
Data is organized in tables (relations), where each table has rows (tuples) and
columns (attributes).
● Key Points:
○ Each table represents an entity type
○ Uses Primary Keys to uniquely identify rows
○ Foreign Keys represent relationships between tables
● Pros:
○ Simple and intuitive
○ Easily scalable and flexible
○ Supports SQL for querying
● Cons:
○ Can become inefficient with
very large datasets
35
Object-Oriented Data Model
Data is represented as objects, similar to object-oriented programming.
36
Entity-Relationship (ER) Model
The ER model is a high-level conceptual framework for database design, focusing
on entities and their relationships.
○ Entities represent objects or concepts (e.g., Student, Course)
○ Relationships represent how entities are related (e.g., enrolls in)
○ Attributes define properties of entities (e.g., name, age)
● Pros:
○ Easy to understand and visually represent
○ Ideal for database design
● Cons:
○ Does not directly implement database functionality
37
ERD:
38
SCHEMAS VERSUS INSTANCES
A schema is the logical structure or design of a database.
It defines how the data is organized, including tables, relationships, and constraints,
without holding any actual data.
○ Represents the blueprint or framework for the database.
○ Describes tables, fields, relationships, and constraints (primary keys, foreign
keys).
○ Typically does not change frequently.
● Example: The schema might define a "Student" table with fields like Student_ID,
Name, DOB, and Grade.
SCHEMAS VERSUS INSTANCES
Types of Schemas
Physical Schema:
○ Describes the physical storage of data in the database, including how data is stored on the
hardware (e.g., storage devices, indexing, file structures).
○ Concerned with performance optimization and storage allocation.
Logical Schema:
○ Describes the logical view of the entire database, focusing on what data is stored and how it
is organized (tables, relationships, constraints).
○ It does not consider physical storage.
View Schema:
An instance refers to the actual data stored in the database at any given moment.
It is a snapshot of the data that adheres to the schema structure.
41
Relationship Between Schema and
Instance
42
Schema vs Instance – Example
Schema Example:
● Student Table:
○ Columns: Student_ID, Name, Age, Department
○ Constraints: Student_ID is a primary key.
Instance Example:
43
DATABASE SCHEMA VS. DATABASE STATE
Database State:
● Refers to the content of a database at a moment in time.
Initial Database State:
● Refers to the database state when it is initially loaded into the system.
Valid State:
● A state that satisfies the structure and constraints of the database.
Distinction:
● The database schema does not change frequently.
● The database state changes every time the database is updated.
EXAMPLE OF A DATABASE SCHEMA
EXAMPLE OF A DATABASE STATE
THREE-SCHEMA ARCHITECTURE
● Proposed to support DBMS characteristics of:
○ Program-data independence.
○ Support of multiple views of the data.
● Not explicitly used in commercial DBMS products, but has been useful in
explaining database system organization
THREE-SCHEMA ARCHITECTURE
Defines DBMS schemas at three levels:
● Internal schema at the internal level to describe physical storage structures and access
paths (e.g indexes).
○ Typically uses a physical data model.
● Conceptual schema at the conceptual level to describe the structure and constraints for
the whole database for a community of users.
○ Uses a conceptual or an implementation data model.
● External schemas at the external level to describe the various user views.
○ Usually uses the same data model as the conceptual schema.
THE THREE-SCHEMA ARCHITECTURE
THREE-SCHEMA ARCHITECTURE
● Mappings among schema levels are needed to transform requests and
data.
○ Programs refer to an external schema, and are mapped by the
DBMS to the internal schema for execution.
○ Data extracted from the internal DBMS level is reformatted to
match the user’s external view (e.g. formatting the results of an
SQL query for display in a Web page)
DATA INDEPENDENCE
● Logical Data Independence:
○ The capacity to change the conceptual schema without having to change the
external schemas and their associated application programs.
● Physical Data Independence:
○ The capacity to change the internal schema without having to change the
conceptual schema.
○ For example, the internal schema may be changed when certain file
structures are reorganized or new indexes are created to improve database
performance
DATA INDEPENDENCE (CONTINUED)
● When a schema at a lower level is changed, only the mappings between this schema
and higher-level schemas need to be changed in a DBMS that fully supports data
independence.
● The higher-level schemas themselves are unchanged.
● Hence, the application programs need not be changed since they refer to the external
schemas.
DBMS LANGUAGES
● Data Definition Language (DDL)
- CREATE, ALTER, DROP, TRUNCATE, RENAME
● Centralized DBMS:
○ Combines everything into single system including- DBMS
software, hardware, application programs, and user interface
processing software.
○ User can still connect through a remote terminal – however, all
processing is done at centralized site.
A PHYSICAL CENTRALIZED ARCHITECTURE
BASIC 2-TIER CLIENT-SERVER ARCHITECTURES
● Specialized Servers with Specialized functions
○ Print server
○ File server
○ DBMS server
○ Web server
○ Email server
● Clients can access the specialized servers as needed
LOGICAL TWO-TIER CLIENT SERVER
ARCHITECTURE
TWO TIER CLIENT-SERVER ARCHITECTURE
● A client program may connect to several DBMSs, sometimes called the
data sources.
● In general, data sources can be files or other non-DBMS software that
manages data.
● Other variations of clients are possible: e.g., in some object DBMSs,
more functionality is transferred to clients including data dictionary
functions, optimization and recovery across multiple servers, etc.
THREE TIER CLIENT-SERVER ARCHITECTURE
● Common for Web applications
● Intermediate Layer called Application Server or Web Server:
○ Stores the web connectivity software and the business logic part of
the application used to access the corresponding data from the
database server
○ Acts like a conduit for sending partially processed data between the
database server and the client.
● Three-tier Architecture Can Enhance Security:
○ Database server only accessible via middle tier
○ Clients cannot directly access database server
THREE-TIER CLIENT-SERVER ARCHITECTURE
CLASSIFICATION OF DBMSS
● Based on the data model used
○ Traditional: Relational, Network, Hierarchical.
○ Emerging: Object-oriented, Object-relational.
● Other classifications
○ Single-user (typically used with personal computers)
vs. multi-user (most DBMSs).
○ Centralized (uses a single computer with one database)
vs. distributed (uses multiple computers, multiple databases)
VARIATIONS OF DISTRIBUTED DBMS (DDBMS)
82
Attributes
83
Types of attribute:
1. Simple : A simple attribute is an attribute that cannot be divided into smaller sub-parts.
It's atomic and represents a single value.
Example: Age, Gender, Date of Birth, Student_ID (these cannot be divided further
into meaningful subparts).
2. Composite Attribute: A composite attribute can be divided into smaller sub-attributes,
each of which has its own meaning.
Example: Name is a composite attribute because it can be divided into:
○ First Name
○ Last Name
○ Middle Name (if applicable)
84
Contd.,
85
TYPES OF ATTRIBUTES (1)
● Simple
● Derived
● Key
○ Each entity has a single atomic value for the attribute. For example, SSN or gender.
● Composite
○ The attribute may be composed of several components. For example:
■ Address(Apt#, House#, Street, City, State, ZipCode, Country), or
■ Name(FirstName, MiddleName, LastName).
■ Composition may form a hierarchy where some components are themselves composite.
● Multi-valued
○ An entity may have multiple values for that attribute. For example, Color of a CAR or
PreviousDegrees of a STUDENT.
■ Denoted as {Color} or {PreviousDegrees}
TYPES OF ATTRIBUTES (2)
● In general, composite and multi-valued attributes may be nested arbitrarily to any
number of levels, although this is rare.
○ For example, PreviousDegrees of a STUDENT is a composite multi-valued
attribute denoted by {PreviousDegrees (College, Year, Degree, Field)}
○ Multiple PreviousDegrees values can exist
○ Each has four subcomponent attributes:
■ College, Year, Degree, Field
EXAMPLE OF A COMPOSITE
ATTRIBUTE
ENTITY TYPES AND KEY ATTRIBUTES (1)
● Entities with the same basic attributes are grouped or typed into an entity type.
○ For example, the entity type EMPLOYEE and PROJECT.
● An attribute of an entity type for which each entity must have a unique value is called a key
attribute of the entity type.
○ For example, SSN of EMPLOYEE.
● A key attribute may be composite.
○ VehicleTagNumber is a key of the CAR entity type with components (Number, State).
● An entity type may have more than one key.
○ The CAR entity type may have two keys:
■ VehicleIdentificationNumber (popularly called VIN)
■ VehicleTagNumber (Number, State), aka license plate number.
● Each key is underlined
DISPLAYING AN ENTITY TYPE
● In ER diagrams, an entity type is displayed in a rectangular box
● Attributes are displayed in ovals
○ Each attribute is connected to its entity type
○ Components of a composite attribute are connected to the oval representing the
composite attribute
○ Each key attribute is underlined
○ Multivalued attributes displayed in double ovals
ENTITY TYPE CAR WITH TWO KEYS AND A CORRESPONDING ENTITY SET
ENTITY SET
● Each entity type will have a collection of entities stored in the database
○ Entity set
● Previous slide shows three CAR entity instances in the entity set for CAR
● Same name (CAR) used to refer to both the entity type and the entity set
● Entity set is the current state of the entities of that type that are stored in the
database
INITIAL DESIGN OF ENTITY TYPES FOR THE COMPANY
DATABASE SCHEMA
● Based on the requirements, we can identify four initial entity types in the COMPANY
database:
○ DEPARTMENT
○ PROJECT
○ EMPLOYEE
○ DEPENDENT
● Their initial design is shown on the following slide
● The initial attributes shown are derived from the requirements description
INITIAL DESIGN OF ENTITY TYPES:
EMPLOYEE, DEPARTMENT, PROJECT, DEPENDENT
REFINING THE INITIAL DESIGN BY INTRODUCING
RELATIONSHIPS
● The initial design is typically not complete
● Some aspects in the requirements will be represented as relationships
● ER model has three main concepts:
○ Entities (and their entity types and entity sets)
○ Attributes (simple, composite, multivalued)
○ Relationships (and their relationship types and relationship sets)
RELATIONSHIPS AND RELATIONSHIP TYPES (1)
✔ A relationship relates two or more distinct entities with a specific meaning.
✔ For example, EMPLOYEE John Smith works on the ProductX PROJECT, or
EMPLOYEE Franklin Wong manages the Research DEPARTMENT.
✔ Relationships of the same type are grouped or typed into a relationship type.
✔ For example, the WORKS_ON relationship type in which EMPLOYEEs and
PROJECTs participate, or the MANAGES relationship type in which EMPLOYEEs and
DEPARTMENTs participate.
✔ The degree of a relationship type is the number of participating entity types.
✔ Both MANAGES and WORKS_ON are binary relationships.
RELATIONSHIP INSTANCES OF THE WORKS_FOR N:1 RELATIONSHIP BETWEEN
EMPLOYEE AND DEPARTMENT
RELATIONSHIP INSTANCES OF THE M:N WORKS_ON
RELATIONSHIP BETWEEN EMPLOYEE AND PROJECT
RELATIONSHIP TYPE VS. RELATIONSHIP SET (1)
● Relationship Type:
○ Is the schema description of a relationship
○ Identifies the relationship name and the participating entity types
○ Also identifies certain relationship constraints
● Relationship Set:
○ The current set of relationship instances represented in the database
○ The current state of a relationship type
● Previous figures displayed the relationship sets
● Each instance in the set relates individual participating entities – one from each participating entity
type
● In ER diagrams, we represent the relationship type as follows:
○ Diamond-shaped box is used to display a relationship type
○ Connected to the participating entity types via straight lines
Using High-Level Conceptual Data Models for
Database Design
● Early stages of database design - information requirements of a system without
getting into the technical details of implementation.
● These models provide a more abstract representation of how data is structured and
related.
● High-level conceptual data model can be used to design a database that will later be
converted into a logical and physical model.
● Example: Entity-Relationship (ER) Models, Unified Modeling Language (UML),
and Object-Oriented Models.
100
Steps in Using High-Level Conceptual Data
Models for Database Design
● Requirement Analysis
● Identify Entities
● Define Relationships
● Define Primary Keys
● Add Constraints
101
An Example Database Application: Online Bookstore
Identify Entities:
● Book: Represents a book in the store.
○ Attributes: BookID (Primary Key), Title, ISBN, Price, PublicationYear
● Author: Represents an author who has written books.
○ Attributes: AuthorID (Primary Key), FirstName, LastName, BirthYear
● Customer: Represents a customer who makes orders.
○ Attributes: CustomerID (Primary Key), FirstName, LastName, Email, Phone
● Order: Represents an order made by a customer.
○ Attributes: OrderID (Primary Key), OrderDate, ShippingAddress
● OrderItem: Represents a specific book in an order.
○ Attributes: OrderItemID (Primary Key), Quantity, PriceAtPurchase
102
Define Relationships:
● Author to Book: An Author can write many Books, and each Book can have one or more
Authors (many-to-many relationship).
● Customer to Order: A Customer can place many Orders, but each Order is placed by one
Customer (one-to-many relationship).
● Order to OrderItem: Each Order can contain multiple OrderItems, but each OrderItem refers
to one specific Order (one-to-many relationship).
● Book to Order: Each Order refers to one Book, and a Book can be part of many Order
(many-to-many relationship).
104
Add Constraints
● Cardinality:
○ An Author can write many Books, but each Book can have many Authors
(many-to-many).
○ A Customer can place many Orders, but each Order is associated with exactly
one Customer (one-to-many).
○ An Order contains one or more OrderItems, but each OrderItem belongs to
exactly one Order (one-to-many).
○ A Book can be in many OrderItems, and each OrderItem contains many Book
(many-to-many).
● Participation Constraints:
In relationship between Book and Author is a "writes" relationship. Here, the roles would be:
In the relationship between Customer and Order, we can define the roles as:
● Customer plays the role of placer (the person who places an order).
● Order plays the role of order placed by.
106
Structural Constraints in ER Diagrams
107
Weak Entity Types in ER Diagrams
It cannot be uniquely identified without the Order to which it belongs and the Book
that is part of the order.
In this case, OrderItem depends on the Order and Book entities for its identity.
108
Naming Conventions in ER Diagrams
● Clearly identified and easy to understand
Entities:
● Book: Use singular nouns for entity names. The entity represents a single book, not
a collection of books. So, name it "Book" instead of "Books."
● Customer: Similarly, name the entity as Customer, not Customers, because it refers
to a single customer at a time.
● Order: The entity representing a customer's order should be called Order to
represent a singular order.
● Author: Use singular form for the entity. For example, Author instead of Authors.
109
Attributes:
● BookID: The attribute BookID should be used as a unique identifier (primary key) for
each book.
● OrderID: The primary key for Order would be OrderID.
● FirstName and LastName: These attributes should be clear and represent individual
pieces of information about Customer and Author entities.
Relationships:
● Writes
● Places
● Contains
● Includes
110
Design Issues in ER Diagrams
● Cardinality and Participation Constraints
● Avoid Redundancy
● Weak Entities
● Complex Relationships : Customer placing an Order and the Order containing
multiple OrderItems and OrderItem and Book could be more intricate if a book
is ordered multiple times by various customers.
111
Relationship Types of Degree Higher than Two
● In an ER diagram, relationships can connect more than two entities.
● When relationships involve three or more entities, they are referred to as n-ary
relationships, where n refers to the number of entities involved.
112
Ternary Relationships (Degree 3):
113
Challenges of Ternary Relationships:
● A ternary relationship can be tricky because it involves more than two entities
● Decompose a ternary relationship into two binary relationships.
● For example, instead of using a ternary relationship to represent the connection
between Customer, Order, and Book, you could break it down into two separate
relationships:
○ Customer to Order (one-to-many)
○ Order to Book (many-to-many)
114
Decomposing Higher-Degree Relationships:
If the ternary relationship becomes too complex to represent, we can break it down into multiple
binary relationships.
For example:
This approach simplifies the structure and makes it easier to enforce referential integrity and
ensure the database's relationships are manageable.
115
Why Decompose Ternary to Binary Relationships?
116
REFINING THE COMPANY DATABASE
SCHEMA BY INTRODUCING RELATIONSHIPS
✔ By examining the requirements, six
relationship types are identified
✔ All are binary relationships( degree 2)
✔ Listed below with their participating entity
types:
✔ WORKS_FOR (between EMPLOYEE,
DEPARTMENT)
✔ MANAGES (also between EMPLOYEE,
DEPARTMENT)
✔ CONTROLS (between DEPARTMENT,
PROJECT)
✔ WORKS_ON (between EMPLOYEE, PROJECT)
ER DIAGRAM – RELATIONSHIP TYPES ARE:
WORKS_FOR, MANAGES, WORKS_ON, CONTROLS,
SUPERVISION, DEPENDENTS_OF
DISCUSSION ON RELATIONSHIP TYPES
✔ ER Diagrams - Notation