Docstoc

Relational Data Model

Document Sample
Relational Data Model Powered By Docstoc
					Relational Data Model
         Lei Li

        CS157B
           What’s a data model?
 Data model is a notation for describing data or information.
 The description generally consists of three parts:
---------------Structure of the data
---------------Operation on the data
---------------Constraints on the data
     The most important data
            models:
 The relational data model
       including object-relational model

 The semistructured-data model
       including XML and related standards
Basics of the relational model
 1. Attributes:
 2. Schemas:
 3. Tuples:
 4. Domains:
 5. constraints
Relational model illustrated
Defining a relation Schema in
             SQL
 SQL (pronounced as “sequel”) is the principal language
   used to describe and manipulate relational database.

 Relations in SQL
 1. stored relation------ tables
 2. views------- relations defined by a computation
 3. Temporary tables----- constructed by the SQL language
   processor when it performs its job of executing queries and
   data modifications. Got thrown away and never stored.
               Data types

 Char
 Bit
 Boolean
 Int
 Float
 Date, Time
             Table declarations
 Create Table table name (
      title CHAR(100),

      year INT,

      length INT,

      genre CHAR(10),

 );
        Simple table

title   year   length   genre
  Modifying relation schemas
 1. drop table R
 2. Alter table movies ADD producer INT;
 3. Alter Table Movies Drop length;
           Relational Algebra
 It’s the data-manipulating aspect of the relational model
 It’s the core of SQL language and every query in SQL
  gets translated to relational algebra.
Overview of relational algebra
 The usual set operations-------- union, intersection,
  difference

 Operations that remove parts of a relation------
  selection, projection

 Operations that combine the tuples of two relations
 ------------cartesian product, natural join, theta join
 Operations called “renaming”

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:4
posted:4/20/2012
language:English
pages:12