Unit 01
Unit 01
Systems
CS312 Database Management Systems
Course Objectives:
1. Knowledge
(i) Understand the fundamental concepts of database management System
(ii) To provide a strong formal foundation in database concepts, DBMS architectures recent technologies and best industry
practices.
2. Skills
(i) To learn the SQL database system.
(ii) To program PL/SQL including stored procedures, stored functions, cursors and packages.
3. Attitude
(i) To design the database system for real world applications.
(ii) To access, modify, program and authenticate the database system.
Course Outcomes:
1. Understand the different data models
2. Implement relational database design from any data model.
3. Create database system for real world applications
4. Handle the transaction management system.
7/17/2020 DATABASE MANAGEMENT SYSTEM LABORATORY 2
CCA & LCA Component
CCA-100M LCA-50M
3
Module 1- Introduction to Database Management Systems and Data Modeling
Syllabus:
• DBMS Vs File Systems, Database System Architecture,
• Database Architectures: Centralized, Client
Server, Parallel, Distributed, Data Abstraction, Data Independence, Data Definition an
d Data Manipulation Languages, Data Models
• ER diagram: Components of ER Model, Conventions, Keys, EER diagram
Components, Reduce E-R diagram into tables
4
History of Database Management System
• 1950s and early 1960s:
– Data processing using magnetic tapes for storage
• Tapes provided only sequential access
– Punched cards for input
• Late 1960s and 1970s:
– Hard disks allowed direct access to data
– Network and hierarchical data models in widespread use
– Ted Codd defines the relational data model
• Would win the ACM Turing Award for this work
• IBM Research begins System R prototype
• UC Berkeley begins Ingres prototype
– High-performance (for the era) transaction processing
5
History(Contd.)
• 1980s:
– Research relational prototypes evolve into commercial systems
• SQL becomes industrial standard
– Parallel and distributed database systems
– Object-oriented database systems
• 1990s:
– Large decision support and data-mining applications
– Large multi-terabyte data warehouses
– Emergence of Web commerce
• Early 2000s:
– XML and XQuery standards
– Automated database administration
• Later 2000s:
– Giant data storage systems
• Google BigTable, Yahoo PNuts, Amazon, ..
6
Basics of Database Management System
• DBMS contains information about a particular enterprise Eg.-University Database
– Collection of interrelated data
Example
– Set of programs to access the data
– An environment that is both convenient and efficient to • Application program examples
use – Add new students, instructors,
– Databases can be very large. and courses
• Database Applications: – Register students for courses,
– Banking: transactions
and generate class rosters
– Airlines: reservations, schedules
– Assign grades to students,
– Universities: registration, grades
– Sales: customers, products, purchases
compute grade point averages
– Online retailers: order tracking, customized
(GPA) and generate transcripts
recommendations
– Manufacturing: production, inventory, orders, supply
chain
– Human resources: employee records, salaries, tax
deductions
7
DBMS Vs 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 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
8
DBMS Vs File Systems contd.
• Concurrent access by multiple users
– Concurrent access needed for performance
– Uncontrolled concurrent accesses can lead to inconsistencies
• Example: Two people reading a balance (say 100) and updating it by withdrawing money (say 50
each) at the same time
• Security problems
– Hard to provide user access to some, but not all, data
9
Database System Architectures
• Centralized and
• Client-Server Systems
• Parallel Systems
• Distributed Systems
10
• Run on a single computer system and do not
Centralized Systems
interact with other computer systems.
• General-purpose computer system: one to a
few CPUs and a number of device controllers
that are connected through a common bus
that provides access to shared memory.
• Single-user system (e.g., personal computer
or workstation): desk-top unit, single user,
usually has only one CPU and one or two
hard disks; the OS may support only one
user.
• Multi-user system: more disks, more
memory, multiple CPUs, and a multi-user OS.
Serve a large number of users who are
connected to the system vie terminals. Often
called server systems.
11
Client-Server • Server systems satisfy requests generated at
m client systems, whose general structure is
Systems shown in the dig.
• Database functionality can be divided into:
• Back-end: manages access structures,
13
Distributed Systems
14
Levels of Abstraction
• Physical level: describes how a record (e.g.,
instructor) is stored.
• Logical level: describes data stored in database, and
the relationships among the data.
type instructor = record
ID : string;
name : string;
dept_name : string;
salary : integer;
end;
• View level: application programs hide details of
data types. Views can also hide information (such
as an employee’s salary) for security purposes.
16
Data Independence
Types of Data Independence :
• Physical Data Independence : the ability to modify the physical schema without
changing the logical schema
⮚ Applications depend on the logical schema
⮚ In general, the interfaces between the various levels and components should be well defined so
that changes in some parts do not seriously influence others.
• Logical Data Independence : the ability to change the conceptual scheme without
changing
⮚ External views
⮚ External API or programs
⮚ Any change made will be absorbed by the mapping between external and conceptual levels.
⮚ When compared to Physical Data independence, it is challenging to achieve logical data
independence.
17
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)
• Semistructured data model (XML)
• Other older models:
– Network model
– Hierarchical model
Database System Languages
Data Definition Language(DDL) Data Manipulation Language (DML)
19
Database System
Structure/Architecture
Important Components of
Database System :
⮚Database Users
⮚Query Processing
⮚Storage Management
⮚Transaction Management
20
Database System Components : Database Users
21
Database System Components : Query Processing
DML Pre-Compiler:
• It converts DML statements embedded in an application program to normal procedure calls in the host
language.
• The pre-complier must interact with the query processor in order to generate the appropriate code.
DDL Compiler:
• The DDL compiler converts the data definition statements into a set of tables. These tables contains
information concerning the database and are in a form that can be used by other components of the
dbms.
File Manager:
• File manager manages the allocation of space on disk storage and the data structure used to represent
information stored on disk.
Query Processor:
• The query processor used to interpret to online user’s query and convert it into an efficient series of
operations in a form capable of being sent to the data manager for execution.
• The query processor uses the data dictionary to find the details of data file and using this information it
create query plan/access plan to execute the query.
22
Database System Components : Query Processing
23
Database System Components : Query Processing
Data Dictionary:
• Data dictionary is the table which contains the information about database objects. It contains
information like
24
Database System Components :Storage Management
b. integrity enforcement.
c. security enforcement.
e. concurrency control.
• Issues:
– Storage access
– File organization
Note: ER diagram notation in 6th edition of Database System Concepts changed from earlier
editions; now based on UML class diagram notation with some modifications.
Relationship Sets With Attributes
• An attribute can also be property of a relationship set.
• For instance, the advisor relationship set between entity sets instructor and student may have
the attribute date
– E.g. date may track when the student started being associated with the advisor
Relationship Sets with Attributes
Attributes
• An entity is represented by a set of attributes, that is descriptive properties possessed by all members
of an entity set.
– Example:
instructor = (ID, name, street, city, salary )
course= (course_id, title, credits)
• Domain – the set of permitted values for each attribute
• Attribute types:
– Simple and composite attributes.
– Single-valued and multivalued attributes
• Example: multivalued attribute: phone_numbers
– Derived attributes
• Can be computed from other attributes
• Example: age, given date_of_birth
Composite Attributes
Entity With Composite, Multivalued, and Derived Attributes
composite
multivalued
derived
Degree of a Relationship Set
• binary relationship
– involve two entity sets (or degree two).
– most relationship sets in a database system are
binary.
• Relationships between more than two entity sets are
rare. Most relationships are binary. (More on this
later.)
Example:
• Ternary relationship
⮚Example: students work on
research projects under the
guidance of an instructor.
⮚relationship proj_guide is
a ternary relationship
between instructor, student,
and project
38
Mapping Cardinality Constraints
• Express the number of entities to which another entity can be associated via a relationship
set.
• Most useful in describing binary relationship sets.
• For a binary relationship set the mapping cardinality must be one of the following types:
– One to one
– One to many
– Many to one
– Many to many
Mapping Cardinalities
● Total participation (indicated by double line): every entity in the entity set participates in at least
one relationship in the relationship set
● E.g. participation of section in sec_course is total
4 every must have an associated course
● Partial participation: some entities may not participate in any relationship in the relationship set
● Example: participation of instructor in advisor is partial
Alternative Notation for Cardinality Limits
• Cardinality limits can also express participation constraints
– Number on line represents how many times the entity can participate in the relationship
•An airplane has a model number, a registration number, and the capacity to take one or more passengers.
•An airplane flight has a unique flight number, a departure airport, a destination airport, a departure date and time,
and an arrival date and time.
•A passenger has given names(first name, last name),contact and a unique email address.
55
Extended E-R Features: Specialization
• Top-down design process; we designate subgroupings within an entity set that are distinctive
from other entities in the set.
• It is a top-down approach in which one higher level entity can be broken down into two lower
level entity.
• These subgroupings become lower-level entity sets that have attributes or participate in
relationships that do not apply to the higher-level entity set.
• Depicted by a triangle component labeled ISA (E.g. instructor “is a” person).
• Attribute inheritance – a lower-level entity set inherits all the attributes and relationship
participation of the higher-level entity set to which it is linked.
Specialization Example
Extended ER Features : Generalization
• A bottom-up design process – combine a number of entity sets
that share the same features into a higher-level entity set.
⮚Specialization and generalization are simple inversions of each other; they
are represented in an E-R diagram in the same way.
⮚The terms specialization and generalization are used interchangeably.
In generalization, the higher level entity can also combine with other
lower level entities to make further higher level entity.
58
Generalization Example
59
Extended ER Features : Aggregation
• Aggregration is a process when relation • Consider the ternary relationship
between two entities is treated as a single proj_guide, which we saw earlier
entity. ▪ Suppose we want to record
• Eliminate this redundancy via aggregation evaluations of a student by a guide on a
project.
▪Treat relationship as an abstract entity
▪ Relationship sets eval_for and
▪Allows relationships between relationships proj_guide represent overlapping
▪Abstraction of relationship into new entity information
▪Every eval_for relationship
corresponds to a proj_guide relationship
• Without introducing redundancy, ▪However, some proj_guide relationships
▪A student is guided by a particular instructor on may not correspond to any eval_for
a particular project relationships
◦So we can’t discard the proj_guide
▪A student, instructor, project combination may relationship
have an associated evaluation 60
Aggregation Example
61
Reduction to Relational Schemas
62
Representing Entity Sets With Simple Attributes
• A strong entity set reduces to a schema with the same attributes
student(ID, name, tot_cred)
• A weak entity set becomes a table that includes a column for the primary key of the identifying strong
entity set
section ( course_id, sec_id, sem, year )
Representing Relationship Sets
• A many-to-many relationship set is represented as a schema with attributes for the primary keys
of the two participating entity sets, and any descriptive attributes of the relationship set.
• Example: schema for relationship set advisor
advisor = (s_id, i_id)
Redundancy of Schemas
● Many-to-one and one-to-many relationship sets that are total on the many-side can be
represented by adding an extra attribute to the “many” side, containing the primary key of the
“one” side
● Example: Instead of creating a schema for relationship set inst_dept, add an attribute dept_name
to the schema arising from entity set instructor
Redundancy of Schemas (Cont.)
• For one-to-one relationship sets, either side can be chosen to act as the “many” side
– That is, extra attribute can be added to either of the tables corresponding to the two
entity sets
• If participation is partial on the “many” side, replacing a schema by an extra attribute in
the schema corresponding to the “many” side could result in null values
• The schema corresponding to a relationship set linking a weak entity set to its identifying
strong entity set is redundant.
– Example: The section schema already contains the attributes that would appear in the
sec_course schema
Composite and Multivalued Attributes
• Composite attributes are flattened out by creating a separate attribute
for each component attribute
– Example: given entity set instructor with composite attribute
name with component attributes first_name and last_name the
schema corresponding to the entity set has two attributes
name_first_name and name_last_name
• Prefix omitted if there is no ambiguity
• Ignoring multivalued attributes, extended instructor schema is
– instructor(ID,
first_name, middle_initial, last_name,
street_number, street_name,
apt_number, city, state, zip_code,
date_of_birth)
Composite and Multivalued Attributes
70
71
72
73