Professional Documents
Culture Documents
Chapter 01 Relational Model & Codd Rules
Chapter 01 Relational Model & Codd Rules
Codd Rules
Relational Model
• A relational database is a collection of relation.
• A relation resembles a “Table” or a “Flatfile” of records.
• Each row in such a table represents a collection of such related data
values
RollNo Name Date_of_Registration
01 ABC 10-02-2013
03 XYZ 10-02-2014
02 SSSS 10-02-2015
Each row is called as tuple and each column is called as attribute of a relation.
Relational Model
• Attribute : Attribute is the name of a column in a table. The attributes
are rollno,name etc. The no. of attributes of a relation is called as
arity (or degree or order of relation).
• No two attributes have a same name.
• Domain : Domain (D) is the set of values of the same data type.
Domain of the attribute is defined as set of allowable values for the
attribute.
• Domain is a set having “homogeneous” members and it is
conceptually similar to the data type concept in programming
language.
Relational Model
• According to the set of values, domain is classified into four
categories
• 1. Simple 2. Application Independent
• 3. Application dependent 4. Composite.
• A domain (D) is said to be simple if all its elements are non-decomposable.
• Application Independent or Atomic domain is the general set of integers, real
numbers or character strings.
• Application dependent domain is having the values permitted in the
database.
• Composite can be specified as a set consisting of non-atomic values.
• Relation: Relations is a collection of homogeneous tuples.
• A relation with n attributes is a subset of Cartesian product of domains of
those attributes.
• e.g. Domain of RollNo(01,02,03)
• Domain of Name(ABC,XYZ,SS)
• Relation Student is subset of Cartesian product of domains of all these
attributes.
• Properties of Relation:
• The relation has a name that is distinct from all other relation names
• Each cell of the relation contain exactly one atomic(not divided) single value.
• Each attribute has a distinct name
• The values of an attribute are no duplicate tuples.
• The order of attributes has no significance
• The order of tuples has no significance
Intension and Extension of Relation
• The structure of relation together with a specification of the domains
and any other restrictions on possible values, is called its intension,
which is usually fixed unless the meaning of the relation is changed to
include additional attributes.
• The tuples are called the extension of the relation which changes
over time.
• Degree of relation: This is defined as no. of attributes it contains.
• Cardinality: The cardinality of relation is the number of tuples it
contains which is also extensions of the relation , which is determine
at a particular instance.
• Relation Schema: It defines the set of attributes of that relation. It is
Denoted by R(A1,A2…An) is made up of relation name R and a list of
attributes A1,A2,…An. Each A1 is the name played in some domain D
in schema R. The domain A1 is denoted by dom(A1)
• Relational Database: A collection of normalized relations with distinct
relation names is called as relational database.
• Integrity Rules: Integrity rules are the constraints or restrictions that apply to
all instances of the database. There are 3 integrity rules
• Entity Integrity Rule : In the base relation, no attribute of a primary key can be NULL
• Referential Integrity Rule : If a foreign key exists in a relation, either the foreign key
value must match a candidate key value of some tuple in its home relation or the
foreign key value must be wholly NULL.
attributes
(or columns)
customer_name customer_street customer_city
customer
Relations are Unordered
● Order of tuples is irrelevant (tuples may be stored in an arbitrary order)
● Example: account relation with unordered tuples
The customer Relation
The depositor Relation
Keys
• Let K ⊆ R
• K is a superkey of R if values for K are sufficient to identify a unique tuple
of each possible relation r(R)
• by “possible r ” we mean a relation r that could exist in the enterprise we are
modeling.
• Example: {customer_name, customer_street} and
{customer_name}
are both superkeys of Customer, if no two customers can possibly have the same
name
• In real life, an attribute such as customer_id would be used instead of customer_name to
uniquely identify customers, but we omit it to keep our examples small, and instead assume
customer names are unique.
Keys
• K is a candidate key if K is minimal
Example: {customer_name} is a candidate key for Customer, since it is a
superkey and no subset of it is a superkey.
• Primary key: a candidate key chosen as the principal means of
identifying tuples within a relation
• Should choose an attribute whose value never, or very rarely, changes.
• E.g. email address is unique, but may change
Foreign Keys
• A relation schema may have an attribute that corresponds to the primary
key of another relation. The attribute is called a foreign key.
• E.g. customer_name and account_number attributes of depositor are foreign keys to
customer and account respectively.
• Only values occurring in the primary key attribute of the referenced relation may
occur in the foreign key attribute of the referencing relation.
• Schema diagram
Codd’s Rules
• Dr. Edgar Frank Codd was a computer scientist working with IBM. He
invented Relational Model for Database Management.
• Codd define 13 rules (0 to 12) and said if DBMS system meets these
rules, it can be called as RDBMS.
• These rules can be applied on a database system that is capable of
managing, storing, and retrieving data from database using its relational
capabilities.
Codd’s Rules
• Rule 0: The Foundation rule: For any system that is advertised as, or claimed
to be, a relational database management system, that system must be able
to manage databases entirely through its relational capabilities.
Codd’s Rules
• Rule 1: The information rule: All information in a relational database is
represented explicitly at the logical level and in exactly one way — by
values in tables.
• Database is logically interpreted in the form of set or related table
• Order of columns in the table doesn’t matter
• Every column in the table must be atomic.
• All the non-key values of the table must be derivable only by Primary key –i.e.
functional dependency.
• Each table showing functional dependency is called normal table- relation hence
Name is given Relational Database Management system.