the relational data model n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
The Relational Data Model PowerPoint Presentation
Download Presentation
The Relational Data Model

Loading in 2 Seconds...

play fullscreen
1 / 16

The Relational Data Model - PowerPoint PPT Presentation


  • 91 Views
  • Uploaded on

The Relational Data Model. Tables Schemas Conversion from E/R to Relations. Attributes (column headers). Tuples (rows). A Relation is a Table. name manf Corvette G.M. Maxima Nissan cars. Schemas. Relation schema = relation name and attribute list.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'The Relational Data Model' - baby


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
the relational data model

The Relational Data Model

Tables

Schemas

Conversion from E/R to Relations

a relation is a table

Attributes

(column

headers)

Tuples

(rows)

A Relation is a Table

name manf

Corvette G.M.

Maxima Nissan

cars

schemas
Schemas
  • Relation schema = relation name and attribute list.
    • Optionally: types of attributes.
    • Example: cars(name, manf) or cars(name: string, manf: string)
  • Database = collection of relations.
  • Database schema = set of all relation schemas in the database.
why relations
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
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.
entity set relation
Entity Set -> Relation

Relation: cars(model, manf)

model

manf

cars

relationship relation

Likes

husband

2

1

Favorite

Mustangdies

Likes(driver, car)

Favorite(driver, car)

wife

Mustangdies(name1, name2)

Married

Married(husband, wife)

Relationship -> Relation

name

name

addr

manf

drivers

cars

combining relations
Combining Relations
  • OK to combine into one relation:
    • The relation for an entity-set E
    • The relations for many-one relationships of which E is the “many.”
  • Example: drivers(name, addr) and Favorite(driver, car) combine to make driver1(name, addr, favcar).
risk with many many relationships

Redundancy

Risk with Many-Many Relationships
  • Combining drivers with Likes would be a mistake. It leads to redundancy, as:

name addr car

Sally 123 Maple Mustang

Sally 123 Maple Maxima

handling weak entity sets
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

Must be the same

At becomes part of

Logins

Example

name

name

Logins

At

Hosts

location

billTo

Hosts(hostName, location)

Logins(loginName, hostName, billTo)

At(loginName, hostName, hostName2)

subclasses three approaches
Subclasses: Three Approaches
  • Object-oriented: One relation per subset of subclasses, with all relevant attributes.
  • Use nulls: One relation; entities have NULL in attributes that don’t belong to them.
  • E/R style: One relation for each subclass:
    • Key attribute(s).
    • Attributes of that subclass.
example1
Example

cars

model

manf

isa

Sports Car

RLR

object oriented
Object-Oriented

name manf

Mustang Nissan

cars

name manf RLR

Corvette G.M. None

Sports

Good for queries like “find the

RLR of Sports Car made by G.M..”

e r style
E/R Style

name manf

Mustang Nissan

Corvette G.M.

Cars

name RLR

Corvette none

Sports Cars

Good for queries like

“find all cars (including

Sports Cars) made by G.M..”

using nulls
Using Nulls

name manf RLR

Mustang Nissan NULL

Corvette G.M. none

cars

Saves space unless there are lots

of attributes that are usually NULL.