SlideShare a Scribd company logo
1 of 59
Introduction to
Database Systems
Conceptual Modeling
Werner Nutt
1
Problem
Requirements Analysis
Database Design Goes Through Stages
Data Analysis, Conceptual Design
Logical Database Design
Physical Database Design
DataRequirements
ConceptualSchema
Logical Schema
Physical Schema
2
Conceptual and Logical Design
PERSON
BUYS
PRODUCT
name
price name ssn
Conceptual Model:
Relational Model:
(plus functional
dependencies)
Normalization:
3
4
Toy Example: University Database
Example queries we may want to ask:
• Which are the given and the family name of the student
with student number 5432?
• How many students are enrolled for the course
“Introduction to Databases”?
• For which courses is Georg Egger enrolled?
• Which machine equipment is used for Introduction to
Databases?
5
More Example Queries
• At which school and for which course is Georg Egger
enrolled?
• For which students does Prof. Rossi act as a tutor and at
which times does he meet with his students?
• Is there a professor who is tutoring students that do not
attend any of the professor's courses?
6
University Data Requirements
• A student has a name, which consists of a given name and a family name,
and a student ID. Each student is uniquely identified by his/her student ID.
• A course has a subject and a course ID. For each course, we want to record
the number of students taking that course and the type of equipment being
used for the course. A course is uniquely identified by its course ID.
• A student can be enrolled in an arbitrary number of courses, and an arbitrary
number of students can be enrolled in a course. For each course in which
they are enrolled students receive a lab mark and an exam mark.
• A course cannot exist if there is no student enrolled in it.
• A school is distinguished by the honour's degree that it awards. We also want
to record to which faculty a school belongs. A student is registered with at
most one school, while a school can have an arbitrary number of students.
7
University Data Requirements (cntd.)
• A student is also registered for a year of study. An year of study is identified
by a number between 1 and 4. A student is registered for only one year of
study, but each cohort can have many students.
• For each member of staff we want to record their name and their room
number. A member of staff is identified by the combination of these two
pieces of data. Staff are appraised by other staff. A member of staff has no
more than one appraiser.
• Students can be allocated to a member of staff as their tutor. A student can
have no more than one tutor. The tutor and the student agree upon a time slot
for regular meetings.
• For each year of study, there is one member of staff who acts as the year
tutor. A member of staff can only be responsible for one year of study.
Students can be registered for a year of study.
• Courses are taught by members of staff. A course can have several teachers,
and a staff member can teach several courses.
8
Conceptual Design with the ER Model
The questions to ask:
• What are the entities (= objects, individuals)
in the organization?
• Which relationships exist among the entities?
• What information (= attributes) do we want to store about
these entities and relationships?
• What are the business rules of the organization?
• Which integrity constraints do arise from them?
The answers are represented in an
Entity Relationship Diagram (ER diagram)
Entity: An object distinguishable from other objects
(e.g., an employee)
• An entity is described by a set of attributes.
Examples of entities?
Examples of things that are not entities?
Entity Set/Entity Type: A collection of similar entities
(e.g., all employees)
• All entities in an entity set have the same set of attributes.
• Each attribute has a domain.
• Each entity set has a key
(i.e., one or more attributes whose values
uniquely identify an entity) 9
Entities and Entity Sets/Types
Graphical Representation of Entity Sets
• Entity Sets are drawn as rectangles
• Attributes are drawn using ovals
• Simple attributes contain atomic values
• Composite attributes combine two or more attributes
• Derived attributes are indicated by dashed lines
• The attributes making up the key are underlined
name
given family
STUDENT
studno
no. of
students equip
subject
courseno
COURSE
10
Composite Keys
• Some entities cannot be uniquely identified by the
values of a single attribute …
• … but may be identified by the combination of two or
more attribute values
 several attributes together make up a compound key
STAFF
name
roomno
11
12
Relationships and Relationship Sets/Types
Relationship: An association between two or more entities
(e.g., “Joe Smith” is “enrolled” in “CS123”)
• Relationships may have attributes
Examples of relationships?
Relationship Set/Type: A collection of similar relationships
• An n-ary relationship type relates n entity types E1,…,En
• Each relationship involves n entities e1E1,…,en En
Examples of relationship sets?
An Instance of a Relationship Type
Student Enrolled Course
St1
St2
St3
St5
C1
St4
St6
C2
C3
r1
r4
r3
r2
r5
r6
….
….
….
Student Course
Enrolled
13
Graphical Representation of
Relationship Types
• Relationship sets are drawn as diamonds
How many labmarks can a student have?
exammark
14
labmark
Enrolled
name
given family
STUDENT
studno
no. of
students equip
subject
courseno
COURSE
An entity type can
• participate in several
relationship sets
and
• participate more than once
in one relationship set
(taking on different “roles”)
Which are other examples of recursive relationships?
Roles and Recursive Relationships
STAFF
name
appraiser appraisee
roomno
Appraisal
15
16
Multiplicity (cardinality) of
Relationship Types
• one-one:
• many-one:
• many-many:
1
2
3
a
b
c
d
1
2
3
a
b
c
d
1
2
3
a
b
c
d
1 1
1
Sometimes the letters m, n are used
to indicate the “many” side of
relationships.
17
Participation Constraints
• Participation constraints specify whether or not an entity
must participate in a relationship set
• When there is no participation constraint, it is possible that
an entity will not participate in a relationship set
• When there is a participation constraint, the entity must
participate at least once
• Participation constraints are drawn using a
double line from the entity set to the relationship set
Mandatory Participation
Works_for
St1
St2
St3
St5
D1
St4
St6
D2
D3
r1
r4
r3
r2
r5
r6
….
….
….
1
Staff Department
Works_for
18
Staff Department
Optional and Mandatory Participation
Staff Manages Department
St1
St2
St3
St5
D1
St4
D2
D3
r1
r3
r2
St6
….
….
….
1
Staff Manages Department
19
Many:many Relationship Type
with Optional and Mandatory Participation
Teaches
C1
….
r1
r3
r4
r2
r5
C2
C3
C4
….
r6
….
St1
St2
St3
St4
St5
Staff Course
Staff Teaches Course
20
21
Recursive Relationship Type
with Optional Participation
Staff
St1
St2
St3
St5
St4
St6
r1 Manages
r3
r2
r4
M: Manager
E: Employee
M
M
M
M
E
E
E
E
E
M
unmanaged
r5
….
….
Manages
Staff
Manager Employee
22
Summary: Properties of Relationship Types
Degree
– The number of participating entity types
Cardinality ratios
– The number of instances of each of the participating
entity types which can partake in a single instance of
the relationship type:
1:1, 1:many, many:1, many:many
Participation
– Whether an entity instance has to participate
in a relationship instance
– Represented with a double line
Attributes in ER Modeling
• For every attribute we define
– Domain or data type
– Format, i.e., composite or atomic
– whether it is derived
• Every entity type must have as key an attribute or
a set of attributes
exammark
23
labmark
Enrolled
given family
name
STUDENT
studno
no. of
students equip
subject
courseno
COURSE
24
ER Model of the University DB
YEAR
Reg
year
hons
SCHOOL
faculty
m
n
1
1
1
1
1
exammark
labmark
Enrolled
subject
equip
courseno
COURSE
name
given family
STUDENT
studno
m
n
T
each
slot
Tutor
Y
earReg
YearTutor
STAFF
name
roomno
appraiser appraisee
1 m
Appraisal
25
Exercise: Supervision of PhD Students
A database needs to be developed that keeps track of PhD students:
• For each student store the name and matriculation number.
Matriculation numbers are unique.
• Each student has exactly one address. An address consists of street,
town and post code, and is uniquely identified by this information.
• For each lecturer store the name, staff ID and office number. Staff ID's
are unique.
• Each student has exactly one supervisor. A staff member may
supervise a number of students.
• The date when supervision began also needs to be stored.
26
Exercise: Supervision of PhD Students
• For each research topic store the title and a short description. Titles
are unique.
• Each student can be supervised in only one research topic, though
topics that are currently not assigned also need to be stored in the
database.
Task:
Design an entity relationship diagram that covers the requirements
above. Do not forget to include cardinality and participation
constraints.
Multivalued Attributes
• Students often have more than one phone number (home,
student hall, mobile)
• There is no additional information, other than the number,
we need to store
• This captured by a multivalued attribute
• Notation: double-lined oval
name
given family
STUDENT
studno
phone_no
27
Roles in Non-recursive Relationships
Also in non-recursive relationships we may annotate
relationship links with the roles that entities play in the
relationship
What would be appropriate roles in this example?
name
given family
STUDENT
studno
SUPERVISE
EXAMINE
1
1
m
m
STAFF
name
roomno
28
Multiway (non-binary) Relationship
Relationships can involve more than two entity types…
STAFF
p
29
m
TUTORS
name
given family
STUDENT
studno
COURSE
equip
courseno
STAFF
name
n
roomno
slot
subject
30
Constraints: Definition
• A constraint is an assertion about the database that must
be true at all times
• Constraints are part of the database schema
31
Modeling Constraints
Finding constraints is part of the modeling process.
They reflect facts that hold in the world or
business rules of an organization.
Examples:
Keys: codice fiscale uniquely identifies a person
Single-value constraints: a person can have only one father
Referential integrity constraints: if you work for a company,
it must exist in the database
Domain constraints: peoples’ ages are between 0 and 150
Cardinality constraints: at most 100 students enroll in a course
32
Keys
A key is a set of attributes that
uniquely identify an object or entity:
Person: social-security-number (U.S.)
national insurance number (U.K.)
codice fiscale (Italy)
name
name + address
name + address + dob
(Why not “age”?)
Perfect keys are often hard to find,
so organizations usually invent something.
Do invented keys (e.g., course_id) have drawbacks?
33
Variants of Keys
• Multi-attribute (composite) keys:
– E.g. name + address
• Multiple keys:
– E.g. social-security-number, name + address
34
Existence Constraints
Sometimes, the existence of an entity of type X
depends on the existence of an entity of type Y:
Examples:
• Book chapters presume the existence of a book
• Tracks on a CD presume the existence of the CD
• Orders depend on the existence of a customer
We call Y the dominating entity type and
X the subordinate type

strong and weak entities
Strong and Weak Entities
address
Dominating and subordinate types are modeled as
• Entities
(also “strong”, or “identifying” entities)
and
• Weak entities
customer
ORDER
CUSTOMER
CUST-ORDER
1
m
date
orderid
35
Weak entity
Identifying
entity
Supporting, or
identifying
relationship
36
Strong and Weak Entities
(Identifier Dependency)
address
• A strong entity type has an identifying primary key
• A weak entity’s key comes not (completely) from its own attributes,
but from the keys of one or more entities to which it is linked by a
supporting many-one relationship
• A weak entity type does not have a primary key
but does have a discriminator
customer
ORDER
CUSTOMER
CUST-ORDER
1
m
date
orderid
Weak Entities May Depend on
Other Weak Entities
• Weak entity
• Identifying entity for
LINE_ITEM
• Weak entity type
• Strong entity type
• Identifying entity for
ORDER
• Identifying entity for
LINE_ITEM
1
m
1
CUSTOMER
address
c-name
CUST-ORDER
orderid
date
ORDER
m
LINE_
ITEM quantity
lineno
ORDER-MAKEUP
37
Turning Relationships into Entities
Relationship types are less natural if
• the relationships have many attributes, or
• we want to model a relationship with that relationship type
Example:
exammark
labmark
ENROL
STUDENT COURSE
m n
TUTOR
STAFF
38
39
Association Entity Types
An entity type that represents a relationship type:
• The association entity type is a subordinate type
• The participating entity types become dominating types
• Attributes of the relationship become attributes of the entity
• Relationships with the dominating entity types are
many-one and mandatory
labmark exammark
ENROL
1
m m
COURSE
subject
equip
courseno
1
m
name
given
studno
m
STUDENT
family
STUDENT
STUD_ENROL COURSE_ENROL
TUTOR
How Does This Solve Our Problem?
labmark exammark
ENROL
1
m m
COURSE
subject
equip
courseno
1
m
name
given
studno
m
STUDENT
family
STUDENT
STUD_ENROL COURSE_ENROL
40
STAFF
Association entity types can participate in any
relationship type
41
Design Principles for ER Modeling
There are usually several ways to model a real world concept,
e.g.:
• entity vs. attribute
• entity vs. relationship
• binary vs. ternary relationships, etc.
Design choices can have an impact on
• redundancies among the data that we store
• integrity constraints captured by the database structure
42
“Don’t Say the Same Thing More Than Once”
Redundancy wastes space and encourages inconsistency
Example:
Which is good design,
and which is bad?
Why?
Beer Manf
ManfBy
name addr
name
1
Beer
name manf
Manf
addr
And What About This?
name manf
Beer Manf
ManfBy
name addr
1
43
Entities Vs. Attributes
Sometime it is not clear
• which concepts are worthy of being entities, and
• which are handled more simply as attributes
Example:
Which are the pros and cons of each of
the two designs below?
Beer
name manf
ManfBy
Beer
name
1
Manf
name
44
45
Entity Vs. Attribute: Rules of Thumb
Only make an entity if either:
1. It is more than a name of something; i.e.,
it has non-key attributes or relationships with a number of
different entities, or
2. It is the “many” in a many-one relationship
Entity Vs. Attribute: Example
• Manfs deserves to be an entity because we record addr,
a non-key attribute
• Beers deserves to be an entity because it is at the “many”
end
• If not, we would have to make “set of beers”
an attribute of Manfs
ManfBy
Beer Manf
1
The following design illustrates both points:
name name addr
46
47
Hints for ER Modelling
• Identify entity types by searching for nouns and noun
phrases
• Assume all entities are strong and check for weak ones on
a later pass
• You need an identifier for each strong entity
• Assume all relationships have optional participation and
check for mandatory (total) ones on a later pass
• Expect to keep changing your mind about whether things
are entities, relationships or attributes
• Keep the level of detail relevant and consistent
(for example leave out attributes at first)
• Approach diagram through different views …
… and merge them
48
Use the Schema to Enforce Constraints
• The conceptual schema should enforce
as many constraints as possible
• Don't rely on future data to follow assumptions
Example:
If the university wants to associate only one instructor
with a course,
– don't allow sets of instructors and
– don’t count on departments to enter only one instructor
per course
49
Exercise: A Record Company Database
• A record company wishes to use a computer database to help with its
operations regarding its performers, recordings and song catalogue.
• Songs have a unique song number, a non-unique title and a
composition date. A song can be written by a number of composers;
the composer’s full name is required. Songs are recorded by
recording artists (bands or solo performers). A song is recorded as a
track of a CD. A CD has many songs on it, called tracks. CDs have a
unique record catalogue number, a title and must have a producer
(the full name of the producer is required). Each track must have the
recording date and the track number of the CD.
• A song can appear on many (or no) CDs, and be recorded by many
different recording artists. The same recording artist might re-record
the same song on different CDs. A CD must have only 1 recording
artist appearing on it. CDs can be released a number of times, and
each time the release date and associated number of sales is
required.
50
Superclasses and Subclasses:
The Problem
Suppose we want to model that:
• Students can be either undergraduates or graduates,
and every student belongs to one of these groups
• Among the university employees, there are academic,
administrative, and technical staff
(and there may be others)
• Only undergraduate students have tutors,
which are academics
How can we express this in ER diagrams?
How do we translate such diagrams into relations?
51
Superclasses and Subclasses:
Specialisation and Generalisation
Subclasses and Superclasses
– A subclass entity type is a specialized type of a
superclass entity type
– A subclass entity type represents a subset or
subgrouping of the superclass entity type’s instances
Example: Undergraduates and postgraduates are
subclasses of student
Attribute Inheritance
– Subclasses inherit properties (attributes) of their
superclasses
52
Defining Superclasses and Subclasses
• Specialisation
– The process of defining a set of more specialised entity types of
an entity type
• Generalization
– The process of defining a generalised entity type from a set of
entity types
Two ways to define subclasses:
• Predicate/Condition defined classes
– Entities that are members of a subclass are determined by a
condition on an attribute value. All member instances of the
subclass must satisfy the predicate.
Example: first years and second year students are subclasses of
undergraduates, defined by their year attribute.
• User defined classes
– No condition for determining subclass membership
53
Constraints on Specialisation and
Generalization
Disjointness
• Overlap
– the same entity instance may be a member of more than one
subclass of the specialisation
• Disjoint
– the same entity instance may be a member of only one subclass
of the specialisation
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
Students are Undergraduates or
Postgraduates
d
UNDERGRADUATE POSTGRADUATE
thesis title
year
Tutor
STAFF
1
m
m
name
given
studno
m
STUDENT
family
54
STUDENT
• Undergraduates and
Postgraduates are subclasses
of Student
• The classes of undergraduates
and postgraduates are disjoint
• Every student is in one of either
class
Subclasses of Staff
ACADEMIC
55
ADMIN
STAFF
payroll no name
length of service
level
grade
project

o
TECHNICAL
• Academic, technical,
and admin are three
subclasses of staff
• The three classes
may overlap
56
Subclasses in the University Scenario
• Every person has a name and an address. A person is
uniquely identified by their name.
• At a university, there are two groups of persons,
employees and students. Every employee receives a
salary, while every student pays a fee.
• Among the employees, there is research and teaching
staff. An employee can belong to both groups.
• Among the teaching staff, there are lecturers and tutors. A
tutor works for several courses.
57
Subclasses in the University Scenario
• Every student is either a postgraduate student or an
undergraduate student.
• A postgraduate student has a thesis title, on which he/she
is working.
• An undergraduate student is in the final year, if he/she is
in his/her
3rd year.
• Every final year student is working on a project.
• Every final year student is supervised by a member of the
teaching staff.
58
Subclasses in the University Scenario
O
EMPLOYEE
salary
STUDENT
fee
O d
RESEARCH TEACHING POST
GRAD
UNDER
GRAD
thesis
LECTURER TUTOR
PERSON
name
address
project

FINAL
YEAR
year = 3
SUPERVISOR
courseno
O
59
References
In preparing these slides I have used several sources.
The main ones are the following:
Books:
• A First Course in Database Systems, by J. Ullman and J. Widom
• Fundamentals of Database Systems, by R. Elmasri and S. Navathe
Slides from Database courses held by the following people:
• Enrico Franconi (Free University of Bozen-Bolzano)
• Carol Goble and Ian Horrocks (University of Manchester)

More Related Content

Similar to 3-db-er_3-db-er_3-db-er_3-db-er_3-db-er.pptx

Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)tameemyousaf
 
Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)tameemyousaf
 
Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)tameemyousaf
 
Lies My OO Teacher Told Me
Lies My OO Teacher Told MeLies My OO Teacher Told Me
Lies My OO Teacher Told MeEric Normand
 
Introduction to Database Management Systems
Introduction to Database Management Systems Introduction to Database Management Systems
Introduction to Database Management Systems Reem Sherif
 
Skills a step-by-step_guide_to_a_high_ie
Skills a step-by-step_guide_to_a_high_ieSkills a step-by-step_guide_to_a_high_ie
Skills a step-by-step_guide_to_a_high_ieTrần Cẩm Hồng
 
Partnering Accounting Students with Professionals
Partnering Accounting Students with ProfessionalsPartnering Accounting Students with Professionals
Partnering Accounting Students with ProfessionalsACBSP Global Accreditation
 
Entity relationship model
Entity relationship modelEntity relationship model
Entity relationship modelRUpaliLohar
 
Career Development Workshop: Resume and Cover Letter Basics
Career Development Workshop: Resume and Cover Letter BasicsCareer Development Workshop: Resume and Cover Letter Basics
Career Development Workshop: Resume and Cover Letter Basicslmdejose
 
ER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMSER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMSRubal Sagwal
 
E_R-Diagram (2).pptx
E_R-Diagram (2).pptxE_R-Diagram (2).pptx
E_R-Diagram (2).pptxsandeep54552
 
Portfolio-Assessment.pdf
Portfolio-Assessment.pdfPortfolio-Assessment.pdf
Portfolio-Assessment.pdfLynneSamson1
 
Bioethics Unit Plan
Bioethics Unit PlanBioethics Unit Plan
Bioethics Unit Planhksprague
 
SAGE interview questions for Asst. Professor
SAGE interview questions for Asst. ProfessorSAGE interview questions for Asst. Professor
SAGE interview questions for Asst. Professorkiranrajat
 

Similar to 3-db-er_3-db-er_3-db-er_3-db-er_3-db-er.pptx (20)

Erd
ErdErd
Erd
 
Unit iv dbms
Unit   iv dbmsUnit   iv dbms
Unit iv dbms
 
Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)
 
Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)
 
Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)
 
Chap 7
Chap 7Chap 7
Chap 7
 
Lies My OO Teacher Told Me
Lies My OO Teacher Told MeLies My OO Teacher Told Me
Lies My OO Teacher Told Me
 
Introduction to Database Management Systems
Introduction to Database Management Systems Introduction to Database Management Systems
Introduction to Database Management Systems
 
Skills a step-by-step_guide_to_a_high_ie
Skills a step-by-step_guide_to_a_high_ieSkills a step-by-step_guide_to_a_high_ie
Skills a step-by-step_guide_to_a_high_ie
 
Partnering Accounting Students with Professionals
Partnering Accounting Students with ProfessionalsPartnering Accounting Students with Professionals
Partnering Accounting Students with Professionals
 
Database part3-
Database part3-Database part3-
Database part3-
 
Entity relationship model
Entity relationship modelEntity relationship model
Entity relationship model
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
Career Development Workshop: Resume and Cover Letter Basics
Career Development Workshop: Resume and Cover Letter BasicsCareer Development Workshop: Resume and Cover Letter Basics
Career Development Workshop: Resume and Cover Letter Basics
 
ER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMSER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMS
 
E_R-Diagram (2).pptx
E_R-Diagram (2).pptxE_R-Diagram (2).pptx
E_R-Diagram (2).pptx
 
Portfolio-Assessment.pdf
Portfolio-Assessment.pdfPortfolio-Assessment.pdf
Portfolio-Assessment.pdf
 
Bioethics Unit Plan
Bioethics Unit PlanBioethics Unit Plan
Bioethics Unit Plan
 
1 b class 1
1 b class 11 b class 1
1 b class 1
 
SAGE interview questions for Asst. Professor
SAGE interview questions for Asst. ProfessorSAGE interview questions for Asst. Professor
SAGE interview questions for Asst. Professor
 

More from BUSHRASHAIKH804312

Andrew and Zac RVA-Beyond-Automated-Testing-2016.ppt
Andrew and Zac RVA-Beyond-Automated-Testing-2016.pptAndrew and Zac RVA-Beyond-Automated-Testing-2016.ppt
Andrew and Zac RVA-Beyond-Automated-Testing-2016.pptBUSHRASHAIKH804312
 
Direct infection: virus can infect files every time a user opens that specif...
Direct infection: virus can infect files every time a user  opens that specif...Direct infection: virus can infect files every time a user  opens that specif...
Direct infection: virus can infect files every time a user opens that specif...BUSHRASHAIKH804312
 
1-SoftwareEngineeringandBestPractices.ppt
1-SoftwareEngineeringandBestPractices.ppt1-SoftwareEngineeringandBestPractices.ppt
1-SoftwareEngineeringandBestPractices.pptBUSHRASHAIKH804312
 
knowledge-portal-150406070618-conversion-gate01.pdf
knowledge-portal-150406070618-conversion-gate01.pdfknowledge-portal-150406070618-conversion-gate01.pdf
knowledge-portal-150406070618-conversion-gate01.pdfBUSHRASHAIKH804312
 
chapter5-file system implementation.ppt
chapter5-file system implementation.pptchapter5-file system implementation.ppt
chapter5-file system implementation.pptBUSHRASHAIKH804312
 

More from BUSHRASHAIKH804312 (7)

Andrew and Zac RVA-Beyond-Automated-Testing-2016.ppt
Andrew and Zac RVA-Beyond-Automated-Testing-2016.pptAndrew and Zac RVA-Beyond-Automated-Testing-2016.ppt
Andrew and Zac RVA-Beyond-Automated-Testing-2016.ppt
 
Direct infection: virus can infect files every time a user opens that specif...
Direct infection: virus can infect files every time a user  opens that specif...Direct infection: virus can infect files every time a user  opens that specif...
Direct infection: virus can infect files every time a user opens that specif...
 
1-SoftwareEngineeringandBestPractices.ppt
1-SoftwareEngineeringandBestPractices.ppt1-SoftwareEngineeringandBestPractices.ppt
1-SoftwareEngineeringandBestPractices.ppt
 
Ch4-ControlFlowTesting.ppt
Ch4-ControlFlowTesting.pptCh4-ControlFlowTesting.ppt
Ch4-ControlFlowTesting.ppt
 
knowledge-portal-150406070618-conversion-gate01.pdf
knowledge-portal-150406070618-conversion-gate01.pdfknowledge-portal-150406070618-conversion-gate01.pdf
knowledge-portal-150406070618-conversion-gate01.pdf
 
chapter5-file system implementation.ppt
chapter5-file system implementation.pptchapter5-file system implementation.ppt
chapter5-file system implementation.ppt
 
SQA.ppt
SQA.pptSQA.ppt
SQA.ppt
 

Recently uploaded

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 

Recently uploaded (20)

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 

3-db-er_3-db-er_3-db-er_3-db-er_3-db-er.pptx

  • 2. Problem Requirements Analysis Database Design Goes Through Stages Data Analysis, Conceptual Design Logical Database Design Physical Database Design DataRequirements ConceptualSchema Logical Schema Physical Schema 2
  • 3. Conceptual and Logical Design PERSON BUYS PRODUCT name price name ssn Conceptual Model: Relational Model: (plus functional dependencies) Normalization: 3
  • 4. 4 Toy Example: University Database Example queries we may want to ask: • Which are the given and the family name of the student with student number 5432? • How many students are enrolled for the course “Introduction to Databases”? • For which courses is Georg Egger enrolled? • Which machine equipment is used for Introduction to Databases?
  • 5. 5 More Example Queries • At which school and for which course is Georg Egger enrolled? • For which students does Prof. Rossi act as a tutor and at which times does he meet with his students? • Is there a professor who is tutoring students that do not attend any of the professor's courses?
  • 6. 6 University Data Requirements • A student has a name, which consists of a given name and a family name, and a student ID. Each student is uniquely identified by his/her student ID. • A course has a subject and a course ID. For each course, we want to record the number of students taking that course and the type of equipment being used for the course. A course is uniquely identified by its course ID. • A student can be enrolled in an arbitrary number of courses, and an arbitrary number of students can be enrolled in a course. For each course in which they are enrolled students receive a lab mark and an exam mark. • A course cannot exist if there is no student enrolled in it. • A school is distinguished by the honour's degree that it awards. We also want to record to which faculty a school belongs. A student is registered with at most one school, while a school can have an arbitrary number of students.
  • 7. 7 University Data Requirements (cntd.) • A student is also registered for a year of study. An year of study is identified by a number between 1 and 4. A student is registered for only one year of study, but each cohort can have many students. • For each member of staff we want to record their name and their room number. A member of staff is identified by the combination of these two pieces of data. Staff are appraised by other staff. A member of staff has no more than one appraiser. • Students can be allocated to a member of staff as their tutor. A student can have no more than one tutor. The tutor and the student agree upon a time slot for regular meetings. • For each year of study, there is one member of staff who acts as the year tutor. A member of staff can only be responsible for one year of study. Students can be registered for a year of study. • Courses are taught by members of staff. A course can have several teachers, and a staff member can teach several courses.
  • 8. 8 Conceptual Design with the ER Model The questions to ask: • What are the entities (= objects, individuals) in the organization? • Which relationships exist among the entities? • What information (= attributes) do we want to store about these entities and relationships? • What are the business rules of the organization? • Which integrity constraints do arise from them? The answers are represented in an Entity Relationship Diagram (ER diagram)
  • 9. Entity: An object distinguishable from other objects (e.g., an employee) • An entity is described by a set of attributes. Examples of entities? Examples of things that are not entities? Entity Set/Entity Type: A collection of similar entities (e.g., all employees) • All entities in an entity set have the same set of attributes. • Each attribute has a domain. • Each entity set has a key (i.e., one or more attributes whose values uniquely identify an entity) 9 Entities and Entity Sets/Types
  • 10. Graphical Representation of Entity Sets • Entity Sets are drawn as rectangles • Attributes are drawn using ovals • Simple attributes contain atomic values • Composite attributes combine two or more attributes • Derived attributes are indicated by dashed lines • The attributes making up the key are underlined name given family STUDENT studno no. of students equip subject courseno COURSE 10
  • 11. Composite Keys • Some entities cannot be uniquely identified by the values of a single attribute … • … but may be identified by the combination of two or more attribute values  several attributes together make up a compound key STAFF name roomno 11
  • 12. 12 Relationships and Relationship Sets/Types Relationship: An association between two or more entities (e.g., “Joe Smith” is “enrolled” in “CS123”) • Relationships may have attributes Examples of relationships? Relationship Set/Type: A collection of similar relationships • An n-ary relationship type relates n entity types E1,…,En • Each relationship involves n entities e1E1,…,en En Examples of relationship sets?
  • 13. An Instance of a Relationship Type Student Enrolled Course St1 St2 St3 St5 C1 St4 St6 C2 C3 r1 r4 r3 r2 r5 r6 …. …. …. Student Course Enrolled 13
  • 14. Graphical Representation of Relationship Types • Relationship sets are drawn as diamonds How many labmarks can a student have? exammark 14 labmark Enrolled name given family STUDENT studno no. of students equip subject courseno COURSE
  • 15. An entity type can • participate in several relationship sets and • participate more than once in one relationship set (taking on different “roles”) Which are other examples of recursive relationships? Roles and Recursive Relationships STAFF name appraiser appraisee roomno Appraisal 15
  • 16. 16 Multiplicity (cardinality) of Relationship Types • one-one: • many-one: • many-many: 1 2 3 a b c d 1 2 3 a b c d 1 2 3 a b c d 1 1 1 Sometimes the letters m, n are used to indicate the “many” side of relationships.
  • 17. 17 Participation Constraints • Participation constraints specify whether or not an entity must participate in a relationship set • When there is no participation constraint, it is possible that an entity will not participate in a relationship set • When there is a participation constraint, the entity must participate at least once • Participation constraints are drawn using a double line from the entity set to the relationship set
  • 19. Optional and Mandatory Participation Staff Manages Department St1 St2 St3 St5 D1 St4 D2 D3 r1 r3 r2 St6 …. …. …. 1 Staff Manages Department 19
  • 20. Many:many Relationship Type with Optional and Mandatory Participation Teaches C1 …. r1 r3 r4 r2 r5 C2 C3 C4 …. r6 …. St1 St2 St3 St4 St5 Staff Course Staff Teaches Course 20
  • 21. 21 Recursive Relationship Type with Optional Participation Staff St1 St2 St3 St5 St4 St6 r1 Manages r3 r2 r4 M: Manager E: Employee M M M M E E E E E M unmanaged r5 …. …. Manages Staff Manager Employee
  • 22. 22 Summary: Properties of Relationship Types Degree – The number of participating entity types Cardinality ratios – The number of instances of each of the participating entity types which can partake in a single instance of the relationship type: 1:1, 1:many, many:1, many:many Participation – Whether an entity instance has to participate in a relationship instance – Represented with a double line
  • 23. Attributes in ER Modeling • For every attribute we define – Domain or data type – Format, i.e., composite or atomic – whether it is derived • Every entity type must have as key an attribute or a set of attributes exammark 23 labmark Enrolled given family name STUDENT studno no. of students equip subject courseno COURSE
  • 24. 24 ER Model of the University DB YEAR Reg year hons SCHOOL faculty m n 1 1 1 1 1 exammark labmark Enrolled subject equip courseno COURSE name given family STUDENT studno m n T each slot Tutor Y earReg YearTutor STAFF name roomno appraiser appraisee 1 m Appraisal
  • 25. 25 Exercise: Supervision of PhD Students A database needs to be developed that keeps track of PhD students: • For each student store the name and matriculation number. Matriculation numbers are unique. • Each student has exactly one address. An address consists of street, town and post code, and is uniquely identified by this information. • For each lecturer store the name, staff ID and office number. Staff ID's are unique. • Each student has exactly one supervisor. A staff member may supervise a number of students. • The date when supervision began also needs to be stored.
  • 26. 26 Exercise: Supervision of PhD Students • For each research topic store the title and a short description. Titles are unique. • Each student can be supervised in only one research topic, though topics that are currently not assigned also need to be stored in the database. Task: Design an entity relationship diagram that covers the requirements above. Do not forget to include cardinality and participation constraints.
  • 27. Multivalued Attributes • Students often have more than one phone number (home, student hall, mobile) • There is no additional information, other than the number, we need to store • This captured by a multivalued attribute • Notation: double-lined oval name given family STUDENT studno phone_no 27
  • 28. Roles in Non-recursive Relationships Also in non-recursive relationships we may annotate relationship links with the roles that entities play in the relationship What would be appropriate roles in this example? name given family STUDENT studno SUPERVISE EXAMINE 1 1 m m STAFF name roomno 28
  • 29. Multiway (non-binary) Relationship Relationships can involve more than two entity types… STAFF p 29 m TUTORS name given family STUDENT studno COURSE equip courseno STAFF name n roomno slot subject
  • 30. 30 Constraints: Definition • A constraint is an assertion about the database that must be true at all times • Constraints are part of the database schema
  • 31. 31 Modeling Constraints Finding constraints is part of the modeling process. They reflect facts that hold in the world or business rules of an organization. Examples: Keys: codice fiscale uniquely identifies a person Single-value constraints: a person can have only one father Referential integrity constraints: if you work for a company, it must exist in the database Domain constraints: peoples’ ages are between 0 and 150 Cardinality constraints: at most 100 students enroll in a course
  • 32. 32 Keys A key is a set of attributes that uniquely identify an object or entity: Person: social-security-number (U.S.) national insurance number (U.K.) codice fiscale (Italy) name name + address name + address + dob (Why not “age”?) Perfect keys are often hard to find, so organizations usually invent something. Do invented keys (e.g., course_id) have drawbacks?
  • 33. 33 Variants of Keys • Multi-attribute (composite) keys: – E.g. name + address • Multiple keys: – E.g. social-security-number, name + address
  • 34. 34 Existence Constraints Sometimes, the existence of an entity of type X depends on the existence of an entity of type Y: Examples: • Book chapters presume the existence of a book • Tracks on a CD presume the existence of the CD • Orders depend on the existence of a customer We call Y the dominating entity type and X the subordinate type  strong and weak entities
  • 35. Strong and Weak Entities address Dominating and subordinate types are modeled as • Entities (also “strong”, or “identifying” entities) and • Weak entities customer ORDER CUSTOMER CUST-ORDER 1 m date orderid 35 Weak entity Identifying entity Supporting, or identifying relationship
  • 36. 36 Strong and Weak Entities (Identifier Dependency) address • A strong entity type has an identifying primary key • A weak entity’s key comes not (completely) from its own attributes, but from the keys of one or more entities to which it is linked by a supporting many-one relationship • A weak entity type does not have a primary key but does have a discriminator customer ORDER CUSTOMER CUST-ORDER 1 m date orderid
  • 37. Weak Entities May Depend on Other Weak Entities • Weak entity • Identifying entity for LINE_ITEM • Weak entity type • Strong entity type • Identifying entity for ORDER • Identifying entity for LINE_ITEM 1 m 1 CUSTOMER address c-name CUST-ORDER orderid date ORDER m LINE_ ITEM quantity lineno ORDER-MAKEUP 37
  • 38. Turning Relationships into Entities Relationship types are less natural if • the relationships have many attributes, or • we want to model a relationship with that relationship type Example: exammark labmark ENROL STUDENT COURSE m n TUTOR STAFF 38
  • 39. 39 Association Entity Types An entity type that represents a relationship type: • The association entity type is a subordinate type • The participating entity types become dominating types • Attributes of the relationship become attributes of the entity • Relationships with the dominating entity types are many-one and mandatory labmark exammark ENROL 1 m m COURSE subject equip courseno 1 m name given studno m STUDENT family STUDENT STUD_ENROL COURSE_ENROL
  • 40. TUTOR How Does This Solve Our Problem? labmark exammark ENROL 1 m m COURSE subject equip courseno 1 m name given studno m STUDENT family STUDENT STUD_ENROL COURSE_ENROL 40 STAFF Association entity types can participate in any relationship type
  • 41. 41 Design Principles for ER Modeling There are usually several ways to model a real world concept, e.g.: • entity vs. attribute • entity vs. relationship • binary vs. ternary relationships, etc. Design choices can have an impact on • redundancies among the data that we store • integrity constraints captured by the database structure
  • 42. 42 “Don’t Say the Same Thing More Than Once” Redundancy wastes space and encourages inconsistency Example: Which is good design, and which is bad? Why? Beer Manf ManfBy name addr name 1 Beer name manf Manf addr
  • 43. And What About This? name manf Beer Manf ManfBy name addr 1 43
  • 44. Entities Vs. Attributes Sometime it is not clear • which concepts are worthy of being entities, and • which are handled more simply as attributes Example: Which are the pros and cons of each of the two designs below? Beer name manf ManfBy Beer name 1 Manf name 44
  • 45. 45 Entity Vs. Attribute: Rules of Thumb Only make an entity if either: 1. It is more than a name of something; i.e., it has non-key attributes or relationships with a number of different entities, or 2. It is the “many” in a many-one relationship
  • 46. Entity Vs. Attribute: Example • Manfs deserves to be an entity because we record addr, a non-key attribute • Beers deserves to be an entity because it is at the “many” end • If not, we would have to make “set of beers” an attribute of Manfs ManfBy Beer Manf 1 The following design illustrates both points: name name addr 46
  • 47. 47 Hints for ER Modelling • Identify entity types by searching for nouns and noun phrases • Assume all entities are strong and check for weak ones on a later pass • You need an identifier for each strong entity • Assume all relationships have optional participation and check for mandatory (total) ones on a later pass • Expect to keep changing your mind about whether things are entities, relationships or attributes • Keep the level of detail relevant and consistent (for example leave out attributes at first) • Approach diagram through different views … … and merge them
  • 48. 48 Use the Schema to Enforce Constraints • The conceptual schema should enforce as many constraints as possible • Don't rely on future data to follow assumptions Example: If the university wants to associate only one instructor with a course, – don't allow sets of instructors and – don’t count on departments to enter only one instructor per course
  • 49. 49 Exercise: A Record Company Database • A record company wishes to use a computer database to help with its operations regarding its performers, recordings and song catalogue. • Songs have a unique song number, a non-unique title and a composition date. A song can be written by a number of composers; the composer’s full name is required. Songs are recorded by recording artists (bands or solo performers). A song is recorded as a track of a CD. A CD has many songs on it, called tracks. CDs have a unique record catalogue number, a title and must have a producer (the full name of the producer is required). Each track must have the recording date and the track number of the CD. • A song can appear on many (or no) CDs, and be recorded by many different recording artists. The same recording artist might re-record the same song on different CDs. A CD must have only 1 recording artist appearing on it. CDs can be released a number of times, and each time the release date and associated number of sales is required.
  • 50. 50 Superclasses and Subclasses: The Problem Suppose we want to model that: • Students can be either undergraduates or graduates, and every student belongs to one of these groups • Among the university employees, there are academic, administrative, and technical staff (and there may be others) • Only undergraduate students have tutors, which are academics How can we express this in ER diagrams? How do we translate such diagrams into relations?
  • 51. 51 Superclasses and Subclasses: Specialisation and Generalisation Subclasses and Superclasses – A subclass entity type is a specialized type of a superclass entity type – A subclass entity type represents a subset or subgrouping of the superclass entity type’s instances Example: Undergraduates and postgraduates are subclasses of student Attribute Inheritance – Subclasses inherit properties (attributes) of their superclasses
  • 52. 52 Defining Superclasses and Subclasses • Specialisation – The process of defining a set of more specialised entity types of an entity type • Generalization – The process of defining a generalised entity type from a set of entity types Two ways to define subclasses: • Predicate/Condition defined classes – Entities that are members of a subclass are determined by a condition on an attribute value. All member instances of the subclass must satisfy the predicate. Example: first years and second year students are subclasses of undergraduates, defined by their year attribute. • User defined classes – No condition for determining subclass membership
  • 53. 53 Constraints on Specialisation and Generalization Disjointness • Overlap – the same entity instance may be a member of more than one subclass of the specialisation • Disjoint – the same entity instance may be a member of only one subclass of the specialisation 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
  • 54. Students are Undergraduates or Postgraduates d UNDERGRADUATE POSTGRADUATE thesis title year Tutor STAFF 1 m m name given studno m STUDENT family 54 STUDENT • Undergraduates and Postgraduates are subclasses of Student • The classes of undergraduates and postgraduates are disjoint • Every student is in one of either class
  • 55. Subclasses of Staff ACADEMIC 55 ADMIN STAFF payroll no name length of service level grade project  o TECHNICAL • Academic, technical, and admin are three subclasses of staff • The three classes may overlap
  • 56. 56 Subclasses in the University Scenario • Every person has a name and an address. A person is uniquely identified by their name. • At a university, there are two groups of persons, employees and students. Every employee receives a salary, while every student pays a fee. • Among the employees, there is research and teaching staff. An employee can belong to both groups. • Among the teaching staff, there are lecturers and tutors. A tutor works for several courses.
  • 57. 57 Subclasses in the University Scenario • Every student is either a postgraduate student or an undergraduate student. • A postgraduate student has a thesis title, on which he/she is working. • An undergraduate student is in the final year, if he/she is in his/her 3rd year. • Every final year student is working on a project. • Every final year student is supervised by a member of the teaching staff.
  • 58. 58 Subclasses in the University Scenario O EMPLOYEE salary STUDENT fee O d RESEARCH TEACHING POST GRAD UNDER GRAD thesis LECTURER TUTOR PERSON name address project  FINAL YEAR year = 3 SUPERVISOR courseno O
  • 59. 59 References In preparing these slides I have used several sources. The main ones are the following: Books: • A First Course in Database Systems, by J. Ullman and J. Widom • Fundamentals of Database Systems, by R. Elmasri and S. Navathe Slides from Database courses held by the following people: • Enrico Franconi (Free University of Bozen-Bolzano) • Carol Goble and Ian Horrocks (University of Manchester)