0% found this document useful (0 votes)
13 views3 pages

Relations2 QA

Relation and application

Uploaded by

usmanjavedist07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Relations2 QA

Relation and application

Uploaded by

usmanjavedist07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ICS 241: Discrete Mathematics II (Spring 2015)

9.2 n-ary Relations and Their Applications


n-ary Relations
Definition: Let A1 , A2 , ..., An be sets. An n-ary relation on these sets is a subset of A1 × A2 ×
... × An . The sets A1 , A2 , ..., An are called the domains of the relation, and n is called its degree.

Primary Key
Definition: A domain of an n-ary relation is called a primary key when the value of the n-tuple
from this domain determines the n-tuple.

Composite Key
Definition: Combinations of domains can also uniquely identify n-tuples in an n-ary relation.
When the values of a set of domains determine an n-tuple in a relation, the Cartesian product of
these domains is called a composite key.

Selection
Definition: Let R be an n-ary relation and C a condition that elements in R may satisfy. Then the
selection operator SC maps the n-ary relation R to the n-ary relation of all n-tuples from R that
satisfy the condition C.

Projection
Definition: The projection Pi1 i2 ,...,im where i1 < i2 < ... < im , maps the n-tuple (a1 , a2 , ..., an ) to
the m-tuple (ai1 , ai2 , ..., aim ), where m ≤ n.

Join
Definition: Let R be a relation of degree m and S a relation of degree n. The join Jp (R, S), where
p ≤ m and p ≤ n, is a relation of degree m + n − p that consists of all (m + n − p)-tuples
(a1 , a2 , ..., am−p , c1 , c2 , ..., cp , b1 , b2 , ..., bn−p ), where the m-tuple (a1 , a2 , ..., am−p , c1 , c2 , ..., cp ) be-
longs to R and the n-tuple (c1 , c2 , ..., cp , b1 , b2 , ..., bn−p ) belongs to S.

9.2 pg. 589 # 7


The 3-tuples in a 3-ary relation represent the following attributes of a student database: student ID
number, name, phone number.

a Is student ID number likely to be a primary key?


Yes because a student ID number is unique in a system.

b Is name likely to be a primary key?


No because multiple students can have the same name.

1
ICS 241: Discrete Mathematics II (Spring 2015)

c Is phone number likely to be a primary key?


No because we can have students that have the same phone number, such as two siblings
having the same home phone number.

9.2 pg. 589 # 9


The 5-tuples in a 5-ary relation represent these attributes of all people in the United States: name,
Social Security number, street address, city, and state.

a Determine a primary key for this relation.


Social security number because it is unique.

b Under what conditions would (name, street address) be a composite key?


When we do not have people that has the same street address and have the same names.

c Under what conditions would (name, street address, city) be a composite key?
Same as above because many people can live in the same city.

9.2 pg. 590 # 11


What do you obtain when you apply the selection operator SC , where C is the condition Destina-
tion = Detroit, to the database in Table 8?

Table 8 Flights

Airline Flight number Gate Destination Departure time


Nadir 122 34 Detroit 08:10
Acme 221 22 Denver 08:17
Acme 122 33 Anchorage 08:22
Acme 323 34 Honolulu 08:30
Nadir 199 13 Detroit 08:47
Acme 222 22 Denver 09:10
Nadir 322 34 Detroit 09:44

{(Nadir, 122, 34, Detroit, 08:10), (Nadir, 199, 13, Detroit, 08:47), (Nadir, 322, 34, Detroit, 09:44)}

9.2 pg. 590 # 13


What do you obtain when you apply the selection operator SC , where C is the condition (Airline
= Nadir) ∨ (Destination = Denver), to the database in Table 8?

{(Nadir, 122, 34, Detroit, 08:10), (Acme, 221, 22, Denver, 08:17), (Nadir, 199, 13, Detroit, 08:47),
(Acme, 222, 22, Denver, 09:10), (Nadir, 322, 34, Detroit, 09:44)}

2
ICS 241: Discrete Mathematics II (Spring 2015)

9.2 pg. 590 # 17


Display the table produced by applying the projection P1,4 to Table 8.

Airline Destination
Nadir Detroit
Acme Denver
Acme Anchorage
Acme Honolulu

9.2 pg. 590 # 19


Construct the table obtained by applying the join operator J2 to the relations in Tables 9 and 10.

Table 9 Part needs Table 10 Part inventory

Supplier Part number Project Part number Project Quantity Color code
23 1092 1 1001 1 14 8
23 1101 3 1092 1 2 2
23 9048 4 1101 3 1 1
31 4975 3 3477 2 25 2
31 3477 2 4975 3 6 2
32 6984 4 6984 4 10 1
32 9191 2 9048 4 12 2
33 1001 1 9191 2 80 4

Supplier Part number Project Quantity Color code


23 1092 1 2 2
23 1101 3 1 1
23 9048 4 12 2
31 4975 3 6 2
31 3477 2 25 2
32 6984 4 10 1
32 9191 2 80 4
33 1001 1 14 8

You might also like