CS 115 Database SystemsFall 2022, Exams of Database Programming

Functional dependencies and normalization in the context of database systems. It explains the concept of redundancy and how it can make databases brittle. It defines relations and functional dependencies, and provides rules for transitive and trivial dependencies. It also covers keys and superkeys, and provides an example of a split schema. The document concludes with a practice exercise and a decomposition process for achieving BCNF.

Typology: Exams

2022/2023

Available from 03/29/2023

ClemBSC
ClemBSC ๐Ÿ‡บ๐Ÿ‡ธ

3.8

(32)

1.6K documents

1 / 14

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Functional Dependencies
and Normalization
CS 115 Database Systems
Fall 2022
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download CS 115 Database SystemsFall 2022 and more Exams Database Programming in PDF only on Docsity!

Functional Dependencies

and Normalization

CS 115 Database Systems

Fall 2022

Redundancy makes DBs โ€œbrittleโ€

id item price customer email 1 bottled water $1 Katara [email protected] 2 ceiling fan $10 Aang [email protected] 3 bottled water $1 Aang [email protected] 4 sandbags $20 Aang [email protected] 5 matches $5 Aang [email protected] Purchases

Depends on Real-World Semantics

id item price customer email 1 bottled water $1 Katara [email protected] 2 ceiling fan $10 Aang [email protected] 3 bottled water $1 Aang [email protected] 4 sandbags $20 Aang [email protected] 5 matches $5 Aang [email protected] Purchases Is the email address redundant? It depends! ...do we want to know the customerโ€™s current email address, or what the email address was at the time of purchase?

Functional Dependencies

โ— Relations (Tables)

  • (^) R (A, B, C) โ— (^) relation R with attributes A, B, C โ—

Functional Dependencies (FDs)

  • (^) {A, B} โ†’ C โ— (^) {A, B} determines C โ— (^) any rows with the same values for A and B must also have the same values for C
  • (^) e.g., library_card_no โ†’ {patron_name, patron_email, etc.}

Keys and Superkeys

โ— Key

  • (^) Attributes of a relation that functionally determine the rest
  • (^) (We will understand โ€œkeyโ€ to mean a minimal key.) โ— Superkey
  • (^) Set of attributes that contain a key R (A, B, C, D) with A โ†’ B and {A, C} โ†’ D

{A, C} is a key

superkeys include {A, B, C} ; {A, C, D} ; {A, B, C, D} ; {A, C}

Closure

โ—

Functional Dependencies:

  • (^) A โ†’ C
  • (^) B โ†’ D
  • (^) A, D โ†’ E
  • (^) E, F โ†’ G โ—

Closure:

  • (^) {A, B}+
  • (^) The closure of a superkey is all attributes in the relation.

{A, B}

A

B

C

D

E

Example

โ— Functional Dependencies

  • (^) purchase_id โ†’ {item, customer}
  • (^) item โ†’ price
  • (^) customer โ†’ email โ—

Is this split (schema) in BCNF? (Why or why not?)

  • (^) Purchases (purchase_id, item, customer, email)
  • (^) Products (item, price)

Practice

โ— Functional Dependencies

  • (^) film_title โ†’ page_count
  • (^) {film_title, scene_no} โ†’ shoot_date
  • (^) actor_name โ†’ {email, pay_rate} โ— Is this split (schema) in BCNF? (Why or why not?)
  • (^) Actors (actor_name, email, pay_rate)
  • (^) Scenes (film_title, scene_no, shoot_date)
  • (^) ActorsInScenes (film_title, scene_no, actor_name)
  • (^) Scripts (film_title, page_count)

Example

โ—

Attributes:

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

โ—

Functional Dependencies:

A, B โ†’ C

B โ†’ D

A, D โ†’ E, F

Practice

โ—

Attributes:

R (user_name, email, meetup_name, description,

user_name, event_name, time, location, RSVP_limit)

โ—

Functional Dependencies:

user_name โ†’ email

meetup_name โ†’ description, user_name

meetup_name, time, location โ†’ event_name, RSVP_limit