The Relational Model

The Relational Model

by Emma Goldenstein -
Number of replies: 0

  • The Relational Model:
    • Used by all major commercial database systems
    • Very simple model
    • Query with high-level languages--simple yet expressive
    • Efficient implementations

 

  • Database = set of named relations (or tables)
    • Each relation has a predefined set of named attributes (or columns)
    • Each tuple (or row) has a value for each attribute.
    • Each attribute has a type (or domain)
      • i.e. ID is an int, Name is a string, GPA is a float, etc.

 

  • Schema-- structural description of relations in database.
    • Set up in advance
    • The framework/empty table(s)
  • Instance-- actual contents at given point in time
    • Change over time
  • Null-- special value for "unknown" or "undefined"
    • Queries might exclude tuples that contain null values
      • E.g. GPA > 3.5 OR GPA <= 3.5 would exclude Craig
  • Key-- attribute whose value is unique in each tuple e.g. ID in the Student table
    • Or set of attributes whose combined values are unique e.g. Name and State in the College Table

 

Student       

 ID

 Name 

 GPA

 Photo 

 123 

 Amy

 3.9

    ☺

 234

 Bob

 3.4

 NULL

 345

 Craig

 NULL 

    ☺

 

   …

 

 

 

College

 Name

 State 

 Enr.

 Stanford 

 CA

 15,000 

 Berkeley 

 CA

 36,000

 MIT

 MA

 10,000

 

  …

 

 

  • Creating relations (tables) in SQL:

      

      > Create Table Student(ID, name, GPA, photo)


      > Create Table College

                   (name string, state char(2), enrollment integer)

 

 

  • Relational Model Summary:
    • Used by all major commercial database systems
    • Very simple model
    • Query with high-level languages: simple yet expressive
    • Efficient implementations