n -ary relations & their applications

6
n-ary Relations & Their Applications

Upload: christine-burt

Post on 01-Jan-2016

32 views

Category:

Documents


2 download

DESCRIPTION

n -ary Relations & Their Applications. n-ary Relations. Let A 1 , A 2 , …, A n be sets. An n -ary relation on these sets is a subset of A 1 x A 2 x … x A n . The A i are called the relation’s domains. Example: Teaching Assignments. Relational Databases. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: n -ary Relations & Their Applications

n-ary Relations & Their Applications

Page 2: n -ary Relations & Their Applications

2

n-ary Relations

• Let A1, A2, …, An be sets.

• An n-ary relation on these sets is a subset of

A1 x A2 x … x An.

• The Ai are called the relation’s domains.

Page 3: n -ary Relations & Their Applications

3

Example: Teaching Assignments

Professor Department Course Number

Cruz Zoology 335

Cruz Zoology 412

Farber Psychology 501

Farber Psychology 617

Grammar Physics 544

Grammar Physics 551

Rosen Computer Science

518

Rosen Mathematics 575

Page 4: n -ary Relations & Their Applications

4

Relational Databases

• A relational database models a database as a relation.

• The relation’s domains are called its attributes.

• The relation’s primary key is an attribute whose value

uniquely determines an element in the relation.

– It is the domain of a function whose co-domain is the Cartesian

product of the other domains.

– In general, a primary key may consist of > 1 attribute.

– What single attribute could serve as the primary key in the Teaching

Assignment table?

Page 5: n -ary Relations & Their Applications

5

Operations on n-ary Relations

• A selection operator defines a subset of R whose elements satisfy some the truth

set of a predicate function

• Let the universe be the set of rows in the Teaching Assignment table (relation).

• Let

– P( x ) mean “the professor = x”

– D( x ) mean “the department = x”

• The Select statement below returns a set of rows or tuples

{ rows | P( Rosen) D( Zoology ) }:

Select Professor = “Rosen” or Department = “Zoology”

selects 4 elements from Teaching Assignments.

Page 6: n -ary Relations & Their Applications

6

To be continued