0% found this document useful (0 votes)
12 views16 pages

DBMS 2

The document provides an overview of the Relational Data Model as proposed by Edgar Frank Codd in 1970, detailing its characteristics, schemas, and constraints. It explains the structure of relations, including the significance of tuples and attributes, as well as various types of relational constraints such as domain, entity integrity, and referential integrity. Additionally, it discusses the operations associated with relations and the implications of foreign key constraints on data integrity.

Uploaded by

dc0xdx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views16 pages

DBMS 2

The document provides an overview of the Relational Data Model as proposed by Edgar Frank Codd in 1970, detailing its characteristics, schemas, and constraints. It explains the structure of relations, including the significance of tuples and attributes, as well as various types of relational constraints such as domain, entity integrity, and referential integrity. Additionally, it discusses the operations associated with relations and the implications of foreign key constraints on data integrity.

Uploaded by

dc0xdx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

CS F212

Database Systems

Prof.R.Gururaj
BITS Pilani CS&IS Dept.
Hyderabad Campus
Relational Data Model & Relational
Constraints (Ch.5 of T1)

Content

1. What is Relational model


2. Characteristics
3. Relational constrains
4. Representation of schemas
5. Operations on relations and constraints

Prof.R.Gururaj CSF 212 Database Systems BITS Pilani, Hyderabad Campus


Relational Model
Edgar Frank Codd proposed Relational Data Model in 1970.
It is a representational or implementation data model.

Using this representational (or implementation) model we


represent a database as collection of relations.

The notion of relation here is different from the notion of


relationship used in ER modeling.

Relation is the main construct for representing data in


relational model.
Every Relation consists of a relation schema and relation
instance.

Prof.R.Gururaj CSF 212 Database Systems BITS Pilani, Hyderabad Campus


R (A1, A2, A3,……,An)
Relation Schema is denoted by
Relation name Attribute list

The number of columns in a relation is known as its degree or arity’.

Relation State (r) of R (thought of as a table)


Each row in the table represents a collection of related data.
Each row contains facts about some entity of some entity-set.

R = (A1, A2, A3,……., An)


r(R) is a set of n tuples in R
r = {t1, t2, t3,…….,tn}
r is an instance of R each t is a tuple and is a ordered list of values.

t = <v1 , v2 ,…, vn > where vi is an element of domain of Ai

Prof.R.Gururaj CSF 212 Database Systems BITS Pilani, Hyderabad Campus


Entities of each type/set are stored as rows in a single relation.

Hence in general, a relation corresponds to a single entity type in


ER diagram.

A row is called a tuple.


The columns of the table represent attributes of that entity type.

The column header is known as attribute or field.


Data type or format of an attribute: is the format of data for that
attribute. Ex. Character strings, numeric, alphanumeric etc.

Values that can appear in a column for any row is called the
domain of that attribute.

Prof.R.Gururaj CSF 212 Database Systems BITS Pilani, Hyderabad Campus


Relational Database Schema is denoted by

S ={R1, R2, ……,Rn}

Database Relations in the


name database (tables)

Prof.R.Gururaj CSF 212 Database Systems BITS Pilani, Hyderabad Campus


Attribute A of relation R is accessed by notation- R.A.

Ex: Student (name, age, branch). Here Student is the relation name.
Student.age - denotes age attribute of Student relation.

Characteristics of a Relation:

❖Ordering of tuples is not significant.

❖Ordering of values in a tuple is important.

❖Values in a tuple under each column must be atomic (simple


& single).

Prof.R.Gururaj CSF 212 Database Systems BITS Pilani, Hyderabad Campus


Prof.R.Gururaj CSF 212 Database Systems BITS Pilani, Hyderabad Campus
Relational Constraints
Constraints are restrictions on data of a relation.

❑Domain level Constrains


✓ Format ( Ex. Character numeric etc.)
✓ Semantic ( Not NULL etc. and range)

❑Entity integrity constraints


✓ Primary key
✓ Unique key
(Super key, Candidate key, Primary key, alternate key)

❑Referential integrity constraints


✓ Foreign key

Prof.R.Gururaj CSF 212 Database Systems BITS Pilani, Hyderabad Campus


Relational Constraints

❑ Functional Dependency
What attributes value defines the value of another
attribute is known as dependency.

This concept is used in database design.

Prof.R.Gururaj CSF 212 Database Systems BITS Pilani, Hyderabad Campus


Referential integrity

The Referential Integrity constraint is specified


between two relations and is used to maintain
consistency among the tuples of two relations.
FK
PK
R1 R2
a b c p q r

c in R1 refers to p in R2

Prof.R.Gururaj CSF 212 Database Systems BITS Pilani, Hyderabad Campus


Referential integrity
The value of FK in a tuple t of R1 either occurs as a
value under p in R2 for some tuple, or is a NULL.

R1 → is known as referencing relation


R2 →is known as referenced relation

Constraints can be specified while defining the structure


& also as triggers.

Prof.R.Gururaj CSF 212 Database Systems BITS Pilani, Hyderabad Campus


Relational Schema
Representation

Prof.R.Gururaj CSF 212 Database Systems BITS Pilani, Hyderabad Campus


Relational Schema
Representation

Prof.R.Gururaj CSF 212 Database Systems BITS Pilani, Hyderabad Campus


Actions need to be taken when FK is set , on operations like
update, insert, and delete. FK
PK
R1 R2
a b c p q r

c in R1 refers to p in R2

If insert a tuple in R1 where the value for c is not in p of R2, then don’t allow.

What if a tuple in R2 is deleted:


Cascade, don’t allow, set to default, set to null.

What if update on R2’s p happens:


Cascade, don’t allow, set to default, set to null.

Prof.R.Gururaj CSF 212 Database Systems BITS Pilani, Hyderabad Campus


Summary
✓ What are basics of relational model
✓ Relation instance
✓ Relational data constraints
✓Referential integrity
✓Relational scheme representation
✓Operations on relations and constraints

Prof.R.Gururaj CSF 212 Database Systems BITS Pilani, Hyderabad Campus

You might also like