Beruflich Dokumente
Kultur Dokumente
21st
Todays Agenda
DBMS Problems
Normalization Approach
2
Prashant Barge, SIOM
*
Draw ERD for 1. Employee is Supervisor, Manager and Staff. Also Staff if Permanent and Ad-hoc
2. For Vehicle Registration database, vehicle may be Two or Three or Four Wheeler. Owner may be Person or Bank or Organization. 3. For a College database, student is UG, G or PG.
The basic concepts of ER modelling is not powerful enough for some complex applications... We require some additional semantic modelling concepts:
*
This is the process of maximising the differences between members of an entity by identifying their distinguishing characteristics.
*
manages Department works for Sales Personnel Staff Manager Secretary
*Here
we have shown that the manages relationship is only applicable to the Manager subclass, whereas the works_for relationship is applicable to all staff. *It is possible to have subclasses of subclasses.
a
a
e.g.
Attribute Inheritance
Specialisation
the process of defining a set of more specialised entity types of an entity type
Generalisation
the process of defining a generalised entity type from a set of entity types
Disjoint Constraint
Disjoint Overlap
Participation Constraint
Total Participation Partial Participation
Disjointness
Overlap Disjoint
the same entity instance is a member of only one subclass of the specialization
the same entity instance may be a member of more than one subclass of the specialization
Completeness
Total
every entity instance in the superclass must be a member of some subclass in the specialisation
Partial
an entity instance in the superclass need not be a member of any subclass in the specialisation
*
given name STUDENT family studno
tutor
payroll no
name STAFF
length of service
level grade
ACADEMIC
TECHNICAL
ADMIN
project
name
PERSON
Overlap
EMPLOYEE
STUDENT
Overlap
thesis
Disjoint
RESEARCH
Overlap
LECTURING
TUTORS
SUPERVISOR
FINAL YEAR
Course no
project
PERSON
COMPANY
personid
compid
U
duration of ownership
OWNER
*
1. Create a relation for superclass
2. Create a relation for each subclass such that: {primary_key of superclass} U {attributes of subclass}
Option A
d
year undergraduate thesis title postgraduate
Option B
family studno
d
year undergraduate thesis title postgraduate
U {type attribute}
d
year undergraduate thesis title postgraduate
1.STAFF(payrollno,name,lengthofservice) ACADEMIC(payrollno,level)
payroll no name STAFF
TECHNICAL(payrollno,project)
ADMIN(payrollno,grade)
length of service
2.ACADEMIC(payrollno,name,lengthofservice,
O
level grade
level) TECHNICAL(payrollno,name,lengthofservice, project) ADMIN(payrollno, name, lengthofservice, grade) 3.STAFF(payrollno, name, lengthofservice, level,
ACADEMIC
TECHNICAL
ADMIN
project
*
name address O salary fee PERSON
EMPLOYEE
STUDENT
UNDER GRAD
year = 3
LECTURING
TUTORS
SUPERVISOR
FINAL YEAR
courseno
project
20
The software that organises data into records in one or more databases and allows organising, accessing and sorting of the data in a variety of formats.
21
22
Database Approach
Advantages
Program-data independence Minimal data redundancy Improved data consistency Improved data sharing Increased productivity of application development Enforcement of standards Improved data quality Improved data accessibility and responsiveness Reduced maintenance
23
3 Level Architecture
user a user i/program j program x
External Users and Applications view of data Conceptual Logical Data Model Physical Physical data Model
25
External (Sub) Schema defines the external view of data as seen by a user or program
Conceptual Schema defines the logical view of data as seen by all technical users and programs Physical (Internal) Schema defines the physical view of data as seen by a DBMS
26
DBMS Models
1. Hierarchy Model 2. Network Model 3. Relational DBMS 4. Object Oriented Model -
27
DBMS Models
1. Hierarchy Model (1960s) Data in a tree structure, Parent Child Relationships Which is one to many, Restricts a child segment to having only one parent segment
28
DBMS Models
2. Network Model
Conference on Data Systems Languages (CODASYL) formally defined the network model in 1971. basic data modeling construct in the network model is the set construct. A set consists of an owner record type, a set name, and a member record type. A member record type can have that role in more than one set, hence the multi-parent concept is supported. An owner record type can also be a member or owner in another set.
29
Prashant Barge, SIOM
DBMS Models
3. Relational DBMS Relational model developed by E.F. Codd. The data and relations between them are organized in tables. A table is a collection of records and each record in a table contains the same fields. Certain fields are designated as keys.
30
Prashant Barge, SIOM
31
DBMS Models
4.
32
Metadata
Data that describe the properties or characteristics of data. Some of these properties include data definitions, data structures and rules or constraints. Item name, the data type, length, minimum and maximum allowable values (where appropriate) and a brief description of each data item. Metadata allow database designers and users to understand what data exist, what the data mean. Data without clear meaning can be confusing, misinterpreted.
33
Metadata
E.g. Data Item Name Type Name Character ID Number Dept Character Age Integer Name Character Manager Number Value Length Min Max 30 9 10 2 18 60 15 9
Description Employee Name Employee No. Dept. No. Employee Age Dept. Name Mgr. Emp. No.
Database Approach
Disadvantages DBMS are more vulnerable than file-based system because of the centralised nature of a large integrated database. If a failure occurs the recovery process is more complex and some times may results in lost transactions. Hardware, software and personnel cost are higher for DBMS.
35
Session 11
36
Normalization Approach There are many types / levels of normalized forms existing in a database environment
Unnormalized Form (UNF) First Normal Form (1NF) Second Normal Form (2NF) Third Normal Form (3NF)
These are some advanced normal forms used rarely.
Boyce-Codd Normal Form (BCNF) Fourth Normal Form (4NF) Fifth Normal Form (5NF)
It
is the process of Decomposing unsatisfactory relations/ user views into smaller relations
It is process of analysis of functional dependency between attributes / data items of user views
Its an another approach for Conceptual data model which in turn can be mapped to any one of the data model like
Hierarchical Network Relational
Reduce Data Redundancy Reduce Data Storage Space Reduce Inconsistency of Data Reduce Update Costs Improve Flexibility
Student
Info
Card
Different constraints
*Students Roll No should be unique *A student can join many courses *A particular student has a single phone number, and single
major Subject
*A course is taught by only one Professor *One grade is given to a student for a particular course
Constraints
Constraints Restricts / guides the design of the Data Bases So Very imp to understand the constraints
A Relational State
Roll No Name 101 Rohit Course CS203 Ph-No 696453 Major Comp. Prof. Rajat Grade A
102
101 103 103 101 104
Nath
Rohit Martin Martin Rohit Baxter
CS303
CS328 CS303 CS503 CS492 CS379
427739
696453 388518 388518 696453 831803
Chemi.
Comp. Physics Physics Comp. English
Bharat
Rajat Bharat Shyam Criss Roid
B
B A C B C
PROBLEMS
Redundancy Of Data
Roll No
101 102
Name
Rohit Nath
Course
CS203 CS303
Ph-No
696453 427739
Major
Comp. Chemi.
Prof.
Rajat Bharat
Grade
A B
101
103 103 101 104
Rohit
Martin Martin Rohit Baxter
CS328
CS303 CS503 CS492 CS379
696453
388518 388518 696453 831803
Comp.
Physics Physics Comp. English
Rajat
Bharat Shyam Criss Roid
B
A C B C
104
Baxter
CS379
831803
English
Roid
Grade A B B A C B C
Nath
Rohit
CS303
CS328
427739
696453
Chemi.
Comp.
Bharat
Rajat
B
B
Martin
CS303
388518
Physics
Bharat
Martin
Rohit Baxter
CS503
CS492 CS379
388518
696453 831803
Physics
Comp. English
Shyam
Cross Rod
C
B C
* Functional Dependence
*These are type of constraints on Relations *Express facts about the enterprise that
we are modeling with the database
There is no algorithmic / scientific method of identifying dependency. We have to use our common sense / observation and judgment to specify dependencies.
Dependency Diagram
Name Roll No Phone Major Grade Course
Prof.
Key Attributes
Normalization
*Is
*Is
an attempt Decomposition.
for
Good
Database
Design
using
(U NF)
This is also called a flat file
There
are no composite and multi valued attributes, and describes one property.
STUDENTS Info Sheet Roll No 101 102 101 103 103 101 104 Name Rohit Nath Rohit Martin Martin Rohit Baxter Course CS203 CS303 CS328 CS303 CS503 CS492 CS379 Ph-No 696453 427739 696453 388518 388518 696453 831803 Major Comp. Chemi. Comp. Physics Physics Comp. English Prof. Rajat Bharat Rajat Bharat Shyam Criss Roid Grade A B B A C B C
Roll No Name
Ph No
Major
101
102 103 104
Rohit
Nath Martin Baxter
696453
427739 388518 831803
Comp
Chemi Phy Eng
1. Student ( Roll No, Name, Ph No, Major ) 2. Student_Course ( Roll No, Course, Prof, Grade )
Partial Dependency
*i.e.
non-key attributes are fully functionally dependent on the key attribute(s).
*If the key has more than one attribute then no non-key
*Dependency Diagram
Grade depends on both while Prof is associated fully on course (partial key attribute)
Roll No
Grade
Prof.
Course
Key Attributes
Roll No
Grade
Course
Prof.
This can be solved by means of DECOMPOSITION
Key Attributes
Key Attributes
Key Attributes
Key Attributes
Roll No to Name, Phone and major dependency are being preserved in the STUDENT relation.
Roll no to Course and Grade dependency is being preserved in the RESULT relation
Name
Class work : Hostel info relation Student ( Roll no, Name, Dept., Year, Hostel )
Roll No 1784 1648 1768 1848 1682 1485 Name Rohit Shyam Kiran Maya Gopal Jinu Depart. Physics Chemistry Zoology Geology English Botany Year 1 1 2 2 3 4 Hostel Ganga Ganga Kaveri Kaveri Periyar Nila
Roll No
Name
Dept.
Year
Hostel
1784
1648 1768 1848 1682 1485
Rohit
Shyam Kiran Maya Gopal Jinu
Physics
Chemistry Zoology Geology English Botany
1
1 2 2 3 4
Ganga
Ganga Kaveri Kaveri Periyar Nila
Key Attribute
Non-Key Attributes
Roll No
1784 1648
Name
Rohit Shyam
Dept.
Physics Chemistry
Year
1 1
Hostel
Ganga Ganga
2 2 3 4
Key Attribute
Non-Key Attributes
Dept..
Physics Chemist ry 1768 Kiran Zoology Functionally 1848 Mayadetermines Geology 1682 Gopal English 1485 Jinu Botany
*STUDENT Relation
Student ( Roll No, Name, Dept., Year, Hostel )
Dependency Diagram
Hostel
Redundancy of Data
Roll No 1784 1648 1768 1848 1682 1485 Name Rohit Shyam Kiran Maya Gopal Jinu Depart. Physics Chemistry Zoology Geology English Botany Year 1 1 2 2 3 4 Hostel Ganga Ganga Kaveri Kaveri Periyar Nila
Redundancy of Data
Roll No 1784 1648 1768 1848 Name Rohit Shyam Kiran Maya Depart. Physics Chemistry Zoology Geology English Botany Year 1 1 2 2 3 4 Hostel Ganga Ganga Kaveri Kaveri Periyar Nila
So there will be 1682 Gopal Insertion, Update 1485 Jinu & Delete Anomalies
*The
relation is in 3NF and all attributes in a relation schema are functionally dependent only on the key attribute.
3NF Relations
1. Student_dept (Roll No, Name, Dept., Year)
2. Hostel (Year, Hostel)
3NF
1. Student_dept (Roll No, Name, Depart., Year) 2. Hostel (Year, Hostel)
In 3NF we are eliminating nonkey attribute related functional dependence called Transitive Dependency
* Thank You