www.android.universityupdates.in | www.universityupdates.in | https://telegram.me/jntuh
UNIT – II
Introduction to the Relational Model: Integrity constraint over relations, enforcing integrity
constraints, querying relational data, logical data base design, introduction to views,
destroying/altering tables and views. Relational Algebra, Tuple relational Calculus, Domain
relational calculus.
1. RELATIONAL MODEL
Relational data model is the most popular data model used widely around the world for data
storage. In this model data is stored in the form of tables.
Relational Model Concepts
Table is also called Relation. Let the below table name be SUDENT_DATA
Attribute / Column / Field
Degree = No of columns = 4
htno Name age city
501 Amar 19 Hyderabad
502 Akbar 18 Warngal Tuple / Row / Record
503 Antony 19 Karimnagar Cardinality = No of rows = 3
Table: In relational model the data is saved in the form of tables. A table has two properties
rows and columns. Rows represent records and columns represent attributes.
Attribute: Each column in a Table is an attribute. Attributes are the properties that define a
relation. e.g., HTNO, NAME, AGE, CITY in the above relation.
Tuple: Every single row of a table is called record or tuple.
Relation Schema: It represents the name of the relation (Table) with its attributes. Eg.,
STUDENT_DATA( htno, name, age, city)
Degree: The total number of attributes in the relation is called the degree of the relation.
Cardinality: Total number of rows present in the Table.
Ravindar.M, Asso.Prof, CSE Dept, JITS-KNR
.android.previousquestionpapers.com | www.previousquestionpapers.com | https://telegram.me/jntuh
,www.android.universityupdates.in | www.universityupdates.in | https://telegram.me/jntuh
2. INTEGRITY CONSTRAINT
Integrity constraints are a set of rules that the database should not violate.
Integrity constraints ensure that authorized changes (update deletion, insertion) made to
the database should not affect data consistency.
Integrity constraints may apply to attribute or to relationships between tables.
TYPES OF INTEGRITY CONSTRAINTS
The integrity constraints supported by DBMS are:
1. Domain Integrity Constraint
2. Entity Integrity Constraint
3. Referential Integrity Constraint
4. Key Constraints
Integrity constraint
Domain Entity Integrity Referential Key
constraint constraint Integrity constraint constraint
Domain Constraint: These are attribute level constraints. An attribute can only take
values which lie inside the domain range. Example: If a constrain AGE > 0 is applied on
STUDENT relation, inserting negative value of AGE will result in failure. If the domain of
AGE is defined as integer, inserting an alphabet in age column is not accepted.
Example: ID NAME SEMESTER AGE
1001 TOM I 18
1002 JHONSON IV 20
1003 KATE VI 21
1004 JHON II 19
1005 MORGAN II A
Not allowed. Because AGE is an integer attribute
Entity integrity constraints: The entity integrity constraint states that primary key
value can't be null. This is because the primary key value is used to identify individual rows
in relation. A table can contain a null value other than the primary key field.
Ravindar.M, Asso.Prof, CSE Dept, JITS-KNR
.android.previousquestionpapers.com | www.previousquestionpapers.com | https://telegram.me/jntuh
,www.android.universityupdates.in | www.universityupdates.in | https://telegram.me/jntuh
Example: Let ID be the primary key in the below table.
ID NAME SEMESTER AGE
1001 TOM I 18
1002 JHONSON IV 20
KATE VI 21
Not allowed. Because primary key can’t be NULL value.
Referential Integrity Constraints: It is also called as foreign key constraint. A
referential integrity constraint is specified between two tables. In this type of constraints,
if a foreign key in Table 2 refers to the Primary Key of Table 1, then every value of the
Foreign Key in Table 2 must be null or be available in Table 1.
Example: Department Table (Table 1)
Primary Key
Dept_No Dept_Name
05 CSE
02 EEE
04 ECE
Primary Key
Relationship
Employee Table (Table 2)
EID NAME AGE Dept_No Foreign Key
1001 TOM 45 04
1002 JHONSON 38 01 Not allowed as Dept_No 01. Because 01
value is not present as a primary key in
1003 KATE 54 05 Table1. Dept_No is a foreign key defined
1004 MORGAN 29 02 in Table2.
Key Constraints: A Key Constraint is a statement that a certain minimal subset of the
fields of a relation is a unique identifier for a tuple. There are 4 types of key constraints.
They are
i. Candidate key: The candidate keys in a table are defined as the set of keys that is
minimal and can uniquely identify any data row in the table.
ii. Primary key: It can uniquely identify any data row of the table. The primary key is
one of the selected candidate key.
iii. Super key: Super Key is the superset of primary key. The super key contains a set of
attributes, including the primary key, which can uniquely identify any data row in the
table.
Ravindar.M, Asso.Prof, CSE Dept, JITS-KNR
.android.previousquestionpapers.com | www.previousquestionpapers.com | https://telegram.me/jntuh
UNIT – II
Introduction to the Relational Model: Integrity constraint over relations, enforcing integrity
constraints, querying relational data, logical data base design, introduction to views,
destroying/altering tables and views. Relational Algebra, Tuple relational Calculus, Domain
relational calculus.
1. RELATIONAL MODEL
Relational data model is the most popular data model used widely around the world for data
storage. In this model data is stored in the form of tables.
Relational Model Concepts
Table is also called Relation. Let the below table name be SUDENT_DATA
Attribute / Column / Field
Degree = No of columns = 4
htno Name age city
501 Amar 19 Hyderabad
502 Akbar 18 Warngal Tuple / Row / Record
503 Antony 19 Karimnagar Cardinality = No of rows = 3
Table: In relational model the data is saved in the form of tables. A table has two properties
rows and columns. Rows represent records and columns represent attributes.
Attribute: Each column in a Table is an attribute. Attributes are the properties that define a
relation. e.g., HTNO, NAME, AGE, CITY in the above relation.
Tuple: Every single row of a table is called record or tuple.
Relation Schema: It represents the name of the relation (Table) with its attributes. Eg.,
STUDENT_DATA( htno, name, age, city)
Degree: The total number of attributes in the relation is called the degree of the relation.
Cardinality: Total number of rows present in the Table.
Ravindar.M, Asso.Prof, CSE Dept, JITS-KNR
.android.previousquestionpapers.com | www.previousquestionpapers.com | https://telegram.me/jntuh
,www.android.universityupdates.in | www.universityupdates.in | https://telegram.me/jntuh
2. INTEGRITY CONSTRAINT
Integrity constraints are a set of rules that the database should not violate.
Integrity constraints ensure that authorized changes (update deletion, insertion) made to
the database should not affect data consistency.
Integrity constraints may apply to attribute or to relationships between tables.
TYPES OF INTEGRITY CONSTRAINTS
The integrity constraints supported by DBMS are:
1. Domain Integrity Constraint
2. Entity Integrity Constraint
3. Referential Integrity Constraint
4. Key Constraints
Integrity constraint
Domain Entity Integrity Referential Key
constraint constraint Integrity constraint constraint
Domain Constraint: These are attribute level constraints. An attribute can only take
values which lie inside the domain range. Example: If a constrain AGE > 0 is applied on
STUDENT relation, inserting negative value of AGE will result in failure. If the domain of
AGE is defined as integer, inserting an alphabet in age column is not accepted.
Example: ID NAME SEMESTER AGE
1001 TOM I 18
1002 JHONSON IV 20
1003 KATE VI 21
1004 JHON II 19
1005 MORGAN II A
Not allowed. Because AGE is an integer attribute
Entity integrity constraints: The entity integrity constraint states that primary key
value can't be null. This is because the primary key value is used to identify individual rows
in relation. A table can contain a null value other than the primary key field.
Ravindar.M, Asso.Prof, CSE Dept, JITS-KNR
.android.previousquestionpapers.com | www.previousquestionpapers.com | https://telegram.me/jntuh
,www.android.universityupdates.in | www.universityupdates.in | https://telegram.me/jntuh
Example: Let ID be the primary key in the below table.
ID NAME SEMESTER AGE
1001 TOM I 18
1002 JHONSON IV 20
KATE VI 21
Not allowed. Because primary key can’t be NULL value.
Referential Integrity Constraints: It is also called as foreign key constraint. A
referential integrity constraint is specified between two tables. In this type of constraints,
if a foreign key in Table 2 refers to the Primary Key of Table 1, then every value of the
Foreign Key in Table 2 must be null or be available in Table 1.
Example: Department Table (Table 1)
Primary Key
Dept_No Dept_Name
05 CSE
02 EEE
04 ECE
Primary Key
Relationship
Employee Table (Table 2)
EID NAME AGE Dept_No Foreign Key
1001 TOM 45 04
1002 JHONSON 38 01 Not allowed as Dept_No 01. Because 01
value is not present as a primary key in
1003 KATE 54 05 Table1. Dept_No is a foreign key defined
1004 MORGAN 29 02 in Table2.
Key Constraints: A Key Constraint is a statement that a certain minimal subset of the
fields of a relation is a unique identifier for a tuple. There are 4 types of key constraints.
They are
i. Candidate key: The candidate keys in a table are defined as the set of keys that is
minimal and can uniquely identify any data row in the table.
ii. Primary key: It can uniquely identify any data row of the table. The primary key is
one of the selected candidate key.
iii. Super key: Super Key is the superset of primary key. The super key contains a set of
attributes, including the primary key, which can uniquely identify any data row in the
table.
Ravindar.M, Asso.Prof, CSE Dept, JITS-KNR
.android.previousquestionpapers.com | www.previousquestionpapers.com | https://telegram.me/jntuh