next up previous
Next: About this document

Comp 419
Database Design
Final Exam Study Question Answers

Note: these study questions and answers pertain only to material covered since the midterm. The final is comprehensive! See the midterm and study questions for the midterm for more study questions.

  1. Consider a relational database containing relations with the following schemes:
        Customer-scheme = (name, address, cust-num)
        Flyrod-scheme = (manufacture, length, line-weight, flyrod-stock-num)
        Purchased-scheme = (cust-num, flyrod-stock-num, date)
    One of the referential integrity constraints associated with this flyshop database is:

    displaymath47

    1. (5 pts) When a tuple is inserted into purchased, what test needs to be performed to insure that this referential integrity constraint is maintained?

      If the tuple inserted is tex2html_wrap_inline69 , then the test is tex2html_wrap_inline71 .

    2. (5 pts) When a tuple is inserted into customer, what test needs to be performed to insure that this referential integrity constraint is maintained?

      none

  2. A company that manufactures lava lamps uses a relational database to keep track of what parts it has in stock, suppliers of parts, and which suppliers supply what parts. The schemes of these relations are:
      Part-scheme = (part-num, description, groovyness, quantity)
      Supplier-scheme = (supplier-name, address, phone-number)
      Supplies-scheme = (part-num, supplier-name, address, cost)
    The primary key for relations on Part-scheme is part-num, and the primary key for relations on Supplier-scheme is {supplier-name, address}.
    1. (5 pts) What referential integrity constraint should hold between the supplier and supplies relations?

      displaymath48

    2. (5 pts) Is there any referential integrity constraint between the part and supplies relations? Why or why not?

      There is no referential integrity constraint that references part on the left of the tex2html_wrap_inline73 and supplies on the right, because part-num is not the primary key for supplies.

      There is no referential integrity constraint that references part on the right of the tex2html_wrap_inline73 and supplies on the left (even though part-num is the primary key for part), because we only store parts that are in stock, and we may very well keep track of suppliers for parts that aren't in stock. Hence, there is no referential integrity constraint between these two relations.

    3. (5 pts) Give a functional dependency expressing the fact that two different addresses do not share the same phone-number.

      phone-number tex2html_wrap_inline77 address

  3. Now assume that the management of the lava lamp company decides that each supplier can supply at most one kind of part - i.e. that the company will buy at most one kind of part from each supplier, even if that supplier has other kinds of parts. Thus, the company will not have two different kinds of parts in stock that were supplied by the same supplier, and will not even store the information that a supplier has other kinds of parts and could potentially supply these parts.
    1. (5 pts) Under this assumption, if we view supplies as a relationship set from supplier to part (E-R model), what is the mapping cardinality of this relationship set?

      many-to-one

    2. (5 pts) Express your mapping cardinality from the first part of this question as one or more functional dependencies that relations on Supplies-scheme must satisfy.

      supplier-name, address tex2html_wrap_inline77 part-num

  4. (5 pts) Consider a scheme:
     Allparts-scheme = (part-num, description, groovyness, quantity, 
                        supplier-name, address, phone-number, cost)
    and set of functional dependencies on that scheme:
    
     F =  tex2html_wrap_inline81 part-num  tex2html_wrap_inline77  {description, groovyness, quantity},
           {supplier-name, address}  tex2html_wrap_inline77  phone-number tex2html_wrap_inline87  
    
    Is the decomposition of Allparts-scheme into Part-scheme, Supplier-scheme, and Supplies-scheme a lossless-join decomposition? Why or why not?

    Yes. Let:
     Sup-scheme = (part-num, supplier-name, address, phone-number, cost)

    The intersection of Part-scheme and Sup-scheme is part-num, and part-num tex2html_wrap_inline77 Part-scheme. (Easy proof omitted - make sure you include it in a similar situation on the exam.) Hence, decomposing Allparts-scheme into Sup-scheme and Part-scheme is a lossless join decomposition.

    Now decompose Sup-scheme into Supplier-scheme and Supplies-scheme. The intersection of these schemes is {supplier-name, address}, and {supplier-name, address} tex2html_wrap_inline77 Supplier-scheme. (Easy proof omitted.) Hence, this is a lossless join decomposition.

    The result of a sequence of lossless join decompositions is a lossless join decomposition.

  5. Consider the relation scheme tex2html_wrap_inline93 and set of functional dependencies:

    displaymath49

    that relations on scheme R must satisfy.

    1. (2 pts) Which rule or axiom allows us to conclude tex2html_wrap_inline95 from tex2html_wrap_inline97 ?

      decomposition

    2. (2 pts) Which rule or axiom allows us to conclude tex2html_wrap_inline99 from tex2html_wrap_inline101 and tex2html_wrap_inline103 ?

      transitivity

    3. (2 pts) Which rule or axiom allows us to conclude tex2html_wrap_inline105 from tex2html_wrap_inline97 and tex2html_wrap_inline109 ?

      union

    4. (4 pts) Is G a superkey for R? Why or why not?

      tex2html_wrap_inline115 = GABDE

      Thus, G is not a superkey because tex2html_wrap_inline115 tex2html_wrap_inline123 R.

  6. Consider the relation scheme tex2html_wrap_inline93 and set of functional dependencies:

    displaymath50

    that relations on scheme R must satisfy.

    1. (10 pts) Find a lossless join decomposition of R into BCNF.

      Compute tex2html_wrap_inline131 = ABGE

      A is not a superkey and A  tex2html_wrap_inline77  BG is not trivial, so the first decomposition is tex2html_wrap_inline143  = ABG and tex2html_wrap_inline147  = ACDE.

      Consider tex2html_wrap_inline143 . A is clearly a superkey for tex2html_wrap_inline143 , so we compute:

      tex2html_wrap_inline157 = B (trivial)
      tex2html_wrap_inline115 = GE (trivial when restricted to tex2html_wrap_inline143 )
      tex2html_wrap_inline167 = BGE (trivial when restricted to tex2html_wrap_inline143 )

      Thus, tex2html_wrap_inline143 is in BCNF.

      Consider tex2html_wrap_inline147 . Compute:

      tex2html_wrap_inline177 = CDE

      Thus, C is not a superkey for tex2html_wrap_inline147 , and C tex2html_wrap_inline77 D is on tex2html_wrap_inline147 and not trivial. Decompose to produce tex2html_wrap_inline193  = CD and tex2html_wrap_inline197  = ACE.

      Consider tex2html_wrap_inline193 . Clearly C is a superkey for tex2html_wrap_inline193 . Compute:

      D+ = D (trivial)

      Hence, tex2html_wrap_inline193 is in BCNF.

      Consider tex2html_wrap_inline197 . Compute:

      tex2html_wrap_inline131 = ABGE

      Hence, A tex2html_wrap_inline77 E holds, A is not a superkey for tex2html_wrap_inline197 , and A tex2html_wrap_inline77 E is not trivial. Decompose to produce tex2html_wrap_inline235  = AE and tex2html_wrap_inline239  = AC. From closures previously computed and tex2html_wrap_inline243 = E, these schemes are in BCNF. Hence, our decomposition is:

      { tex2html_wrap_inline143 , tex2html_wrap_inline193 , tex2html_wrap_inline235 , tex2html_wrap_inline239 }

    2. (7 pts) Compute tex2html_wrap_inline255 , a canonical cover for F.

      displaymath50

      Use the union rule to produce:

      displaymath52

      If we replace A tex2html_wrap_inline77 BG by A tex2html_wrap_inline77 B, tex2html_wrap_inline131  = AB, so we lose A tex2html_wrap_inline77 G. Hence, G is not extraneous.

      If we replace C tex2html_wrap_inline77 DE by C tex2html_wrap_inline77 D, tex2html_wrap_inline177  = CDE, so we can recover C tex2html_wrap_inline77 DE. Hence, E is extraneous.

      displaymath53

      If we replace CD tex2html_wrap_inline77 E by C tex2html_wrap_inline77 E, we compute tex2html_wrap_inline177  = CDE in tex2html_wrap_inline323 . Hence, C tex2html_wrap_inline77 E is in tex2html_wrap_inline331 , and so D is extraneous.

      displaymath54

      use the union rule to produce:

      displaymath55

      If we replace C tex2html_wrap_inline77 DE by C tex2html_wrap_inline77 D, tex2html_wrap_inline177  = CD, so we can NOT recover C tex2html_wrap_inline77 DE. Hence, E is not extraneous.

      If we replace C tex2html_wrap_inline77 DE by C tex2html_wrap_inline77 E, tex2html_wrap_inline177  = CE, so we can NOT recover C tex2html_wrap_inline77 DE. Hence, D is not extraneous.

      Thus:

      displaymath56

    3. (5 pts) Find a lossless join, dependency preserving decomposition of R into 3NF.

      None of the functional dependencies in the canonical cover is a subset of any other (just looking at the attributes in the f.d.), so step 2 of the algorithm produces: {ABG, CDE, GE}

      Compute closures:

      tex2html_wrap_inline391 = ABGE
      tex2html_wrap_inline395 = CDE
      tex2html_wrap_inline399 = GE

      Thus, no scheme contains a superkey for R (much less a candidate key). However, tex2html_wrap_inline405 = ACBGDE and clearly neither A nor C is a superkey. Hence, AC is a candidate key and our lossless join, dependency preserving 3NF decomposition is: {ABG, CDE, GE, AC}

  7. Consider the relation scheme R = {A, B, C, G} and set of dependencies:

    displaymath57

    that relations on scheme R must satisfy.

    1. (5 pts) Prove that A tex2html_wrap_inline427 G is in tex2html_wrap_inline431 .

      1. A tex2html_wrap_inline427 CG (By A tex2html_wrap_inline427 B and complementation.)
      2. A tex2html_wrap_inline427 C (By A tex2html_wrap_inline77 C and replication.)
      3. A tex2html_wrap_inline427 BG (By 2 and complementation.)
      4. A tex2html_wrap_inline427 G (By 1, 3 and intersection.)
    2. (5 pts) Prove that the decomposition {ABC, AG} is a lossless join decomposition.

      The intersection of these two schemes is A. To show that the decomposition is lossless, it suffices to show A tex2html_wrap_inline427 AG.

      1. A tex2html_wrap_inline427 G (from the previous part.)
      2. A tex2html_wrap_inline427 A (trivial)
      3. A tex2html_wrap_inline427 AG (1, 2, multivalued union)
    3. (10 pts) Find a lossless join decomposition of R into 4NF.

      Compute tex2html_wrap_inline131 = AC. Hence, A is not a superkey for R. Clearly, A tex2html_wrap_inline77 C is not trivial. Decompose into tex2html_wrap_inline143 = AC and tex2html_wrap_inline147 = ABG.

      Consider tex2html_wrap_inline143 . Since A is a superkey for tex2html_wrap_inline143 , and multivalued dependencies with C on the left are all trivial on tex2html_wrap_inline143 (because C tex2html_wrap_inline427 C is trivial and C tex2html_wrap_inline427 A would be trivial on tex2html_wrap_inline143 if it held), this scheme is in 4NF.

      Consider tex2html_wrap_inline147 . From the previous problem, we have A tex2html_wrap_inline427 G and we know that A is not a superkey for tex2html_wrap_inline147 . Since A tex2html_wrap_inline427 G is not trivial for tex2html_wrap_inline147 , decompose into tex2html_wrap_inline193 = AG and tex2html_wrap_inline197 = AB.

      By the reasoning used for tex2html_wrap_inline143 , we can conclude that tex2html_wrap_inline193 and tex2html_wrap_inline197 are in 4NF. Hence, the decomposition is: { tex2html_wrap_inline143 , tex2html_wrap_inline193 , tex2html_wrap_inline197 }.

  8. (10 pts) What kinds of problems associated with relational database design can decomposition help solve? Why does decomposition help?

    Duplication of information and inability to represent information (null values). Appropriate decompositions are needed to achieve normal forms, and the entire point of normal forms is to avoid duplication.

    Decomposition helps with inability to represent information because this problem usually arises from attributes that are not closely related being stored in the same relation. In this case, information for one subset of the attributes will often be available when the associated information for the remaining attributes is not (leading to null values). Decomposition solves this problem by splitting into schemes with only closely related attributes.

  9. (5 pts) Are arbitrary decompositions helpful in designing relation schemes? Why or why not?

    NO! An arbitrary decomposition may be a lossy join decomposition, in which case information is actually lost from the relation! Even if a decomposition is lossless, if the decomposition isn't necessary to achieve a higher level of normalization, then it does not improve the design. In fact, it degrades the design by making querying more expensive (more joins).

  10. (5 pts) Is it possible in general to have two primary indices on the same relation for different search keys? Justify your answer.

    No. In a primary index, the records in the file are stored in sorted order (by the search key). In general, it will not be possible to sort the records by two different search keys simultaneously. Hence, it is not possible in general to have two primary indices on different search keys.

  11. (15 pts) Construct a B tex2html_wrap_inline583 tree for the following key values: (2, 3, 4, 7, 11, 17, 19, 23, 29, 31). Assume that insertions happen in the order that the keys are listed in. You do not need to show the file that the leaves are pointing into - just the B tex2html_wrap_inline583 tree.

    Solution omitted - this question is not from the material for the exam.



next up previous
Next: About this document

Tim Wahls
Thu May 8 11:42:35 EDT 1997