5
11/21/2019 Spring 2019 (4) (30%) (a) R(A,B,C,D) has two candidate keys and A is one of them. What are the range of superkeys R may have? CK: (1) A => 8 SK: A, AB, AC, AD, ABC, ABD, ACD, ABCD CK: (2) B => 4 additional SK: B, BC, BD, BCD (contains B but no A) => 12 SK CK: (2) BC => 2 additional SK: BC, BCD (contains BC but no A) => 10 SK CK: (2) BCD => 1 additional SK: BCD (contains BCD but no A) => 9 SK {9, 10, 12} CK: A => 8 SK: A, AB, AC, AD, ABC, ABD, ACD, ABCDE CK: AB => 4 SK: AB, ABC, ABD, ABCD CK: ABC => 2 SK: ABC, ABCD CK: ABCD => 1 SK: ABCD For FD: X -> A, violating conditions Normal Form Violating conditions 2NF X is a part of a CK and A is non- prime 3NF X is not a SK and A is non-prime BCNF X is not a SK (b) List the highest normal forms for the following relations. [i] R(A,B,C,D) {A->D, B->C} L (not in RHS): AB must be in every CK M (both RHS and LHS): R (only in RHS): CD (Not in any CK)

University of Houston–Clear Lakedcm.uhcl.edu/.../csci4333/Fall2019/demo/s3/2019_11_21.docx · Web view11/21/2019 Spring 2019 (4) (30%) (a)R(A,B,C,D) has two candidate keys and A

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

11/21/2019

Spring 2019

(4) (30%)

(a)R(A,B,C,D) has two candidate keys and A is one of them. What are the range of superkeys R may have?

CK: (1) A => 8 SK: A, AB, AC, AD, ABC, ABD, ACD, ABCD

CK: (2) B => 4 additional SK: B, BC, BD, BCD (contains B but no A) => 12 SKCK: (2) BC => 2 additional SK: BC, BCD (contains BC but no A) => 10 SKCK: (2) BCD => 1 additional SK: BCD (contains BCD but no A) => 9 SK

{9, 10, 12}

CK: A => 8 SK: A, AB, AC, AD, ABC, ABD, ACD, ABCDECK: AB => 4 SK: AB, ABC, ABD, ABCDCK: ABC => 2 SK: ABC, ABCDCK: ABCD => 1 SK: ABCD

For FD: X -> A, violating conditions

Normal Form

Violating conditions

2NF

X is a part of a CK and A is non-prime

3NF

X is not a SK and A is non-prime

BCNF

X is not a SK

(b)List the highest normal forms for the following relations.

[i] R(A,B,C,D) {A->D, B->C}

L (not in RHS): AB must be in every CKM (both RHS and LHS): R (only in RHS): CD (Not in any CK)

CK: (1) ABPrime attributes: ABNon-prime: CD

A (a proper subset of a CK) -> D (non-prime): violates 2NFB (a proper subset of a CK) -> C (non-prime): violates 2NF

Highest NF: 1NF

[ii] R(A,B,C,D) {A->D, B->CD}

CK: ABPrime attributes: ABNon-prime: CD

A (a proper subset of a CK) -> D (non-prime): violates 2NFB (a proper subset of a CK) -> C (non-prime): violates 2NFB (a proper subset of a CK) -> D (non-prime): violates 2NF

Highest NF: 1NF

[iii] R(A,B,C,D) {A->D, D->B}

CK: ACprime: ACnon-prime: BD

A (a proper subset of a CK) ->D (non-prime) : violates 2NFD (not a part of a CK) -> B (non-prime): does not violate 2NFD (not a SK) -> B (non-prime): does not violate 3NF

Highest NF: 1NF

[iv] R(A,B,C,D) {A->D, D->BC}[v] R(A,B,C,D) {A->D, D->ABC}

E.g. R(A,B,C,D) {A->D, B->C, C->B}

L: AM: B,CR: D

Potential CK: A, AB, AC, ABCA+: ADAB+: ABDCAC+: ACDB (

CK: (1) AB, (2) ACprime: ABCnon-prime: DA (part of a CK) ->D (non-prime): violates 2NFB (part of a CK, not a SK) -> C (prime): does not violate 3NF; violates BCNFC (part of a CK, not a SK) -> B (prime): does not violate 3NF; violates BCNF

Highest NF: 1NF

(c)It is known that for R(A,B,C,D):

1. R has exactly 4 superkeys.

2. B and C are non-prime attributes.

What are the candidate key(s)?

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

Max number of CK?

CK: (1) AB (unique and minimal) => eliminate 17 subsets of R as CK=> Not a CK: A or B (not unique): 2=> Not a CK: ABC, ABD, …, proper superset of AB (not minimal): 15

CK: (1) A => eliminate: proper supersets of A: 31

CK: (1) ABCDEF => eliminate 63

Xampp apache: default root directory: htdocs of xampp installation (C:\xampp\htdocs)

URL: http://localhost/python/csci4333/Fall2019/s3/hello.html

Mapp to:

Local FS:

C:\xampp\htdocs\python\csci4333\Fall2019\s3\hello.html

URL: http://localhost/python/csci4333/Fall2019/s3/t1.py

Mapp to:

Local FS:

C:\xampp\htdocs\python\csci4333\Fall2019\s3\t1.py