Date post: | 04-Apr-2018 |
Category: |
Documents |
Upload: | naveen-malhotra |
View: | 219 times |
Download: | 0 times |
of 20
7/31/2019 Unit1_DBMS
1/20
7/31/2019 Unit1_DBMS
2/20
Unit-1
: The data is sorted hierarchically, using a downward tree.This model uses pointers to navigate between stored data. It was the first DBMS model.
: like the hierarchical model, this model uses pointers towardstored data. However, it does not necessarily use a downward tree structure.
( , Relational database management system): The data
is stored in two-dimensional tables (rows and columns). The data is manipulated basedon the relational theory of mathematics. (This model will be studied in detail.)
: Data is represented as a table, but is manipulated using
predicate calculus. ( , object-oriented database management system): the data
is stored in the form of objects, which are structures called classesthat display the datawithin. The fields are instances of these classes
7/31/2019 Unit1_DBMS
3/20
Unit-1
In 3-Layered architecture there are three levels. The three levels of the architecture are threedifferent views of the data:
1. External- individual user view
2. Conceptualor logical- community user view3. Internal- physical or storage view
Three-Schemes Architecture
1. The external level is the view that the individual user of the database
has. This view is often a restricted view of the database and the same database may
7/31/2019 Unit1_DBMS
4/20
Unit-1
a. Storage allocation e.g. B-trees, hashing etc.
b. Access paths e.g. specification of primary and secondary keys, indexes and
pointers and sequencing.c. Miscellaneous e.g. data compression and encryption techniques, optimization ofthe internal structures.
With knowledge about the three-schemes architecture the term data independence can be
explained as followed: Each higher level of the data architecture is immune to changes of thenext lower level of the architecture.
Therefore, the logical scheme may stay unchanged even though the storage space ortype of some data is changed for reasons of optimization or reorganization.
Also the external scheme may stay unchanged for most changes of the logical scheme.This is especially desirable as in this case the application software does not need to bemodified or newly translated.
A relational model database is defined as a database that allows you to group its data items into
one or more independent tables that can be related to one another by using fields common toeach related table.
A relation is usually described as a table, which is organized intorows andcolumns.Thetable below summarizes some of the most important relational database terms and their SQLdatabase equivalents.
http://en.wikipedia.org/wiki/Table_(database)http://en.wikipedia.org/wiki/Row_(database)http://en.wikipedia.org/wiki/Row_(database)http://en.wikipedia.org/wiki/Column_(database)http://en.wikipedia.org/wiki/Column_(database)http://en.wikipedia.org/wiki/Table_(database)http://en.wikipedia.org/wiki/Row_(database)http://en.wikipedia.org/wiki/Column_(database)7/31/2019 Unit1_DBMS
5/20
Unit-1
relation, base relvar tablederived relvar view, query result, result set
tuple row
attribute column
2. Tuples: Each row of data is a tuple.
3. Cardinality: It is defined as the number of tuples in a relation. For example if there is 4 rows ina table, cardinality of this table entity is 4.
4. Degree of a relation: Each column in the tuple is called as an attribute. The number ofattributes in a relation is defined as its degree. For example. If there is four columns(attributes)in a table, its degree will be four.
Entity is a person, place, object, event or concept in the user environment about whichthe organization wishes to maintain data. This is represented by a rectangle in E-R diagrams.
A collection of entities that share common properties or characteristics.
Regular Vs. Weak entity type
Regular Entity: Entity that has its own key attribute (s).e.g.: Employee, student ,customer, policy holder etc.
Weak entity: Entity that depends on other entity for its existence and doesnt have key attribute(s) of its own.
e.g. : spouse of employee.
Difference between Entity Type & Entity Instance:It might help to think of an entity as a thing. So you are asking about a type of thing, and anactual instance of that thing For example one type of thing is a Person Anil P is an instance of a
http://en.wikipedia.org/wiki/Relation_(database)http://en.wikipedia.org/wiki/Relvarhttp://en.wikipedia.org/wiki/Relation_(database)http://en.wikipedia.org/wiki/Relvar7/31/2019 Unit1_DBMS
6/20
Unit-1
Composite attribute: can be split into components
E.g.: Date of joining of the employee can be split into day, month and year.
Composite Vs. Simple Attributes
Composite attributes can be divided intosmaller parts which represent simpleattributes with independent meaning
Simple Attribute: Aircraft -Type
Complex Attribute: Aircraft -Locationwhich is comprised of :
Aircraft -Latitude
Aircraft -Longitude
Aircraft -Altitude
Notation
There is no formal concept of compositeThere is no formal concept of composite
attribute in the relational modelattribute in the relational model
Single Vs Multi-valued AttributesSingle valued : can take on only a single value for each entity instance
e.g.: age of employee. There can be only one value for this.
Multi-valued: can take up many values.
e.g.: skill set of employee
SingleVs. Multivalued Attributes
7/31/2019 Unit1_DBMS
7/20
Unit-1
Derived attribute vs Stored Attributes
Stored Attribute: Attribute that need to be stored permanently.e.g.: name of an employee
Derived Attribute: Attribute that can be calculated based on other attributes.e.g. : years of service of employee can be calculated from date of joining and current date
Derived Vs. Stored Attributes
Some attribute values can be derived from
related attribute values:
Age Date - B-day
Y-Sal 12 * M -Sal
EMPLOYEE
M-sal
B-days Y-sal
Age
NotationNotation
5. Null Values Attributes
NullValuedAttributes
7/31/2019 Unit1_DBMS
8/20
Unit-1
widowed.
2. The domain of the attribute month is having twelve values ranging from January to December.
A relationship type between two entity types defines the set of all associations
between these entity types
Each instance of the relationship between members of these entitytypes is called a relationship instance.e.g if Works-for is the relationship between the Employee entity and the TTI_Department entity,then Rohan works-for CSE_department, Riya works for CS department ..etc are relationship
instances of the relationship, works-for.
Degree of a RelationshipThe number of entity types involved in a relationship is called degree of a relationship.
If One entity type is involved in a relationship, it is called Unary.If two entity type is involved in a relationship, it is called Binary.
If Three entity type is involved in a relationship, it is called Ternary.
e.g: employee manager-of employee is unary.
employee works-for department is binary.customer purchase item, shop keeper is a ternary relationship.
Relationship Degree
The degree of a relationship type isthe number of participating entitytypes 2 entities: Binary Relationship
3entities:TernaryRelationship
BinaryBinary
7/31/2019 Unit1_DBMS
9/20
Unit-1
E.g.:
Employee head-of department (1:1)Lecturer offers course (1:N) assuming a course is taught by a single lecturerStudent enrolls course (M:N)
Possible Cardinality Ratios
1to -1 (1 : 1)
Both entities can
participate in only one
relationship instance
1-to -Many, Many -to -1
(1 : N, N : 1)
One entity can
participate in many
relationship instances Many -to -Many (N: M)
Both entities can participate in
many relationship instance
.
.
.
.
.
.
.11-- toto -- ManyMany
.
.
.
.
.
.
.
ManyMany -- toto --
11
.
.
.
.
.
.
.
.
.
.
.
.
.ManyMany --toto --ManyMany
Representing Cardinality
7/31/2019 Unit1_DBMS
10/20
Unit-1
Employee: partial
Department: total
Representing Participation
Every employee must work for adepartment
Every department must have a managerEvery department must have employees
Not every employee is a manager
N 1
1 1
Each entity type must have an attribute or set of attributes that distinguishes one instancefrom other instances of the same type.
Example: name is Key for Beers
Beers
isa
name manf
7/31/2019 Unit1_DBMS
11/20
Unit-1
Relationship Constraints
What are Relationship Constraints ?
Constraints on the relationship type limit the
possible combination of entities that mayparticipate in the corresponding relationship
set
Kinds of ConstraintsWhat kind of constraints can be defined in the
ER Model?
Cardinality Constraints
Participation Constraints
Together called Structural Constraints
Constraints are represented byConstraints are represented byspecific notation in the ER diagramspecific notation in the ER diagram
7/31/2019 Unit1_DBMS
12/20
Unit-1
Specialization Is the process of defining a set of subclasses of a
superclass
The set of subclasses is based upon some distinguishingcharacteristics of the entities in the superclass
Example: {SECRETARY, ENGINEER, TECHNICIAN}is a specialization of EMPLOYEE based upon job type .
May have several specializations of the same superclass
Example: Another specialization of EMPLOYEE based inmethod of pay is {SALARIED_EMPLOYEE,HOURLY_EMPLOYEE}.
Superclass /subclass relationships and specialization canbe diagrammatically represented in EER diagrams
Attributes of a subclass are called specific attributes.For example, TypingSpeed of SECRETARY
The subclass can participate in specific relationshiptypes. For example, BELONGS_TO of
HOURLY_EMPLOYEE
Example of a Specialization
7/31/2019 Unit1_DBMS
13/20
Unit-1
Generalization
The reverse of the specialization process
Several classes with common features are generalized into
a superclass ; original classes become its subclasses
Example: CAR, TRUCK generalized into VEHICLE; both
CAR, TRUCK become subclasses of the superclass
VEHICLE.
We can view {CAR, TRUCK} as a specialization of VEHICLE
Alternatively, we can view VEHICLE as a generalization of CAR
and TRUCK
Generalization and Specialization
Arrow pointing to the generalized superclass represents ageneralization
Arrows pointing to the specialized subclasses represent aspecialization
7/31/2019 Unit1_DBMS
14/20
Unit-1
Subclasses and Superclasses (1)
An entity type may have additional meaningfulsubgroupings of its entities
Example: EMPLOYEE may be further grouped intoSECRETARY, ENGINEER, MANAGER, TECHNICIAN,
SALARIED_EMPLOYEE, HOURLY_EMPLOYEE, Each of these groupings is a subset of EMPLOYEE entities
Each is called a subclass of EMPLOYEE
EMPLOYEE is the superclass for each of these subclasses
These are called superclass /subclass relationships.
Example: EMPLOYEE/SECRETARY,EMPLOYEE/TECHNICIAN
Modeling Subclasses
Some objects ina class maybe special
define a newclass better: define a subclass
Products
7/31/2019 Unit1_DBMS
15/20
Unit-1
30
Product
name category
price
Is a Is a
Educational ProductSoftware Product
Age Groupplatforms
Subclasses
32
Subclasses to Relations
Product
name category
price
Is a Is a
Educational ProductSoftware Product
Age Groupplatforms
gadget39Toy
photo49Camera
gadget99Gizmo
CategoryPriceName
unixGizmo
platformsName
retiredToy
todlerGizmo
Age GroupName
Product
Sw.Product
Ed.Product
7/31/2019 Unit1_DBMS
16/20
Unit-1
S U M M A R Y O F E R - D I A G R A M
N O T A T I O N F O R E R S C H E M A S
M e a n i n g
E N T IT Y T Y P E
W E A K E N T I T Y T Y P E
R E L A T I O N S H I P T Y P E
I D E N T I F Y I N G R E L A T I O N S H I P T Y P E
A T T R I B U T E
K E Y A T T R I B U T E
M U L T I V A L U E D A T T R I B U T E
C O M P O S IT E A T T R I B U T E
D E R I V E D A T T R I B U T E
T O T A L P A R T IC I P A T IO N O F E2 IN R
C A R D I N A L IT Y R A T IO 1 :N F O R E1:E2 IN R
S y m b o l
E1 R E2
E1 R E2N
7/31/2019 Unit1_DBMS
17/20
Unit-1
Designing an ER Diagram
Consider the following set of requirements for a University database. Design a n ER diagramfor this application:
The university keeps track of each student's name, student number, social securitynumber, current address and phone num ber, permanent address andphon e number,
bir thdate, sex , cla ss (fre shman, graduate) , major departm ent, minor department (if any),degree program (B.A., B.S., ... Ph.D.).Som e user applications need to r efer to the city,state, and zip code of the student's permanent address and to the student's lastname. Both social security number and student number are unique for each student.All students will have at least a major department.
Each department is described by a name, department code, officenumber, office phone,and college.Both the nam e and code have unique values for each department.
Each course has a course name, description, course number, number of credits, level and
offering department.The course number is unique for each course. Each section has an instructor, semester, year, course, and section number.T he section
number distinguishes sections of the same course that are taughtduring the samesemester/year; its value is an integer (1, 2, 3, ... up to the number of sections taughtduring each sem ester).
A grade report must be generated for each student that lists thesection, letter grade, andnumeric grade (0,1,2,3, or 4) for each student and calculates his or her average GPA.
7/31/2019 Unit1_DBMS
18/20
Unit-1
University ER Diagram
Student
Class
StudentID SSN
Sex
Zip
Degree
City
Birth date
State
Name
Address
Department
DName DCode OfficeNumber
OfficePhone
College
Course
CName
CourseDesc
CNumber
Credits
Section
Instructor Year
SemesterSectionNumber
GPA
Numeric Grade
Letter Grade
Grade_Report
Belong_To
Offer
Minor In
Major In
TTI INSTITUTE, SHALIMAR BAGH, ND-88 9582324716 18
7/31/2019 Unit1_DBMS
19/20
Unit-1
TTI INSTITUTE, SHALIMAR BAGH, ND-88 9582324716 19
7/31/2019 Unit1_DBMS
20/20
Unit-1
FIGURE 3.17An ER diagram
for an
AIRLINE
database
schema.
TTI INSTITUTE, SHALIMAR BAGH, ND-88 9582324716 20