SlideShare a Scribd company logo
Module-2:Relational Model,Relational
Algebra,Mapping Conceptual Design
into a Logical Design
Prepared By
Indu K S
Assistant Professor
Dept Of ISE,TOCE
Chapter 5(5.1 to 5.3)
Relational Model: Relational Model Concepts,
Relational Model Constraints and relational database schemas,
Update operations,
Transactions, and
Dealing with constraint violations.
Chapter 8(8.1 to 8.5)
Relational Algebra: Unary and Binary relational operations,
additional relational operations (aggregate, grouping, etc.)
Examples of Queries in relational algebra.
Chapter 9(9.1 to 9.2)
Mapping Conceptual Design into a Logical Design:
Relational Database Design using ER-to-Relational mapping
5.1 Relational Model Concepts
• The relational model is a way of structuring and querying data in a
database
• The relational model represents the database as a collection of
relations.
• Informally, each relation resembles a table of values or, to some
extent, a flat file of records .
• A relation is thought of as a table of values, each row in the table
represents a collection of related data values.
• A row represents a fact that typically corresponds to a real-world
entity or relationship.
• The table name and column names are used to help to interpret
the meaning of the values in each row.
• In the formal relational model terminology, a row a tuple, a
column header an attribute, and the table a relation.
• The data type describing the types of values that can appear in
each column is represented by a domain of possible values.
5.1.1 Domains, Attributes, Tuples, and Relations
• A domain D is a set of atomic values.
• By atomic means each value in the domain is indivisible in formal
relational model.
• A common method of specifying a domain is to specify a data type
from which the data values forming the domain are drawn.
Some examples of domains follow:
• USA_phone_number: string of digits of length ten
• SSN: string of digits of length nine
• Name: string of characters beginning with an uppercase letter
• GPA: a real number between 0.0 and 4.0
• Gender: a member of the set { female, male }
• Dept_Code: a member of the set { CMPS, MATH, ENGL, PHYS,
PSYC, ... }
• 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: Ai is the name of a role played by some domain D
in the relation schema R.
• D is called the domain of Ai and is denoted by dom(Ai).
• Tuple: A tuple is a mapping from attributes to values drawn
from the respective domains of those attributes.
• A tuple is intended to describe some entity (or relationship
between entities) in the miniworld.
• R is called the name of this relation.
• The degree (or arity) of a relation is the number of attributes n of
its relation schema.
• A relation of degree seven, which stores information about
university students, would contain seven attributes describing each
student as follows: STUDENT(Name, Ssn, Home_phone,
Address, Office_phone, Age, Gpa)
• Relational Database: A collection of relations, each one consistent
with its specified relational schema.
• A relation (or relation state) r of the relation schema R(A1, A2, …
, An), also denoted by r(R), is a set of n-tuples r = {t1, t2, … , tm}.
Each n-tuple t is an ordered list of n values t =<v1,v2….vn>.
DBMS Module-2 notes for engineering BE vtu
5.1.2 Characteristics of Relations
DBMS Module-2 notes for engineering BE vtu
5.1.3 Relational Model Notation
5.2 Relational Model Constraints and Relational Database Schemas
Relational Model Constraints on databases can generally be divided into
three main categories:
1. Constraints that are inherent in the data model known as inherent
model-based constraints or implicit constraints.
2. Constraints that can be directly expressed in the schemas of the data
model, typically by specifying them in the DDL known as schema-
based constraints or explicit constraints.
3. Constraints that cannot be directly expressed in the schemas of the
data model, and hence must be expressed and enforced by the
application programs or in some other way known as application-based
or semantic constraints or business rules.
The schema-based constraints include domain constraints, key
constraints, constraints on NULLs, entity integrity constraints, and
referential integrity constraints.
DBMS Module-2 notes for engineering BE vtu
5.2.4 Entity Integrity, Referential Integrity, and Foreign Keys
Entity Integrity:
Entity Integrity ensures that each table has a primary key and that the values in this
primary key are unique and not null. This guarantees that each record (tuple) in the
table can be uniquely identified.
Primary Key: A set of one or more columns whose combined values uniquely
identify each row in the table. A table can have only one primary key, which
enforces both uniqueness and non-nullability on its columns.
A foreign key :
Is a column or a set of columns in a relational database table that
provides a link between data in two tables. It acts as a cross-
reference between tables by referencing the primary key of another
table, thereby ensuring referential integrity.
Referential Integrity
Referential Integrity ensures that a foreign key value always
refers to an existing, valid row in another table. This maintains
the logical consistency between related tables.
In the EMPLOYEE relation,
the attribute Dno refers to the
department for which an
employee works; hence, it is
designated Dno to be a
foreign key of EMPLOYEE
referencing the
DEPARTMENT relation
In this definition, EMPLOYEE is
called the referencing relation and
DEPARTMENT is the referenced
relation
DBMS Module-2 notes for engineering BE vtu
5.2.5 Other Types of Constraints
The salary of an employee should not exceed the salary of the
employee’s supervisor and the maximum number of hours an
employee can work on all projects per week is 56.
Such constraints can be specified and enforced within the
application programs that update the database, or by using a
general-purpose constraint specification language. Sometimes
called as Semantic Integrity constraint.
5.3 Update Operations, Transactions, and Dealing with Constraint Violations
DBMS Module-2 notes for engineering BE vtu
DBMS Module-2 notes for engineering BE vtu
The Delete Operation :
The Delete operation can violate only referential integrity.
This occurs if the tuple being deleted is referenced by foreign keys from
other tuples in the database.
To specify deletion, a condition on the attributes of the relation selects
the tuple (or tuples) to be deleted
DBMS Module-2 notes for engineering BE vtu
DBMS Module-2 notes for engineering BE vtu
DBMS Module-2 notes for engineering BE vtu
5.3.4 The Transaction Concept
A database application program running against a relational
database typically executes one or more transactions.
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.
Chapter 8(8.1 to 8.5)
The basic set of operations for the formal relational model is the
relational algebra. These operations enable a user to specify basic
retrieval requests as relational algebra expressions.
8.1 Unary Relational Operations: SELECT and PROJECT
DBMS Module-2 notes for engineering BE vtu
DBMS Module-2 notes for engineering BE vtu
For example, to select the tuples for all employees who either work in
department 4 and make over $25,000 per year, or work in department
5 and make over $30,000, we can specify the following SELECT
operation:
σ(Dno=4 AND Salary>25000) OR (Dno=5 AND Salary>30000)(EMPLOYEE)
DBMS Module-2 notes for engineering BE vtu
8.1.2 The PROJECT Operation
Results of a sequence of operations.
(a) πFname, Lname, Salary
(σDno=5(EMPLOYEE)).
To rename the attributes in a relation, we simply list the new attribute
names in parentheses, as in the following example:
TEMP ← σDno=5(EMPLOYEE)
R(First_name, Last_name, Salary) ← πFname, Lname, Salary(TEMP)
These two operations are illustrated in Figure 8.2(b).
DBMS Module-2 notes for engineering BE vtu
8.2 Relational Algebra Operations from Set Theory
8.2.1 The UNION, INTERSECTION, and MINUS
Operations
DBMS Module-2 notes for engineering BE vtu
DBMS Module-2 notes for engineering BE vtu
DBMS Module-2 notes for engineering BE vtu
Ad

More Related Content

Similar to DBMS Module-2 notes for engineering BE vtu (20)

COMPUTERS Database
COMPUTERS Database COMPUTERS Database
COMPUTERS Database
Rc Os
 
Dbms Concepts
Dbms ConceptsDbms Concepts
Dbms Concepts
adukkas
 
ER Digramms by Harshal wagh
ER Digramms by Harshal waghER Digramms by Harshal wagh
ER Digramms by Harshal wagh
harshalkwagh999
 
Introduction to database management system
Introduction to database management systemIntroduction to database management system
Introduction to database management system
backiyalakshmi14
 
RDBMS
RDBMSRDBMS
RDBMS
NilaNila16
 
Data model
Data modelData model
Data model
Syed Zaid Irshad
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]
Bashir Rezaie
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
Nishant Munjal
 
Relational model
Relational modelRelational model
Relational model
Dabbal Singh Mahara
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relational
Jafar Nesargi
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relational
Jafar Nesargi
 
DBMS Unit-2.pdf
DBMS Unit-2.pdfDBMS Unit-2.pdf
DBMS Unit-2.pdf
vaishnavi339314
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relational
Jafar Nesargi
 
unit-3_Chapter1_RDRA.pdf
unit-3_Chapter1_RDRA.pdfunit-3_Chapter1_RDRA.pdf
unit-3_Chapter1_RDRA.pdf
Koteswari Kasireddy
 
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
Raj vardhan
 
Relational Model
Relational ModelRelational Model
Relational Model
A. S. M. Shafi
 
Bca examination 2017 dbms
Bca examination 2017 dbmsBca examination 2017 dbms
Bca examination 2017 dbms
Anjaan Gajendra
 
Chapter 2 Database System Architecture.pdf
Chapter 2 Database System Architecture.pdfChapter 2 Database System Architecture.pdf
Chapter 2 Database System Architecture.pdf
Getnet Tigabie Askale -(GM)
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
Nazir Ahmed
 
DBMS and Rdbms fundamental concepts
DBMS and Rdbms fundamental conceptsDBMS and Rdbms fundamental concepts
DBMS and Rdbms fundamental concepts
Kuntal Bhowmick
 
COMPUTERS Database
COMPUTERS Database COMPUTERS Database
COMPUTERS Database
Rc Os
 
Dbms Concepts
Dbms ConceptsDbms Concepts
Dbms Concepts
adukkas
 
ER Digramms by Harshal wagh
ER Digramms by Harshal waghER Digramms by Harshal wagh
ER Digramms by Harshal wagh
harshalkwagh999
 
Introduction to database management system
Introduction to database management systemIntroduction to database management system
Introduction to database management system
backiyalakshmi14
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]
Bashir Rezaie
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
Nishant Munjal
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relational
Jafar Nesargi
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relational
Jafar Nesargi
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relational
Jafar Nesargi
 
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
Raj vardhan
 
Bca examination 2017 dbms
Bca examination 2017 dbmsBca examination 2017 dbms
Bca examination 2017 dbms
Anjaan Gajendra
 
DBMS and Rdbms fundamental concepts
DBMS and Rdbms fundamental conceptsDBMS and Rdbms fundamental concepts
DBMS and Rdbms fundamental concepts
Kuntal Bhowmick
 

Recently uploaded (20)

Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Journal of Soft Computing in Civil Engineering
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E..."Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
Infopitaara
 
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Journal of Soft Computing in Civil Engineering
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
π0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalizationπ0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalization
NABLAS株式会社
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
The Gaussian Process Modeling Module in UQLab
The Gaussian Process Modeling Module in UQLabThe Gaussian Process Modeling Module in UQLab
The Gaussian Process Modeling Module in UQLab
Journal of Soft Computing in Civil Engineering
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E..."Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
Infopitaara
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
π0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalizationπ0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalization
NABLAS株式会社
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
Ad

DBMS Module-2 notes for engineering BE vtu

  • 1. Module-2:Relational Model,Relational Algebra,Mapping Conceptual Design into a Logical Design Prepared By Indu K S Assistant Professor Dept Of ISE,TOCE
  • 2. Chapter 5(5.1 to 5.3) Relational Model: Relational Model Concepts, Relational Model Constraints and relational database schemas, Update operations, Transactions, and Dealing with constraint violations. Chapter 8(8.1 to 8.5) Relational Algebra: Unary and Binary relational operations, additional relational operations (aggregate, grouping, etc.) Examples of Queries in relational algebra. Chapter 9(9.1 to 9.2) Mapping Conceptual Design into a Logical Design: Relational Database Design using ER-to-Relational mapping
  • 3. 5.1 Relational Model Concepts • The relational model is a way of structuring and querying data in a database • The relational model represents the database as a collection of relations. • Informally, each relation resembles a table of values or, to some extent, a flat file of records . • A relation is thought of as a table of values, each row in the table represents a collection of related data values. • A row represents a fact that typically corresponds to a real-world entity or relationship. • The table name and column names are used to help to interpret the meaning of the values in each row. • In the formal relational model terminology, a row a tuple, a column header an attribute, and the table a relation. • The data type describing the types of values that can appear in each column is represented by a domain of possible values.
  • 4. 5.1.1 Domains, Attributes, Tuples, and Relations • A domain D is a set of atomic values. • By atomic means each value in the domain is indivisible in formal relational model. • A common method of specifying a domain is to specify a data type from which the data values forming the domain are drawn. Some examples of domains follow: • USA_phone_number: string of digits of length ten • SSN: string of digits of length nine • Name: string of characters beginning with an uppercase letter • GPA: a real number between 0.0 and 4.0 • Gender: a member of the set { female, male } • Dept_Code: a member of the set { CMPS, MATH, ENGL, PHYS, PSYC, ... }
  • 5. • 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: Ai is the name of a role played by some domain D in the relation schema R. • D is called the domain of Ai and is denoted by dom(Ai). • Tuple: A tuple is a mapping from attributes to values drawn from the respective domains of those attributes. • A tuple is intended to describe some entity (or relationship between entities) in the miniworld.
  • 6. • R is called the name of this relation. • The degree (or arity) of a relation is the number of attributes n of its relation schema. • A relation of degree seven, which stores information about university students, would contain seven attributes describing each student as follows: STUDENT(Name, Ssn, Home_phone, Address, Office_phone, Age, Gpa) • Relational Database: A collection of relations, each one consistent with its specified relational schema. • A relation (or relation state) r of the relation schema R(A1, A2, … , An), also denoted by r(R), is a set of n-tuples r = {t1, t2, … , tm}. Each n-tuple t is an ordered list of n values t =<v1,v2….vn>.
  • 11. 5.2 Relational Model Constraints and Relational Database Schemas Relational Model Constraints on databases can generally be divided into three main categories: 1. Constraints that are inherent in the data model known as inherent model-based constraints or implicit constraints. 2. Constraints that can be directly expressed in the schemas of the data model, typically by specifying them in the DDL known as schema- based constraints or explicit constraints. 3. Constraints that cannot be directly expressed in the schemas of the data model, and hence must be expressed and enforced by the application programs or in some other way known as application-based or semantic constraints or business rules.
  • 12. The schema-based constraints include domain constraints, key constraints, constraints on NULLs, entity integrity constraints, and referential integrity constraints.
  • 14. 5.2.4 Entity Integrity, Referential Integrity, and Foreign Keys Entity Integrity: Entity Integrity ensures that each table has a primary key and that the values in this primary key are unique and not null. This guarantees that each record (tuple) in the table can be uniquely identified. Primary Key: A set of one or more columns whose combined values uniquely identify each row in the table. A table can have only one primary key, which enforces both uniqueness and non-nullability on its columns.
  • 15. A foreign key : Is a column or a set of columns in a relational database table that provides a link between data in two tables. It acts as a cross- reference between tables by referencing the primary key of another table, thereby ensuring referential integrity.
  • 16. Referential Integrity Referential Integrity ensures that a foreign key value always refers to an existing, valid row in another table. This maintains the logical consistency between related tables.
  • 17. In the EMPLOYEE relation, the attribute Dno refers to the department for which an employee works; hence, it is designated Dno to be a foreign key of EMPLOYEE referencing the DEPARTMENT relation In this definition, EMPLOYEE is called the referencing relation and DEPARTMENT is the referenced relation
  • 19. 5.2.5 Other Types of Constraints The salary of an employee should not exceed the salary of the employee’s supervisor and the maximum number of hours an employee can work on all projects per week is 56. Such constraints can be specified and enforced within the application programs that update the database, or by using a general-purpose constraint specification language. Sometimes called as Semantic Integrity constraint.
  • 20. 5.3 Update Operations, Transactions, and Dealing with Constraint Violations
  • 23. The Delete Operation : The Delete operation can violate only referential integrity. This occurs if the tuple being deleted is referenced by foreign keys from other tuples in the database. To specify deletion, a condition on the attributes of the relation selects the tuple (or tuples) to be deleted
  • 27. 5.3.4 The Transaction Concept A database application program running against a relational database typically executes one or more transactions. 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.
  • 28. Chapter 8(8.1 to 8.5) The basic set of operations for the formal relational model is the relational algebra. These operations enable a user to specify basic retrieval requests as relational algebra expressions. 8.1 Unary Relational Operations: SELECT and PROJECT
  • 31. For example, to select the tuples for all employees who either work in department 4 and make over $25,000 per year, or work in department 5 and make over $30,000, we can specify the following SELECT operation: σ(Dno=4 AND Salary>25000) OR (Dno=5 AND Salary>30000)(EMPLOYEE)
  • 33. 8.1.2 The PROJECT Operation
  • 34. Results of a sequence of operations. (a) πFname, Lname, Salary (σDno=5(EMPLOYEE)).
  • 35. To rename the attributes in a relation, we simply list the new attribute names in parentheses, as in the following example: TEMP ← σDno=5(EMPLOYEE) R(First_name, Last_name, Salary) ← πFname, Lname, Salary(TEMP) These two operations are illustrated in Figure 8.2(b).
  • 37. 8.2 Relational Algebra Operations from Set Theory 8.2.1 The UNION, INTERSECTION, and MINUS Operations