+ All Categories
Home > Documents > Lecture 5.pptx

Lecture 5.pptx

Date post: 15-Apr-2016
Category:
Upload: saadia-latif
View: 220 times
Download: 0 times
Share this document with a friend
39
Database Systems Abdul Wahid
Transcript

Database SystemsAbdul Wahid

Relationships

Relationships

Relationships are the connections and interactions between the entities instances, e.g., Program and Student ETs are linked

How to identify relationships

Naming Relationships

Up to you If there is no proper name of the association in the

system then participants’ names of abbreviations are used

Naming STUDENT and CLASS have ENROLL

relationship However, it can also be named as STD_CLS

Symbol for Relationships

DEPT EMP

BOOKSTD

Relationships

Relationship type can be identified like an entity type

A relationship type is an abstraction of a relationship

Relationships

Entities involved in a relationship are called its participants

Types of the relationships can be established on the basis of participant ETs

Relationships Types A Binary relationship is the one that links two entity

types e.g. STUDENT-CLASS

Binary Relationship Example

STD COURSE

BOOKSTD

EMPPROJ

Binary Relationships May also have instances, that can be formally described

in an ordered pair form {(S1001, OS), (S1020, DS), (S1002, DS), (S1058, NW)}

Attributes of the Rships

The key The relationships can have their descriptive

attributes Where to place

Attributes of Rships

STD COURSE

GRADE

Ternary Relationships

One that involves three entity types STUDENT-CLASS-FACULTY

Ternary Relationship Examples

STD COURSE

FACULTY

PROJ EMP

SKILL

Ternary Relationships

Instances in ordered triples Example {(S1013, MCS4, Adnan), (S1023, MCS3,

Fasih)}

Unary Relationship An ET linked with itself, also called recursive

relationship Example Roommate, where STUDENT is linked

with STUDENT

Unary Relationship Examples

STD ROOMMATE

EMP CHAIR-PERSON

EMP SPOUSE

Cardinality of Rships

Number of instances of one entity type that can possibly be related to instances of other entity type

Types of Cardinalities

One to oneOne to manyMany to oneMany to many

Types of Cardinalities

DEPT ChairPerson

One to one

EMPDEPTOne to many/ many to one

PROJEMP

PROJEMP

Many to many

Minimum Cardinality

Determines whether the link is compulsory or optional

Important, since it effects the implementation

Cardinality Example

HOBBY

STD

BOOKSTD

COURSE

STD

PROJEMP

Other NotationsBOOKSTD

HOBBYSTD

EMPPROJ

Other NotationsBOOKSTD 1 M

HOBBYSTD 1M

EMPPROJ MM

Other Notations

BOOKSTD 1

EMPPROJ

CHAIRDEPT 11

Roles in Relationships Determine the role ETs play in a relationship Most of the time is clear from the context, like in

STD and COURSE relationship

Roles in Relationships

Two situation when they should be expressed explicitly

A one to one relationship Two ETs having more than one relationship

Roles Examples

COURSESTD ENROLS ENROLLEDBY

ENROLMENT

FACUL-TY HEAD

HEADS

HEADED BY

Roles Examples

FACULTYSTD

STD_TEACH

STD_SUP

Taug

ht By

Supervised

by

Supe

rvise

s

Teaches

Dependencies A type of constraint Existence dependency Identifier dependency Referential Dependency

Existence Dependency

BOOKCOPYBOOK

bkId

bkTitle

bkId

CopyId

Enhancements in E-R Data Model

EE-R Data ModelDifferent proposalsMost common feature is representation of supertypes and subtypes

A popular feature of Object Oriented paradigm

Super/Subtypes Also called generalization/ specialization Supertype is called a General Entity type whereas

subtypes are the specializations

Super/SubtypesPERSON

STD FAC

ST

ST1 ST3ST2

General Entity Types

Specialized Entity Types

Super/SubtypesEMP

SALARIED HOURLY

Grade

AnalSal

NoOfHrs

HourlyRate

Super/SubtypesPERSO

N

STD FAC

StId

CGPA

Qual

GradeClsName

Name

Id

Address


Recommended