Databases Week 1 – Relational Model
Table entries are values that conform
to some data type
-Examples of SQL data types:
Strings
Numbers
bit, int, float
numeric, decimal number
Binary data
Gender, Heads or Tails
Date and Time
datetime, timestamp
Data Types and Domains
The domain dom(D) of a type D is the set of possible values.
dom(Int) = {-2134567898,…,2134567898}
dom(numeric(2,0)) = {-99,…,99}
SQL allows us to define application-specific domains as subsets of
standard data types: create domain ExampleDomain as numeric(2,0).
We may even add constraints:
create domain ExampleDomain as numeric(2,0) check(value > 0)
Domains are useful to document that 2 columns represent the same kind
of objects and that comparisons are meaningful.
, Relation schema
A relation schema s (of a single relation) defines:
A (finite) sequence A1,…,An of distinct attribute names
For each attribute A1 a data type (or domain) Di
A relation schema can be written as:
s = (A1 : D1, … , An : Dn)
Relational Database Schema
A relational database schema S defines:
A finite set of relation names {R1,…,Rm}
A relation schema schema(Ri) for every relation Ri
A set of integrity constraints C
in summary, S = ({R1, … , Rm}, schema, C)
“relation names: {Students, Exercises, Results}
relation schema for every relation name:
Students(SiD, first, last, address)
Exercises(category, number, topic, maxPoints)
Results(SiD, category, number, points)
Examples of integrity constraints: keys and foreign keys.
Schema = describes structure of database
States = actual content at a specific moment
Database States: Tuples
Tuples are used to formalize table rows.
A tuple t with respect to relation schema
is a sequence t = (d1,…,dn) of values such that di ∈ dom(Di)
So other words: t ∈ dom(D1) x … x dom(Dn).
Thus: (‘2709501’, ‘Simon’, ‘van Rens’, ‘Ouderkerk’) is a tuple in a table.
So if (‘2709501’, ‘Simon’, ‘van Rens’, ‘Ouderkerk’).name = ‘Simon’.
Database state I
2
Table entries are values that conform
to some data type
-Examples of SQL data types:
Strings
Numbers
bit, int, float
numeric, decimal number
Binary data
Gender, Heads or Tails
Date and Time
datetime, timestamp
Data Types and Domains
The domain dom(D) of a type D is the set of possible values.
dom(Int) = {-2134567898,…,2134567898}
dom(numeric(2,0)) = {-99,…,99}
SQL allows us to define application-specific domains as subsets of
standard data types: create domain ExampleDomain as numeric(2,0).
We may even add constraints:
create domain ExampleDomain as numeric(2,0) check(value > 0)
Domains are useful to document that 2 columns represent the same kind
of objects and that comparisons are meaningful.
, Relation schema
A relation schema s (of a single relation) defines:
A (finite) sequence A1,…,An of distinct attribute names
For each attribute A1 a data type (or domain) Di
A relation schema can be written as:
s = (A1 : D1, … , An : Dn)
Relational Database Schema
A relational database schema S defines:
A finite set of relation names {R1,…,Rm}
A relation schema schema(Ri) for every relation Ri
A set of integrity constraints C
in summary, S = ({R1, … , Rm}, schema, C)
“relation names: {Students, Exercises, Results}
relation schema for every relation name:
Students(SiD, first, last, address)
Exercises(category, number, topic, maxPoints)
Results(SiD, category, number, points)
Examples of integrity constraints: keys and foreign keys.
Schema = describes structure of database
States = actual content at a specific moment
Database States: Tuples
Tuples are used to formalize table rows.
A tuple t with respect to relation schema
is a sequence t = (d1,…,dn) of values such that di ∈ dom(Di)
So other words: t ∈ dom(D1) x … x dom(Dn).
Thus: (‘2709501’, ‘Simon’, ‘van Rens’, ‘Ouderkerk’) is a tuple in a table.
So if (‘2709501’, ‘Simon’, ‘van Rens’, ‘Ouderkerk’).name = ‘Simon’.
Database state I
2