0% found this document useful (0 votes)
8 views

Unit 3 The Relational Data Model and Relational Database Constraints bitinfoNepal

relational data model and database

Uploaded by

bit student
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)
8 views

Unit 3 The Relational Data Model and Relational Database Constraints bitinfoNepal

relational data model and database

Uploaded by

bit student
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/ 4

Prepared by Prabesh Bhandari (For 3rd Sem BIT, TU)

Unit – 3 Relational Data Model and Relational Database Constraints

1. Define integrity constraint? Discuss referential integrity in detail.


- Integrity constraints are a set of rules. It is used to maintain the quality of information.
- Integrity constraints ensure that the data insertion, updating, and other processes have to be performed
in such a way that data integrity is not affected.
- Thus, integrity constraint is used to guard against accidental damage to the database.

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

ID Name Salary Dept_ID


1101 Jackson 40000 3
1102 Harry 60000 2
1103 Steve 80000 4
1104 Ash 1800000 3
1105 James 36000 1

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.

2. Discuss domain constraint with suitable example.


Domain integrity constraint contains a certain set of rules or conditions to restrict the kind of attributes
or values a column can hold in the database table. The data type of a domain can be string, integer,
character, DateTime, currency, etc.

Example: Consider a Student's table having Roll No, Name, Age, Class of students.
Prepared by Prabesh Bhandari (For 3rd Sem BIT, TU)

Roll No Name Age Class


101 Adam 14 6
102 Steve 16 8
103 David 8 4
104 Bruce 18 12
105 Tim 6 A

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.

3. Differentiate between Integrity and Security with example.

S.N. Data Security Data Integrity


1. Data security refers to the prevention of data Data integrity refers to the quality of data,
corruption through the use of controlled which assures the data is complete and has a
access mechanisms. whole structure.
2. Its motive is the protection of data. Its motive is the validity of data.
3. Some of the popular means of data security Some of the means to preserve integrity are
are authentication/authorization, masking, backing up, error detection, designing a
and encryptions. suitable user interface and correcting data.
6. It relates to the physical form of data against It relates to the logical protection (correct,
accidental or intentional loss or misuse and complete and consistence) of data.
destruction.
7. It avoids unauthorized access of data. It avoids human error when data is entered.
8. It can be implemented through: It can be implemented by following rule:

• user accounts (passwords) • Primary Key


• authentication schemes • Foreign Key
• Relationship

4. Which part of the RDBMS taken care of the data dictionary?

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 number of columns or attributes

-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.

Union operation (υ):


UNION is symbolized by ∪ symbol. It includes all tuples that are in tables A or in B. It also eliminates
duplicate tuples. So, set A UNION set B would be expressed as: A ∪ B

Set Difference (-):


(-) Symbol denotes it. The result of A – B, is a relation which includes all tuples that are in A but not in B.

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.

CHARACTERISTICS NATURAL JOIN INNER JOIN


Select Column from Select Column from Table_Name Table1
Syntax Table_Name Table1 Natural Inner Join Table2 on
Join Table2; Table1.Column=Table2.Column;
In Natural Join, there is no
need to mention the common In Inner join, there is a need to explicitly
columns. The tables are mention the common columns specified
Common Columns
joined considering the on ON Clause.
column on basis of name and
datatype.

In Natural join, when we


execute a query, there is In Inner join, we always have a duplicate
Duplicates
never a duplicate entry given entry given to a common column.
to common columns.

select * from Stu natural Join select * from Stu s inner join marks m
Example
marks; on s.Roll_no=m.Roll_no;

You might also like