Unit 3 The Relational Data Model and Relational Database Constraints bitinfoNepal
Unit 3 The Relational Data Model and Relational Database Constraints bitinfoNepal
Referential Integrity Constraint: Referential Integrity Constraint ensures that there must always exist a
valid relationship between two relational database tables. This valid relationship between the two tables
confirms that a foreign key exists in a table. It should always reference a corresponding value or attribute
in the other table or be null.
Example: Consider an Employee and a Department table where Dept_ID acts as a foreign key between
the two tables
Employees Table
Department Table
Dept_ID Dept_Name
1 Sales
2 HR
3 Technical
In the above example, Dept_ID acts as a foreign key in the Employees table and a primary key in the
Department table. Row having DeptID=4 violates the referential integrity constraint since DeptID 4 is not
defined as a primary key column in the Departments table.
Example: Consider a Student's table having Roll No, Name, Age, Class of students.
Prepared by Prabesh Bhandari (For 3rd Sem BIT, TU)
In the above student's table, the value A in the last row last column violates the domain integrity
constraint because the Class attribute contains only integer values while A is a character.
Data dictionary is a set of tables and database objects that is stored in a special area of the database and
maintained exclusively by the kernel.
5. What is union compatibility? Define operations union, intersection, and difference on two union
compatible relations A and B with suitable example.
Prepared by Prabesh Bhandari (For 3rd Sem BIT, TU)
The union compatibility of relations implies that the participating relations must fulfil the following
conditions:
-Same domain of each corresponding pair of attributes of relation A and relation B, that is
Dom(A) = Dom (B)
That is, the domain (stands for data type) for the corresponding attributes must be identical.
Intersection (∩):
An intersection is defined by the symbol ∩ as A ∩ B.
Prepared by Prabesh Bhandari (For 3rd Sem BIT, TU)
It defines a relation consisting of a set of all tuple that are in both A and B. However, A and B must be
union-compatible.
6. Explain the difference between "Join"(Inner Join) and "Natural Join" of algebraic operators with
example.
select * from Stu natural Join select * from Stu s inner join marks m
Example
marks; on s.Roll_no=m.Roll_no;