Docsity

Data Model - Data Base Management System - Lecture Slides, Slides of Database Management Systems (DBMS)

Partial preview of the text

Download Data Model - Data Base Management System - Lecture Slides and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Relational Data Model

What is a Data Model?

  • A notation for describing data or information
  • Description consists of 3 parts:
    1. Structure of the data -Arrays and structures or objects
    2. Operations on the data -Queries (Operations that retrieve information) -Modifications (Operations that change the database)
    3. Constraints on the data -Limitations

The Relational Model

  • Based on tables
  • The structure portion resemble an array of structs in C
  • Column headers Field names
  • Each row values of struct in the array

An example relation

Title Year Length Genre

Gone With the Wind

1939 231 Drama

Star Wars 1977 124 sciFi

Wayne’s World 1992 95 comedy

Movie data as XML

<Movie title=“Gone With the Wind”> 1939 231 drama <Movie title=“Star Wars”> 1977 124 sciFi <Movie title=“Wayne’s World”> 1992 95 comedy

Other Data Models

  • Object-oriented features

-Values can have structure -Relations can have associated methods

Object-relational model --- which are analogous to the way structs in C were extended to objects in C++

Comparison of Modeling Approaches

  • Relational model provides
    • A simple, limited approach to structuring data, yet is reasonably flexible so anything can be modeled
    • A limited, yet useful, collection of operations on data

Basics of the Relational Model

  • Represent data as a two-dimensional table called a relation

Keys of Relations

  • A set of attributes forms a key for a relation, if we don’t allow two tuples in a relation instance to have the same values in all the attributes of the key
  • Relation Movies has a key consisting of the two attributes title and year
  • Attribute or attributes that form a key for a relation by underlining the key attribute(s).

Movies (title, year, length, genre)

Defining a Relation Schema in SQL

  • SQL (pronounced “sequel”) is the principal language used to describe and manipulate relational databases
  • Two aspects to SQL
  1. Data-Definition  for declaring database schemas
  2. Data-Manipulation  for querying and modifying database

Data Types

  • All attributes must have a data type
  1. Character strings of fixed or varying length CHAR(n)  a fixed-length string of up to n characters OR VARCHAR (n)

Data Types

  1. Bit strings of fixed or varying length

BIT(n) bit strings of length n BIT VARYING(n)  bit strings of length up to n

  1. The type BOOLEAN denotes an attribute whose value is logical
  • The possible values are TRUE, FALSE, and UNKNOWN

Data Types

  1. Dates and times can be represented by the data types DATE and TIME respectively

Simple Table Declarations

CREATE TABLE Movies (

title CHAR(100), year INT, length INT, genre CHAR(10), studioName CHAR(30), producerC# INT

);