Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The Relational Model

Informal Terminology

  • Relation: table
    • Relation Name: name of the table
  • Attribute: column name
  • Tuple/Record: line in the table
  • Domain: set of constants that entries of tuples can take
  • Database Schema: specifying the structure of the database
  • Database Instance: specifying the actual content in the database

Formal Definitions

  • : a countably infinite set of attributes
    • assume is fixed
  • : a total order on
    • the elements of a set of attributes are written according to unless otherwise specified
  • : a countably infinite set of domains (disjoint from )
    • assume is fixed
    • a constant is an element of
    • for most cases, the same domain of values is used for all attributes;
      • otherwise, assume a mapping on , where is a set called the domain of attribute
  • : a countably infinite set of relation names (disjoint from and )
  • : a function from to (the finitary powerset of )
    • is inifinite for each (possibly empty) finite set of attributes
      • which allows multiple relations to have the same set of attributes
    • is called the of a relation name
    • : the of relation name
  • : a relation name or a relation schema
    • Alternative notations:
      • : indicating
      • : indicating
  • : a database schema
    • a nonempty finite set of relation names
    • might be written as

Examples

Table Movies

TitleDirectorActor
AXY

Table Location

TheaterAddressPhone
T1Addr1P1

Table Pariscope

TheaterTitleSchedule
T1A9:00
  • The database schema
  • The sorts of the relation names

Named v.s. Unnamed Attributes/Tuples

Named Perspective

E.g.

a tuple over a finite set of attributes (or over a relation schema ) is a total mapping (viewed as a function) from to .

  • : is a tuple over
  • : the value of on an attribute in ()
  • : the restriction of to a subset , i.e., denotes the tuple over such that for all

Unnamed Perspective

E.g.

a tuple is an ordered n-tuple () of constants (i.e., an element of the Cartesian product )

  • : the -th coordinate of

Correspondence

Because of the total order , a tuple (defined as a function) can be viewed as an ordered tuple with as a first component and as a second component. Ignoring the names, this tuple can be viewed as the ordered tuple .

Conversely, the ordered tuple can be viewed as a function over the set of integers with for each .

Conventional v.s. Logic Programming Relational Model

Conventional Perspective

a relation (instance) over a relation schema is a finite set of tuples with sort .

a database instance of database schema is a mapping with domain , such that is a relation over for each .

Logic Programming Perspective

This perspective is used primarily with the ordered-tuple perspective on tuples.

A fact over is an expression of the form , where for .
If , we sometimes write for .

a relation (instance) over a relation schema is a finite set of facts over .

a database instance of database schema is a finite set that is the union of relation instances over for all .

Examples

Assume .

Named and Conventional

Unnamed and Conventional

Named and Logic Programming

Unnamed and Logic Programming

Variables

an infinite set of variables will be used to range over elements of .

  • a free tuple over or is a function from to
  • an atom over is an expression of the form , where and each term
  • a ground atom is an atom with no variables, i.e., a fact (see Logic Programming Perspective)

Notations

ObjectNotation
Constants
Variables
Sets of Variables
Terms
Attributes
Sets of Attributes
Relation Names
Database Schemas
Tuples
Free Tuples
Facts
Atoms
Relation Instances
Database Instances