unit-1&2
unit-1&2
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
part of program code
Hard to add new constraints or change existing ones
Purpose of Database Systems (Cont.)
192-83-7465 Johnson
Alma Palo Alto A-101
019-28-3746 Smith
North Rye A-215
192-83-7465 Johnson
Alma Palo Alto A-201
321-12-3123 Jones
Main Harrison A-217
019-28-3746 Smith
North Rye A-201
A Sample Relational
Database
Unit1 –lecture5
Database Users
Users are differentiated by the way they expect to
interact with the system
Application programmers – interact with system
through DML calls
Sophisticated users – form requests in a database
query language
Specialized users – write specialized database
applications that do not fit into the traditional data
processing framework
Naïve users – invoke one of the permanent
application programs that have been written
previously
◦ E.g. people accessing database over the web, bank tellers, clerical staff
Database Administrator
Coordinates all the activities of the database
system; the database administrator has a
good understanding of the enterprise’s
information resources and needs.
Database administrator's duties include:
◦ Schema definition
◦ Storage structure and access method definition
◦ Schema and physical organization modification
◦ Granting user authority to access the database
◦ Specifying integrity constraints
◦ Acting as liaison with users
◦ Monitoring performance and responding to changes in
requirements
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.
Storage Management
Storage manager is a program module that
provides the interface between the low-level
data stored in the database and the
application programs and queries submitted
to the system.
The storage manager is responsible to the
following tasks:
◦ interaction with the file manager
◦ efficient storing, retrieving and updating of data
Overall System Structure
Application Architectures
Attribute
Cardinality = 2
tuple/relational
instance SID Name Major GPA
1234 John CS 2.8
5678 Mary EE 3.6
4 Degree
A Schema / Relation
From ER Model to Relational
Model
So… how do we convert an ER diagram into
a table?? Simple!!
Basic Ideas:
Build a table for each entity set
Primary Key
Example – Strong Entity
Set
SID Name SSN Name
Major Dept
GPA
Major GPA
Major GPA
P-Key3
E-Set 3
itself
SSN Name
Street City
Representing Multivalue
Attribute
For each multivalue attribute in an entity
set/relationship set
◦ Build a new relation schema with two columns
◦ One column for the primary keys of the entity
set/relationship set that has the multivalue
attribute
◦ Another column for the multivalue attributes.
Each cell of this column holds only one value.
So each value is represented as an unique tuple
◦ Primary key for this schema is the union of all
attributes
Example – Multivalue
attribute The primary key for this
SID Name
table is Student_SID +
Children, the union of all
Children attributes
Student
Major GPA
Stud_SID Children
1234 Johnson
1234 Mary
SID Name Major GPA
5678 Bart
1234 John CS 2.8
5678 Lisa
5678 Homer EE 3.6
5678 Maggie
Representing Class
Hierarchy
Two general approaches depending on
disjointness and completeness
◦ For non-disjoint and/or non-complete class
hierarchy:
create a table for each super class entity set
according to normal entity set translation method.
Create a table for each subclass entity set with a
column for each of the attributes of that entity set
plus one for each attributes of the primary key of the
super class entity set
This primary key from super class entity set is also
used as the primary key for this new table
Example SSN Name
Person
SID Status
Gender
ISA
Student
Major GPA
e entity set
SJSU people
ISA
SID
Student Faculty
Disjoint and Complete
mapping
Major GPA Dept
Dept
SID
Name
member
Primary Key of Advisor
Dept