Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

SESSION 4 RELATIONAL MODEL CONCEPTS

1.Table / Relation
RELATIONAL MODELS
2.Tuple / Record
3.Attribute / Column / Field
Relational data model is the primary data
4.Relation Key
model, which is used widely around the
world for data storage and processing. 5.Attribute Domain
6.Relation Schema
Relational model represents the database 7.Relation Instance
as a collection of relations. A relation is
nothing but a table of values. Every row TABLE
in the table represents a collection of
related data values. These rows in the A table has two properties rows and
table denote a real-world entity or columns. Rows represent records and
relationship. columns represent attributes.

CODD’S 12 RULES

• E.F Codd was a Computer Scientist


who invented the Relational model for
Database management. Based on
relational model, the Relational
database was created.
• Codd proposed 13 rules popularly TUPLE
known as Codd's 12 rules to test
DBMS's concept against his relational A single row of a table, which contains a
model. single record.
• Codd's rule actually define what quality
a DBMS requires in order to become a
Relational Database Management
System (RDBMS).

ATTRIBUTE
Each column in a Table. Attributes are the
properties which define a relation.
ATTRIBUTE DOMAIN
A domain is a set of permitted values for an
attribute in table. An attribute cannot accept
values that are outside of their domains.

KEYS
Key plays an important role in relational
database; it is used for identifying unique
rows from table. It also establishes
relationship among tables.
RELATIONAL SCHEMA
TYPES OF KEYS
Represents the name of the relation with its
attributes. • Super Key • Candidate Key •
Primary Key • Alternative /
Alternate Key • Composite Key •
Foreign Key • Non-Key

Super Key - is defined as a set of attributes


within a table that can uniquely identify
each record within a table.
Super Key is a superset of Candidate key.

RELATIONAL INSTANCE TABLE: EMPLOYEE

A finite set of tuples in the RDBMS system.


Relation instances never have duplicate
tuples.

Candidate key - a minimal super key with


no redundant attributes. It is a super key
with no redundant attributes
EM_ID, EM_PhilHealthNum
RELATION KEY
Every row has one, two or multiple
attributes. It is an attribute which can
uniquely identify a particular tuple(row) in a
relation(table).
Primary key - a column or set of columns Three main integrity constraints:
in a table that uniquely identifies tuples
(rows) in that table. It is selected from a set • Key constraints • Domain
of candidate keys. This is done by constraints • Referential integrity
database admin or database designer. constraints

KEY CONSTRAINTS
An attribute that can uniquely identify a
tuple in a relation is called the key of the
table.
The value of the attribute for different tuples
Foreign Key – Foreign keys are the in the relation has to be unique.
columns of a table that points to the
primary key of another table.
AR_ID is the primary key of the AIRLINES
Relation

DOMAIN CONSTRAINTS

OTHER KEYS • Domain constraints can be violated if


an attribute value is not appearing in
Alternate Key – Out of all candidate keys, the corresponding domain or it is not
only one gets selected as primary key, of the appropriate data type.
remaining keys are known as alternate or • Domain constraints specify that within
secondary keys. each tuple, and the value of each
Composite Key – A key that consists of attribute must be unique.
more than one attribute to uniquely identify • This is specified as data types which
rows (also known as records & tuples) in a include standard data types integers,
table is called composite key. real numbers, characters, Booleans,
variable length strings, etc.
Non–Key - attributes are the attributes or
fields of a table, other than candidate key
attributes/fields in a table.

CONSTRAINTS
Relational Integrity Constraints - Every
relation has some conditions that must hold
for it to be a valid relation.
REFERENTIAL INTEGRITY
CONSTRAINTS

• Referential integrity constraints is based


on the concept of Foreign Keys.
• A foreign key is an important attribute of
a relation which should be referred to in
other relationships.
• Referential integrity constraint state
happens where relation refers to a key
attribute of a different or same relation.
However, that key element must exist in • Relational Algebra works on the whole
the table. table at once, so we do not have to use
loops etc. to iterate over all the
rows(tuples) of data one by one.
• It uses operators to perform queries. An
operator can be either unary or binary
• All we have to do is specify the table
name from which we need the data, and
in a single line of command, relational
algebra will traverse the entire given
table to fetch data for you.

QUERY LANGUAGE
• The primary operations that we can
• Relational database systems are perform using relational algebra are: a)
expected to be equipped with a query Select
language that can assist its users to b) Project
query the database instances. c) Union
• There are two kinds of query d) Set Intersection
languages e) Set Different
a) Relational Algebra – Procedural
f) Cartesian product
b) Relational Calculus – Non
g) Rename
Procedural
RELATIONAL ALGEBRA
SELECT
• Relational Algebra is a procedural query
language used to query the database • Select Operator is denoted by sigma (σ)
tables to access data in different ways. and it is used to find the tuples (or rows)
• In relational algebra, input is a relation in a relation (or table) which satisfy the
(table from which data has to be given condition.
accessed) and output is also a relation • Notation: σ Condition (Relation/Table
(a temporary table holding the data name)
asked for by the user).
UNION

PROJECT

• Project operator is denoted by ∏ symbol


and it is used to select desired columns
from a table.
• Notation: ∏ column_name1, ..
column_nameN(table_name)

SET INTERSECTION

• Suppose there are two tuples R and S.


• The set intersection operation contains
all tuples that are in both R & S.
• It is denoted by intersection ∩.
• Notation: R ∩ S
CARTESIAN PRODUCT

• The Cartesian product is used to


combine each row in one table with
each row in the other table.
• It is also known as a cross product.
• It is denoted by X.
• Notation: E X D

SET DIFFERENT

• Suppose there are two tuples R and S.


• The set intersection operation contains
all tuples that are in R but not in S.
• It is denoted by intersection minus (-).
• Notation: R – S RENAME

• Rename (ρ) operation can be used to


rename a relation or an attribute of a
relation.
• It is denoted by rho (ρ).
• Notation: ρ(OLD NAME, NEW NAME)
• EX: ρ(AIRCRAFT, AIRPLANE)

RELATIONAL CALCULUS

• In contrast to Relational Algebra,


Relational Calculus is a non-procedural
query language, that is, it tells what to
do but never explains how to do it.
• It tells the system what data to be
retrieved but doesn’t tell how to retrieve
it.
• Relational calculus exists in two forms:
a) Tuple Relational Calculus (TRC)
b) Domain Relational Calculus
(DRC)
• Tuple relational calculus is used for
selecting those tuples that satisfy the
given condition.
• Notation: {T | P (T)} or {T | Condition
(T)}

Where
a) T is the resulting tuples
b) P(T) is the condition used to
fetch T.

DOMAIN RELATIONAL CALCULUS (DRC)

• In domain relational calculus the


records are filtered based on the
domains.
• The filtering variable uses the domain of
attributes instead of entire tuple values
• It uses logical connectives ∧ (and), ∨
(or) and ┓ (not).
• It uses Existential (∃) and Universal
Quantifiers (∀) to bind the variable.

• Notation: {a1, a2, a3, ..., an | P (a1, a2,


a3, ... ,an)}
Where
a) a1, a2 are attributes
b) P stands for formula built by inner
attributes

You might also like