Database Management Systems
Introduction
Data – Any fact that can be recorded
e.g., - texts, numbers, alphanumeric, audio, video, image.
Database – Collection of interrelated data
◦ Types of database –
Traditional database
Multimedia database
Geographic Information System (GIS) Database
Real-time database
Data Warehouse (huge volume of historical data)
DBMS – Collection of interrelated data and a set of programs to access those data. It
helps us to store and retrieve database information in a convenient and efficient manner.
Database (DB) + Database Management System (DBMS) = Database System (DBS)
Koushik De- CSE, UEMK 2
Introduction (contd..)
DBMS Softwares – MS Access, Oracle, SQL Server, MySQL DB2, SYBASE, etc.
MS Excel – Does possess data management capabilities, but not a pure DBMS.
Languages used by DBMS Softwares – SQL, PL/SQL
Applications – Banking, Airline, Retail, Manufacturing, Telecommunication,
Universities, etc.
Users of Database –
Naive Users – Who knows nothing about the database but interacts with the
system by invoking one of the application programs that have been written earlier.
Sophisticated Users – performs the same task of data entry not by using any
application program, but by means of query language like SQL.
Koushik De- CSE, UEMK 3
Introduction (contd..)
Application Programmers – Developers who interact with the database by means of DML
queries or Rapid Action Development (RAD) tools. These DML queries are written in the
application programs like C, C++, JAVA, Pascal etc. These queries are converted into object
code to communicate with the database. For example, writing a C program to generate the
report of employees who are working in particular department will involve a query to fetch
the data from database. It will include a embedded SQL query in the C Program.
Sophisticated Users – They are sophisticated users who write specialized database
applications like computer-aided designs, knowledge and expert systems that store data
with complex data types (e.g., audio/video data, graphics data).
Database Administrators (DBA) – A person or a group of persons who monitors the
database management system handling.
Creates the original database
Makes physical changes (modifications) to the scema
Grants authorization for data access
Does routine maintenance and periodic back up.
Koushik De- CSE, UEMK 4
DBMS Vs. File-processing Systems
Data redundancy and inconsistency
Difficulty in accessing data
Data isolation – multiple files and formats
Integrity problems (enforcing consistency constraints)
Atomicity of updates
Concurrent access by multiple users
Security problems
Koushik De- CSE, UEMK 5
DBMS Architectures
User User
Application Application
Server
Programs Programs
Database Database
Two-tier Architecture Three-tier Architecture
Koushik De- CSE, UEMK 6
Views
Part of the database that is visible to a particular user, for e.g., in a banking
system, the person who checks the account debits and credits of a customer is
not granted access to the payroll system. The account, depositor and borrower
tables are his view.
Differ from person to person.
The authorization of access is granted by the DBA.
Koushik De- CSE, UEMK 7
Levels of Abstraction
Users
User View level describes how users see the
data.
Conceptual or Logical level defines logical
structure
View 1 View 2 View 3
Physical level describes the files and indexes
used.
Conceptual Schema
also known as the
ANSI/SPARC model Physical Schema
DB
8
Example: University Database
Conceptual schema:
◦ Students (sid: string, name: string, age: integer, gpa:real)
◦ Courses (cid: string, cname:string, credits:integer)
◦ Enrolled (sid:string, cid:string, grade:string)
View 1 View 2 View 3
External Schema (View Level):
◦ Course info (cid:string, enrollment:integer) Conceptual Schema
Physical schema: Physical Schema
◦ Relations stored as unordered files.
◦ Index on first column of Students.
DB
Koushik De- CSE, UEMK 9
Data Independence
Ability to modify a schema definition in
one level without affecting a schema View 1 View 2 View 3
definition in the other levels.
Conceptual Schema
Logical data independence: Protection
from changes in logical structure of data.
Physical Schema
Physical data independence: Protection
from changes in physical structure of data.
DB
Koushik De- CSE, UEMK 10
Metadata & Data dictionary
Metadata – Data about data
It is the overall description of the database specified by a set of definitions and
constraints, for e.g. –
Means of creation of the data
Purpose of the data
Time and date of creation
Creator or author of the data
Location on a computer network where the data was created
Standards used
File size
Data dictionary – Metadata repository
It stores information about each data element in the database such as its name, data
type, range of value, source, access authorization and indicates which application
programs use this data item.
Koushik De- - CSE, UEMK 11
Database Models
Koushik De- - CSE, UEMK 12
Database Models
Object based Record based Physical
data model data model data model
Entity-Relationship (E-R) Hiearchical Unifying
Semantic Network
Frame-memory
Functional
Relational
Object based
Koushik De- - CSE, UEMK 13
Hierarchical Data Model
Koushik De- - CSE, UEMK 14
Network Data Model
Koushik De- - CSE, UEMK 15
Relational Data Model
Koushik De- - CSE, UEMK 16
Comparison
Koushik De- - CSE, UEMK 17
Entity-Relationship (E-R) Model
social-security customer-street
account-number
customer-name customer-city balance
customer depositor account
Koushik De- - CSE, UEMK 18
E-R Model (Contd..)
name dob cid
age
roll cname
student enroll course
Attributes
Relationship
Entity Set
Koushik De- - CSE, UEMK 19
RDBMS
Koushik De- - CSE, UEMK 20
RDBMS
A relational database management system (RDBMS) is a database management
system (DBMS) that is based on the relational model as invented by E. F. Codd
He proposed thirteen golden rules to define what is required from a database
management system in order for it to be considered relational, i.e., RDBMS
See Codd’s 13 Golden Rules
Basic Idea –
to present the data to the user as relations (i.e. as a collection of tables with
each table consisting of a set of rows and columns)
to provide relational operators to manipulate the data in tabular form.
Koushik De- - CSE, UEMK 21
Relational Schema
Fields / Attributes
C
a
Student r
d
Roll Name DOB Age i
n
1 Aamir Khan 14-03-1965 50 Tuple / a
2 Shahrukh Khan 02-11-1965 50 Record / l
Entity i
3 Salman Khan 28-12-1965 50 t
y
Degree
Student
Entity Set
Values
Schema
Koushik De- - CSE, UEMK 22
Few Terminologies
Schema – the logical structure of the database (e.g., set of customers and accounts
and the relationship between them).
Instance – the actual content of the database at a particular point in time.
Degree – the number of columns associated with a relation or table.
Cardinality – the number of rows in a table.
Domain – the range of possible values for an attribute.
e.g. – the domain for the attribute gender may be {‘M’, ‘F’}
the domain for the attribute title may be { ‘Mr.’, “Ms.’, ‘Mrs.’, ‘Dr.’}
Koushik De- - CSE, UEMK 23
Few Terminologies (Contd..)
Extension - The extension of a given relation is the set of tuples appearing in that
relation at any given instance. The extension thus varies with time. It changes as
tuples are created, destroyed, and updated.
EmpNo EmpName Dept
1001 Ramesh Marketing at time t1
1002 Suresh Finance
EmpNo EmpName Dept
1001 Ramesh Marketing
1002 Suresh Finance
at time t2
1003 Amar Sales
1004 Akbar HR
1005 Antony Finance
Koushik De- - CSE, UEMK 24
Few Terminologies (Contd..)
Intension - The intension of a given relation is independent of time. It is the
permanent part of the relation. It corresponds to what is specified in the relational
schema.
It is a combination of two things : a structure and a set of integrity constraints.
Example -
Employee (EmpNo Number(4) Not NULL, EmpName Char(20), Dept
Char(10) )
This is the intension of Employee relation.
Control Redundancy – Read only data is repeated sometimes to increase
availability.
Koushik De- - CSE, UEMK 25
Types of Atrributes
Simple attribute – attribute that consist of a single atomic value.
e.g. – Roll, Marks, Salary, etc.
Composite Attribute – attributes which can be decomposed further
e.g. – Name (First Name, Middle Name, Last Name)
Address (House No., Street, City, State)
Single-valued atribute – attribute that hold a single value
e.g. – City, EmpId, Salary, etc.
Multi-valued attribute – attribute that hold multiple values
e.g. – Phone no., EmailID
Derived attribute – an attribute that can be calculated or derived from another
attribute
e.g. – Age (derived from DOB)
Null attribute – an attribute whose value is missing for a record.
e.g. - if a record does not contain an assignment for the Price attribute
Koushik De- - CSE, UEMK 26
Concept Of Keys
Koushik De- - CSE, UEMK 27
Keys
Super Key – An attribute or a group of attribute that can uniquely identify a tuple
from a relational schema.
Candidate Key – Minimal Super key.
Prime attribute – Member of some candidate key
Primary Key – One of the Candidate keys (usually the most powerful one,
depends on the choice of the user) that can uniquely fetch a tuple from a relational
schema.
A primary key cannot accept NULL values.
A composite primary key is a primary key comprising of more than one attributes.
Alternate / Secondary Key – Rest all candidate keys.
Unique Key – same as primary key, but can accept NULL values.
Koushik De- - CSE, UEMK 28
Keys (Contd..)
Foreign Key – An attribute of an entity set E, which is dependant on the primary
key of another entity set E1.
The former table is called the referencing table and the latter is called the
referenced or derived table.
In such a case, E has to be constructed first and then E1. While deletion, E1 has
to be deleted first and then E.
e.g. – Consider the below relations:
student = (roll, name, marks)
course = (cid, cname)
enroll = (roll, cid)
roll, cid in the enroll relation are foreign keys and together form the composite
primary key for the relation.
Koushik De- - CSE, UEMK 29
Strong and Weak Entity Set
Strong entity set – An entity set that has a fixed entity set.
Weak entity set – An entity set that does not have sufficient attributes to form a
primary key.
e.g. –
loan = (loan_id, loan_name, borrower, amount)
payment = (payment_id, payment_date, amount)
The payment relation does not have a primary key (payment_id cannot uniquely
identify tuples) and hence is a weak entity set.
Discriminator/Partial Key – An attribute of a weak entity set which normally
does not show uniqueness, but shows uniqueness when combined with a strong
Entity set.
e.g. – payment_id when combined with loan_id, can uniquely identify tuples.
Koushik De- - CSE, UEMK 30
Integrity Constraints
Entity Integrity – If an attribute is a prime attribute, it cannot accept NULL
values. In other words, no component of a primary key can be NULL.
Extension to the above rule - No non-key attribute can be referenced.
Referential Integrity – Ensures that a value that appears in one relation for a given
set of attributes also appears for a certain set of attributes in another relation.
In other words, it states that any foreign key value must match a primary key value
(or the foreign key value can be NULL).
e.g. –
Restrict – do not allow deletion of ‘parent’ side if related rows exist in
‘dependant’ side.
Cascade – automatically delete ‘dependant’ side rows that correspond to
the ‘parent’ side row to be deleted.
Koushik De- - CSE, UEMK 31
Entity-Relationship Diagram
Koushik De- - CSE, UEMK 32
E-R Model
Proposed by Peter Chen in 1976
ER diagram is widely used in database design
◦ Represent conceptual level of a database system
◦ Describe things and their relationships in high level
Entity set – an abstraction of similar things, e.g. cars, students
◦ An entity set contains many entities
Attributes – common properties of the entities in a entity sets
Relationship – specify the relations among entities from two or more entity sets
Koushik De- - CSE, UEMK 33
E-R Diagram Notations
Koushik De- - CSE, UEMK 34
E-R Diagram Notations (contd..)
Koushik De- - CSE, UEMK 35
An Example
Koushik De- - CSE, UEMK 36
Attributes
Both entity sets and relationships can have attributes
Attributes may be
◦ Composite
◦ Multi-valued (double ellipse)
◦ Derived (dashed ellipse)
Koushik De- - CSE, UEMK 37
An Example
Koushik De- - CSE, UEMK 38
Relationship
The degree of a relationship = the number of entity sets that participate in the
relationship
◦ Mostly binary relationships
◦ Sometimes more
Mapping cardinality of a relationship
◦ 1 –1
◦ 1 – many
◦ many – 1
◦ Many-many
Koushik De- - CSE, UEMK 39
Relationship Example
Koushik De- - CSE, UEMK 40
Attribute of A Relationship Set
Koushik De- - CSE, UEMK 41
One-One and One-Many
Koushik De- - CSE, UEMK 42
Many-one and many-many
Koushik De- - CSE, UEMK 43
Total Participation
When we require all entities to participate in the relationship (total
participation), we use double lines to specify
Every loan has to have at
least one customer
Koushik De- - CSE, UEMK 44
Alternative Cardinality Specification
• l..h - Minimum cardinality..maximum cardinality
• A minimum value of 1 indicates total participation of the entity set in the relationship
• A maximum value of 1 indicates that the entity participates in at most one
relationship, while a maximum value of * indicates no limit.
• A label 1..* indicates total participation.
Koushik De- - CSE, UEMK 45
Self Relationship
Sometimes entities in a entity set may relate to other entities in the same set. Thus
self relationship
Here employees mange some other employees
The labels “manager” and “worker” are called roles the self relationship
Koushik De- - CSE, UEMK 46
Weak Entity Set
Some entity sets in real world naturally depend on some other entity set.
They can be uniquely identified only if combined with another entity set
Double rectangles
for weak entity set
Double diamond
for weak entity
relationship
Dashed underscore
for discriminator
Koushik De- - CSE, UEMK 47
Extended E-R Features
Koushik De- - CSE, UEMK 48
Koushik De- - CSE, UEMK
Koushik De- - CSE, UEMK
Koushik De- - CSE, UEMK
Database Languages
Koushik De- - CSE, UEMK 52
Database Languages
Procedural Non-procedural
Determines WHAT & HOW a Is concerned with the WHAT not the
process should be done. HOW
e.g. – Relational Algebra e.g. – Relational Calculus, SQL
Koushik De- - CSE, UEMK 53
Types of SQL Statements
Data Definition Language (DDL) – specifies the database schema (CREATE,
ALTER, DROP)
Data Manipulation Language (DML) – enables the user to access or manipulate
data such as insertion, deletion and modification or records (INSERT, DELETE,
UPDATE)
Data Query Language (DQL) – enables the user to query* on one or more tables to
get the required information they want (SELECT)
Data Control Language (DCL) – using this, the access of users is controlled by the
DBA (GRANT, REVOKE)
Transaction Control Language (TCL) – enables the user for transaction processing
(COMMIT, ROLLBACK, ROLLBACK TO)
* A query is a statement requesting the retrieval of information (e.g., select * from student where age > =18;)
Koushik De- - CSE, UEMK 54
Appendix
Koushik De- - CSE, UEMK 55
Codd’s 13 Golden Rules
Rule 0: The Foundation rule:
For any system that is advertised as, or claimed to be, a relational data base management
system, that system must be able to manage data bases entirely through its relational
capabilities.
Rule 1: The information rule:
All information in a relational data base is represented explicitly at the logical level and in
exactly one way — by values in tables.
Rule 2: The guaranteed access rule:
Each and every datum (atomic value) in a relational data base is guaranteed to be logically
accessible by resorting to a combination of table name, primary key value and column
name.
Rule 3: Systematic treatment of null values:
Null values (distinct from the empty character string or a string of blank characters and
distinct from zero or any other number) are supported in fully relational DBMS for
representing missing information and inapplicable information in a systematic way,
independent of data type.
Rule 4: Dynamic online catalog based on the relational model:
The data base description is represented at the logical level in the same way as ordinary
data, so that authorized users can apply the same relational language to its interrogation as
they apply to the regular data.
Koushik De- - CSE, UEMK 56
Codd’s 13 Golden Rules (Contd..)
Rule 5: The comprehensive data sublanguage rule:
A relational system may support several languages and various modes of terminal use (for
example, the fill-in-the-blanks mode). However, there must be at least one language whose
statements are expressible, per some well-defined syntax, as character strings and that is
comprehensive in supporting all of the following items: Data definition.
View definition.
Data manipulation (interactive and by program).
Integrity constraints.
Authorization.
Transaction boundaries (begin, commit and rollback).
Rule 6: The view updating rule:
All views that are theoretically updatable are also updatable by the system.
Rule 7: High-level insert, update, and delete:
The capability of handling a base relation or a derived relation as a single operand applies
not only to the retrieval of data but also to the insertion, update and deletion of data.
Rule 8: Physical data independence:
Application programs and terminal activities remain logically unimpaired whenever any
changes are made in either storage representations or access methods.
Koushik De- - CSE, UEMK 57
Codd’s 13 Golden Rules (Contd..)
Rule 9: Logical data independence:
Application programs and terminal activities remain logically unimpaired when
information-preserving changes of any kind that theoretically permit unimpairment are
made to the base tables.
Rule 10: Integrity independence:
Integrity constraints specific to a particular relational data base must be definable in the
relational data sublanguage and storable in the catalog, not in the application programs.
Rule 11: Distribution independence:
A relational DBMS has distribution independence.
Rule 12: The nonsubversion rule:
If a relational system has a low-level (single-record-at-a-time) language, that low level
cannot be used to subvert or bypass the integrity rules and constraints expressed in the
higher level relational language (multiple-records-at-a-time).
<< Back
Koushik De- - CSE, UEMK 58
......The End.....
Koushik De- - CSE, UEMK 59