Docsity

Understanding Relational Data Model: Entity Sets to Relations and Table Combination, Slides of Database Management Systems (DBMS)

Partial preview of the text

Download Understanding Relational Data Model: Entity Sets to Relations and Table Combination and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

The Relational Data Model

A Relation is a Table

name manf

Snickers M&M/Mars

Twizzlers Hershey

Candies

2

Attributes (column headers)

Tuples (rows)

Why Relations?

• Very simple model.

• Often matches how we think about data.

• Abstract model that underlies SQL, the most

important database language today.

From E/R Diagrams to Relations

• Entity set -> relation.

  • Attributes -> attributes.

• Relationships -> relations whose attributes are

only:

  • The keys of the connected entity sets.
  • Attributes of the relationship itself.

Relationship -> Relation

7

Con- sumers Likes Candies

Likes(consumer, candy)

Favorite

Favorite(consumer, candy)

Married

husband

wife

Married(husband, wife)

name addr name manf

Buddies

Buddies(name1, name2)

Combining Relations

• OK to combine into one relation:

1. The relation for an entity-set E

2. The relations for many-one relationships of

which E is the “many.”

• Example: Consumers(name, addr) and

Favorite(consumer, candy) combine to make

Consumer1(name, addr, favCandy).

Handling Weak Entity Sets

• Relation for a weak entity set must include

attributes for its complete key (including those

belonging to other entity sets), as well as its

own, nonkey attributes.

• A supporting relationship is redundant and

yields no relation (unless it has attributes).

Example

11

Logins At Hosts

name name

Hosts(hostName, location) Logins(loginName, hostName, billTo) At(loginName, hostName, hostName2)

Must be the same

billTo

At becomes part of Logins

location

Example

13

Candies

Choc- olates

isa

name (^) manf

color

Object-Oriented

14

name manf Twizzler Hershey Candies

name manf color Snickers M&M/Mars light Chocolates

Good for queries like “find the color of chocolate candies made by M&M/Mars.”

Using Nulls

16

name manf color Twizzler Hershey NULL Snickers M&M/Mars dark Candies

Saves space unless there are lots

of attributes that are usually NULL.