relationships

7
Muhammad Umair Relationshi ps Oracle Database 11g Developer Track

Upload: umair-shakir

Post on 19-Jan-2017

127 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Relationships

Muhammad Umair

Relationships

Oracle Database 11g Developer Track

Page 2: Relationships

What is a Relation ?› A mathematical definition:

– if A, B are sets, then a relation R is a subset of A x B› A={1,2,3}, B={a,b,c,d},

R = {(1,a), (1,c), (3,b)}

- makes is a subset of Product x Company:1

2

3

a

b

c

d

A=

B=makes Company

Product

Page 3: Relationships

Relation› Relationship

– Relationship is defined as a meaningful association among instance of one or more entities.

– E.g. Students reads for degree, Students passes course, Teacher serve department.

› Degree of Relationship– Number of entities involved in a relationship

› Types of Relationship– Unary Relationship

A relationship among instance of single entities

Page 4: Relationships

Relation– Binary Relationship

A relationship among instance of two entities

– Ternary RelationshipA relationship among instance of three entities.

› Maximum Cardinality– If and b are two associated entities then maximum cardinality of

A will be the maximum number of instance of A that can be associated with a single instance of B.

– Maximum cardinality can be either “one” or “many”

Page 5: Relationships

Relation› Minimum Cardinality

– If and b are two associated entities then minimum cardinality of A will be the minimum number of instance of A that can be associated with a single instance of B.

– minimum cardinality can be either “zero” or “one”› Types of Relationship on the basis of Maximum Cardinality

– One-to-One Relationship› A relationship having cardinality “one” on both sides

– One-to-Many Relationship› A relationship having cardinality “one” on one side and “many” on other

side– Many-to-Many Relationship

› A relationship having cardinality “many” on both sides

Page 6: Relationships

Multiplicity of E/R Relations› one-one:

› many-one

› many-many

123

abcd

123

abcd

123

abcd

Page 7: Relationships

address name ssn

Person

buys

makes

employs

CompanyProduct

name category

stockprice

name

price