The Relational Data Model - PowerPoint PPT Presentation

About This Presentation
Title:

The Relational Data Model

Description:

Title: CS206 --- Electronic Commerce Author: Jeff Ullman Last modified by: Glenn Wiggins Created Date: 3/23/2002 8:14:09 PM Document presentation format – PowerPoint PPT presentation

Number of Views:67
Avg rating:3.0/5.0
Slides: 17
Provided by: Jeff579
Learn more at: http://sandbox.mc.edu
Category:

less

Transcript and Presenter's Notes

Title: The Relational Data Model


1
The Relational Data Model
  • Tables
  • Schemas
  • Conversion from E/R to Relations

2
A Relation is a Table
  • name manf
  • Corvette G.M.
  • Maxima Nissan
  • cars

3
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.

4
Why Relations?
  • Very simple model.
  • Often matches how we think about data.
  • Abstract model that underlies SQL, the most
    important database language today.

5
From E/R Diagrams to Relations
  • Entity set -gt relation.
  • Attributes -gt attributes.
  • Relationships -gt relations whose attributes are
    only
  • The keys of the connected entity sets.
  • Attributes of the relationship itself.

6
Entity Set -gt Relation
  • Relation cars(model, manf)

model
manf
cars
7
Relationship -gt Relation
name
name
addr
manf
drivers
cars
8
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).

9
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
10
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).

11
Example
name
name
Logins
Hosts
At
location
billTo
Hosts(hostName, location) Logins(loginName,
hostName, billTo) At(loginName, hostName,
hostName2)
12
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 dont belong to them.
  • E/R style One relation for each subclass
  • Key attribute(s).
  • Attributes of that subclass.

13
Example
cars
model
manf
isa
Sports Car
RLR
14
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..
15
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..
16
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.
Write a Comment
User Comments (0)
About PowerShow.com