1 test1 n = {n: n is an integer and n 0} x = {x: x = n + 5, where n n} y = {y: y = 7 * n - 1,...

Post on 28-Dec-2015

222 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1

Test1

N = {n: n is an integer and n 0}

X = {x: x = n + 5, where n N}

Y = {y: y = 7 * n - 1, where n N}

List the three smallest elements of each set.

N X Y

0 5 -1

1 6 6

2 7 13

2

Test1

N = {n: n is an integer and n 0}

X = {x: x = n + 5, where n N}

Y = {y: y = 7 * n - 1, where n N}

Give the formula of a mapping between X and Y.

The formula cannot contain n.

x = n + 5

n = x – 5

y = 7 * n – 1

= 7 * (x – 5) – 1

= 7x - 36

3

Test1DrivingClass (ClientNo, ClientName, InstructorNo, InstructorName, ClassDate,

ClassTime, CarID)

Which of the following are correct functional dependencies?

CarNo, ClassDate InstructorNo

Yes No

 

InstructorNo, ClassDate, ClassTime CarNo

Yes No

 

InstructorName InstructorNo

Yes No

4

Test1DrivingClass (ClientNo, ClientName, InstructorNo, InstructorName, ClassDate,

ClassTime, CarID)

Which of the following is a candidate key?

CarNo, ClassDate, ClassTime

 

Yes No

 

InstructorNo, ClientNo, ClassDate

Yes No

5

Test1

Branch (Bno, Street, City, State, Tel_No, Fax_No)

Staff (Sno, FirstName, LastName, Address, Tel_No, Bno)

Client (ClientNo, Name, StreetAddress, City, State, Gender)

DrivingClass (ClientNo, Sno, ClassDate, ClassTime, CarID)

Car (CarID, Make, Model, Year, Mileage, LastInspectionDate)

List the client information (ClientNo, Name, Gender) with the instructor information (FirstName, LastName)

for all scheduled driving classes for the current date

that use a 2012 Chevrolet Cruze.

The query must produce correct result for any day without modification.

6

Test1

Branch (Bno, Street, City, State, Tel_No, Fax_No)

Staff (Sno, FirstName, LastName, Address, Tel_No, Bno)

Client (ClientNo, Name, StreetAddress, City, State, Gender)

DrivingClass (ClientNo, Sno, ClassDate, ClassTime, CarID)

Car (CarID, Make, Model, Year, Mileage, LastInspectionDate)

(Client.ClientNo,Name,Gender,FirstName,LastName)

(ClassDate = CurrentDate() and Make = ‘Chevrolet’ and Model = ‘Cruze’ and Year = 2012)

(Client (Staff (DrivingClass Car)))

7

Test1

Branch (Bno, Street, City, State, Tel_No, Fax_No)

Staff (Sno, FirstName, LastName, Address, Tel_No, Bno)

Client (ClientNo, Name, StreetAddress, City, State, Gender)

DrivingClass (ClientNo, Sno, ClassDate, ClassTime, CarID)

Car (CarID, Make, Model, Year, Mileage, LastInspectionDate)

(Client.ClientNo,Name,Gender,FirstName,LastName)

(ClassDate = CurrentDate() and Make = ‘Chevrolet’ and Model = ‘Cruze’ and Year = 2012)

(Client Staff DrivingClass Car)

Cannot Join Client and Staff!

8

Test1Derive table schemas for the following entities with a one-to-many relationship. Use DBDL to specify the table schemas.

E1 E2

A1 B1

A2 B2

A3: composite (A31, A32) B3: composite (B31, B32)

A4 multi-value

PK: (A1, A2) PK: B1

AK: None AK: None

 

E1 (0..1) ----- IsRelatedTo ----- E2 (1..*)

Attribute: C1, C2

9

E1(A1,A2,A31,A32,A4)

PK: A1,A2

AK: NONE

FK: NONE

E2(B1,B2,A1,A2,C1,C2)

PK: B1

AK: NONE

FK: A1,A2 references E1

E2(NewID,B1,B31, B32)

PK: NewID

AK: NONE

FK: B1 references E2

10

Decompose the following relation into 3NF. Assume it is in 1NF.

P (A, B, C, D, E, F)

PK A, B, C

AK: NONE

FK: NONE

Functional Dependencies:

A, B, C All

A E

D F

11

P2(A,E)

PK: A

AK: NONE

FK: NONE

FDs:

A E

P3(D,F)

PK: D

AK: NONE

FK: NONE

FDs:

D F

A E

C80 0

C70 10

D F

9 X

4 Y

12

P2(A,E)

PK: A

AK: NONE

FK: NONE

FDs:

A E

P3(D,F)

PK: D

AK: NONE

FK: NONE

FDs:

D F

A E

C80 0

C80 0

C80 0

C70 10

D F

9 X

9 X

4 Y

4 Y

No Duplicate Records!

13

P (A, B, C, D)

PK A, B, C

AK: NONE

FK: A references P2

D references P3

FDs:

A, B, C All

A B C D

C80 100 10 9

C80 300 20 9

C80 300 10 4

C70 100 20 4

14

Decompose the table into BCNF.

Q (X, Y, Z, U, V, W, Q)

PK: X, Y, Z

AK: U, V, W

Functional Dependencies:

X, Y, Z All

U, V, W All

U, V X

W Q

15

Q2(W,Q)

PK: W

AK: NONE

FK: NONE

FDs:

W Q

Q3(U, V, X)

PK: U, V

AK: NONE

FK: NONE

FDs:

U, V X

W Q

N1 2.5

N2 3.2

N3 3.2

U V X

1 0 80

2 2 70

1 1 80

16

Q (Y, Z, U, V, W)

PK U, V, W

AK: NONE

FK: W references Q2

(U, V) references Q3

FDs:

U, V, W All

Y Z U V W

M14 100 1 0 N1

M14 100 2 2 N2

M14 200 2 2 N3

M14 300 1 1 N1

M14 400 1 0 N2

top related