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

DBMS Module2 Chapter1 PPTs

Module 2 discusses the relational data model, which represents databases as collections of relations resembling tables with rows (tuples) and columns (attributes). It covers relational model concepts, constraints, and update operations, emphasizing the importance of integrity and the handling of constraint violations during database operations. Key definitions include relation schemas, domain constraints, and the roles of primary and foreign keys in maintaining data integrity.

Uploaded by

shobhagopal97
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)
5 views16 pages

DBMS Module2 Chapter1 PPTs

Module 2 discusses the relational data model, which represents databases as collections of relations resembling tables with rows (tuples) and columns (attributes). It covers relational model concepts, constraints, and update operations, emphasizing the importance of integrity and the handling of constraint violations during database operations. Key definitions include relation schemas, domain constraints, and the roles of primary and foreign keys in maintaining data integrity.

Uploaded by

shobhagopal97
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

Module 2

Chapter 1 : The
Relational Data Model
Outline :

Relational Model Concepts

Relational Model Constraints and Relational Database


Schemas

Update Operations and Dealing with Constraint Violations


1.1 Relational Model Concepts
The relational model represents the database as a collection of relations.
RELATION :
Informal Definition
• Each relation resembles a table of values.
• A Relation may be – set of rows.
• A Relation may be – set of columns.
• Each row represent – entity or relationship.
• Each row has set of unique values to identify.
• Each column is having either column name or attribute name.
Formal Definition
• The table is called a relation.
• A row is called a tuple.
• A column header is called an attribute.
• Each column contains data type that describes the type of values to insert.

Example of STUDENT Relation


Relational schema:
A relation schema R, denoted by R(A1, A2, ...,An), is made up of a relation name R and a list
of attributes A1, A2, ...,An.

Attribute:
It is the name of the column in a particular table.

Domain :
It is set of atomic values .
Example : Phone_number(10 digit), SSN (9 digit), Name (character string)

Degree of Domain :
The degree of a relation is the number of attributes that relation/table consists of.
Example : If Student relation schema is having degree 7, then
STUDENT(Name, USN, Phone, Address, Age, Course, Result)
Definition Summary
Informal Terms Formal Terms
Table Relation
Column Header Attribute
All possible Column Domain
Values
Row Tuple

Table Definition Schema of a Relation


Populated Table State of the Relation
1.1.2 Characteristics Of Relations
1. Ordering of tuples in a relation r(R):
The tuples are not considered to be ordered

2. Ordering of attributes in a relation schema R (and of values within each tuple):


We will consider the attributes in R(A1, A2, ..., An) and the values in t=<v1, v2, ..., vn>
to be ordered .

3. Values and NULLs in a tuple :


• All values are considered atomic (indivisible).
• A special null value is used to represent values that are unknown or inapplicable to
certain tuples.

4. Interpretation(Meaning) of a relation :
Means the values in each tuple should satisfy the meaning of the relation.
1.1.3 Relational Model Notation
• Relation schema R of degree n is denoted by by R(A1, A2, ...,An)
• Uppercase letters Q, R, S denote relation names
• Lowercase letters q, r, s denote relation states
• Letters t, u, v denote tuples
• An attribute A can be qualified with the relation name R to which it belongs by using the dot
notation R.A for example, STUDENT.Name or STUDENT.Age.
• Example :
1.2 Relational Model Constraints and
Relational Database Schemas
Constraints are restrictions on the actual values in a database state.
• Constraints on databases are divided into three main categories.
1. Inherent model-based constraints or implicit constraints.
Example: Duplicate tuples not allowed.
2. Schema-based constraints or explicit constraints.
Example: domain constraints, key constraints, constraints on NULLs, entity integrity
constraints, and referential integrity constraints
3. Application-based or semantic constraints or business rules.
Example : Salary of employee should not exceed the salary of Manager
1.2.1 Domain Constraints :
• Value of Each attribute – atomic or unique value.
• Data types – Standard data types[Interger –(int,float,decimal), String-(fixed-length,variable-
length),date,datetime]

1.2.2 Key Constraints and Constraints on NULL Values :


Super Key : Super keys are collections of one or more properties (columns) in DBMS that
allow a tuple (row) in a relation (table) to be distinctly identified.
Key : It is an attribute or set of attributes used to identify specific row(s) in a table and also
to find or create relationship between tables.
Candidate Key : The minimal set of attributes that can uniquely identify a tuple is known as a
candidate key.
For Example: STUD_NO in STUDENT relation. It is a minimal super key.
Primary Key: It is a column or columns in a table that uniquely identify each row of data.
NULL : Null values are not permitted for few attributes.
Example : Consider the STUDENT relation
1.2.3 Relational Databases and Relational Database Schemas
Relational Database Schema : Schema ‘S’, having set of relations R1, R2, R3… etc
S = {R1, R2, ..., Rm}
Example : Company Database
COMPANY = {EMPLOYEE, DEPARTMENT, DEPT_LOCATIONS, PROJECT, WORKS_ON, DEPENDENT}
Relational database state:
is a set of relation states DB = {r1, r2, ..., rm}.

1.2.4 Integrity, Referential Integrity, and


Foreign Keys :
1. Entity integrity constraint.
2. Referential integrity constraint.
1.3 Update Operations, Transactions, and Dealing with
Constraint Violations
Three basic operations that can change the states of relations in the database:
1. Insert - used to insert one or more new tuples in a relation
2. Delete- used to delete tuples
3. Update (or Modify)- used to change the values of some attributes in existing tuples

1. The Insert Operation: It provides a list of attribute values for a new tuple.
Insert can violate any of the four types of constraints.
1. Domain constraints : attribute value does not appear in the domain
2.Key constraints : if a key value is already exists in another tuple in the
relation
3.Entity integrity: if primary key value is NULL
4.Referential integrity : if the value of any foreign key that does not exist .
Example : INSERT INTO employee (id, name, dept, age, salary location) VALUES (105, 'Srinath',
'Aeronautics', 27, 33000);

2. The Delete Operation :


• It can violate only referential integrity.
• Example : DELETE FROM Employee WHERE EMPNO = 105;
• Options involved in delete operation :
1. Restrict : is to reject the deletion
2. Cascade : is to attempt to cascade (or propagate) the deletion by deleting tuples that
referencethe tuple that is being deleted

3. Set null or set default : is to modify the referencing attribute values that cause the
violation; each such value is either set to NULL or changed to reference another default
valid tuple.
3. The Update Operation :
It is used to change the values of one or more attributes in a table.
Example :
UPDATE Employee
SET EMPNO = ‘204’
WHERE EMPNO = ‘105’;

4. The Transaction Concept :


• A transaction is an executing program that includes some database operations, such as
reading from the database, or applying insertions, deletions, or updates to the database.
• Example : a transaction to apply a bank withdrawal willtypically read the user account record,
check if there is a sufficient balance, and then update the record by the withdrawal amount.

You might also like