SlideShare una empresa de Scribd logo
1 de 25
Relational DBMS
 Edgar F. Codd at IBM invented the relational database
in 1970. Called Father of RDBMS.
 The main elements of RDBMS are based on Codd’s 13
rules for a relational system.
 Tables (or relations) are related to each other by
sharing common characteristics
RDBMS
A database management system that stores data in the
form of related tables is called Relational Database
Management System.
The goal of RDBMS is to make data easy to store &
retrieve
Relational databases help solve problems as they are
designed to create tables & then combine the
information in interesting ways to create valid
information.
RDBMS
Typical RDBMS include
Microsoft Access
Microsoft SQL Server
Sybase (The forerunner of Microsoft SQL Server)
IBM DB2
Oracle
Ingres
MySQL
Postgresql etc
RDBMS
Relation Instance:- snapshot of DB
Example:
Schema :- Logical design of DB.
Example:
Account-schema = (account-number, branch-name,
balance)
Branch-schema = (branch-name, branch-city, assets)
Customer-schema = (customer-name, customer-street,
customer-city)
RDBMS
Schema Diagram
Translation ER Model to Relational
Model
Translation ER Model to Relational
Model
Integrity Constraint
An integrity constraint (IC) is a condition specified on
a database schema and restricts the data that can be
stored in an instance of the database.
If a database instance satisfies all the integrity
constraints specifies on the database schema, it is
a legal instance.
A DBMS permits only legal instances to be stored in the
database.
Integrity Constraint
Domain Constraints:
A relation schema specifies the domain of each field in
the relation instance. These domain constraints in the
schema specify the condition that each instance of the
relation has to satisfy.
Example:
create domain Dollars numeric(12,2)
create domain Pounds numeric(12,2)
define the domains Dollars and Pounds to be decimal
numbers with a total of 12 digits, two of which are
placed after the decimal point.
Integrity Constraint
Referential Integrity:
ensure that a value that appears in one relation for a
given set of attributes also appears for a certain set of
attributes in another relation.
Example: SQL
branch-name char(15) references branch
Key Constraints
Super Key:
An attribute, or set of attributes, that uniquely identifies a
tuple within a relation.
However, a super key may contain additional attributes that
are not necessary for a unique identification.
Candidate Key:
A super key such that no proper subset is a super key within
the relation. There are two parts of the candidate key
definition:
i. Two distinct tuples in a legal instance cannot have identical
values in all the fields of a key.
ii. No subset of the set of fields in a candidate key is a unique
identifier for a tuple.
Key Constraints
Primary Key:
The candidate key that is selected to identify tuples
uniquely within the relation.
The candidate keys that are not selected as the primary
key are called as alternate keys.
Features of the primary key:
1. Primary key will not allow duplicate values.
2.Primary key will not allow null values.
3. Only one primary key is allowed per table.
Key Constraints
Foreign Key:
Foreign keys represent the relationships between tables.
A foreign key is a column (or a group of columns)
whose values are derived from the primary key of some
other table.
Features of foreign key:
1. Records cannot be inserted into a detail table if
corresponding records in the master table do not exist.
2. Records of the master table cannot be deleted or
updated if corresponding records in the detail table
actually exist.
Integrity Constraint
Assertions:
An assertion is a predicate expressing a condition that we
wish the database always to satisfy.
create assertion <assertion-name> check <predicate>
Example :
create assertion sum-constraint check
(not exists (select * from branch
where (select sum(amount) from loan
where loan.branch-name = branch.branch-name)
>= (select sum(balance) from account
where account.branch-name = branch.branch-name)))
Integrity Constraint
Triggers:
A trigger is a statement that the system executes
automatically as a side effect of a modification to the
database.
To design a trigger mechanism, we must meet two
requirements:
1. Specify when a trigger is to be executed. This is broken
up into an event that causes the trigger to be checked
and a condition that must be satisfied for trigger
execution to proceed.
2. Specify the actions to be taken when the trigger
executes.
Integrity Constraint
Triggers:
Example: define a trigger that replaces the blank value
in a phone number field of an inserted tuple by the
null value.
create trigger setnull-trigger before update on r
referencing new row as nrow for each row when
nrow.phone-number = ’ ’ set nrow.phone-number = null
Relational Algebra
Fundamental Operations
Unary Operation
 Select
 Project
 Rename
Binary Operations
 Union
 Set different
 Cartesian product
Relational Algebra
Select (σ) :
(a) Example: select those tuples of the loan relation
where the branch is “Perryridge,”
σbranch-name =“Perryridge” (loan)
(b) Example: find those tuples pertaining to loans of
more than $1200 made by the Perryridge branch
σbranch-name =“Perryridge”∧ amount>1200 (loan)
Relational Algebra
Project(Π)
Example: list all loan numbers and the amount of the
loan as
Πloan-number, amount(loan)
Union(∪)
Example: find the names of all bank customers who hav
either an account or a loan or both.
Πcustomer-name (borrower ) ∪ Πcustomer-name (depositor)
borrower : Customers with a loan in the bank
Relational Algebra
Set Difference (-)
Example: find all customers of the bank who have an account
but not a loan
Πcustomer-name (depositor) − Πcustomer-name (borrower )
Cartesian-Product (X)
Example: find the names of all customers who have a loan at
the Perryridge branch.
3. Πcustomer-name (σborrower .loan-number =loan.loan-number
(σbranch-name =“Perryridge” (borrower × loan)))
Relational Algebra
Rename (ρ)
relational-algebra expression E,
ρ x (E)
returns the result of expression E under the name x.
Additional operations are:
• Set intersection
• Assignment
• Natural join
Relational Calculus
Tuple Relational Calculus
A query in the tuple relational calculus is expressed as
{t | P(t)}
the set of all tuples t such that predicate P is true for t.
Domain Relational Calculus
An expression in the domain relational calculus is of the form
{< x1, x2, . . . , xn > | P(x1, x2, . . . , xn)}
where x1, x2, . . . , xn represent domain variables. P represents a
formula composed of atoms, as was the case in the tuple
relational calculus.

Más contenido relacionado

La actualidad más candente

Data base management system
Data base management systemData base management system
Data base management system
Navneet Jingar
 
Functional dependencies and normalization
Functional dependencies and normalizationFunctional dependencies and normalization
Functional dependencies and normalization
daxesh chauhan
 

La actualidad más candente (20)

Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
 
ER-Model-ER Diagram
ER-Model-ER DiagramER-Model-ER Diagram
ER-Model-ER Diagram
 
Databases: Normalisation
Databases: NormalisationDatabases: Normalisation
Databases: Normalisation
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
database Normalization
database Normalizationdatabase Normalization
database Normalization
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Entity relationship modelling
Entity relationship modellingEntity relationship modelling
Entity relationship modelling
 
Data Models
Data ModelsData Models
Data Models
 
Rdbms
RdbmsRdbms
Rdbms
 
3 Level Architecture
3 Level Architecture3 Level Architecture
3 Level Architecture
 
Data base management system
Data base management systemData base management system
Data base management system
 
Normalization in a Database
Normalization in a DatabaseNormalization in a Database
Normalization in a Database
 
The relational database model
The relational database modelThe relational database model
The relational database model
 
Dbms normalization
Dbms normalizationDbms normalization
Dbms normalization
 
Functional dependencies and normalization
Functional dependencies and normalizationFunctional dependencies and normalization
Functional dependencies and normalization
 
Database systems - Chapter 2
Database systems - Chapter 2Database systems - Chapter 2
Database systems - Chapter 2
 
Sql - Structured Query Language
Sql - Structured Query LanguageSql - Structured Query Language
Sql - Structured Query Language
 
Dbms 14: Relational Calculus
Dbms 14: Relational CalculusDbms 14: Relational Calculus
Dbms 14: Relational Calculus
 
Normal forms
Normal formsNormal forms
Normal forms
 

Destacado

Cardinality and participation constraints
Cardinality and participation constraintsCardinality and participation constraints
Cardinality and participation constraints
Nikhil Deswal
 
4 the relational data model and relational database constraints
4 the relational data model and relational database constraints4 the relational data model and relational database constraints
4 the relational data model and relational database constraints
Kumar
 
3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMS
koolkampus
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMS
koolkampus
 

Destacado (14)

Cardinality and participation constraints
Cardinality and participation constraintsCardinality and participation constraints
Cardinality and participation constraints
 
Rdbms
RdbmsRdbms
Rdbms
 
Relational database management system (rdbms) i
Relational database management system (rdbms) iRelational database management system (rdbms) i
Relational database management system (rdbms) i
 
Urinary system embryology
Urinary system embryologyUrinary system embryology
Urinary system embryology
 
Introduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallIntroduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John Mulhall
 
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system  - Relational data model and relational datab...Fundamentals of database system  - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]
 
Introduction to RDBMS
Introduction to RDBMSIntroduction to RDBMS
Introduction to RDBMS
 
4 the relational data model and relational database constraints
4 the relational data model and relational database constraints4 the relational data model and relational database constraints
4 the relational data model and relational database constraints
 
3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMS
 
Denormalization
DenormalizationDenormalization
Denormalization
 
RDBMS.ppt
RDBMS.pptRDBMS.ppt
RDBMS.ppt
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMS
 
Rdbms
RdbmsRdbms
Rdbms
 

Similar a Database : Relational Data Model

6 integrity and security
6 integrity and security6 integrity and security
6 integrity and security
Dilip G R
 
6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMS
koolkampus
 
5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS
koolkampus
 

Similar a Database : Relational Data Model (20)

SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
 
Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013
 
6 integrity and security
6 integrity and security6 integrity and security
6 integrity and security
 
MySQL 指南
MySQL 指南MySQL 指南
MySQL 指南
 
dbms first unit
dbms first unitdbms first unit
dbms first unit
 
Unit04 dbms
Unit04 dbmsUnit04 dbms
Unit04 dbms
 
My sql advacnce topics
My sql advacnce topicsMy sql advacnce topics
My sql advacnce topics
 
Ch6
Ch6Ch6
Ch6
 
Design dbms
Design dbmsDesign dbms
Design dbms
 
ch2
ch2ch2
ch2
 
RDBMS
RDBMSRDBMS
RDBMS
 
E-R diagram & SQL
E-R diagram & SQLE-R diagram & SQL
E-R diagram & SQL
 
ch4
ch4ch4
ch4
 
6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMS
 
Unit 04 dbms
Unit 04 dbmsUnit 04 dbms
Unit 04 dbms
 
5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS
 
uniT 4 (1).pptx
uniT 4 (1).pptxuniT 4 (1).pptx
uniT 4 (1).pptx
 
Ch4
Ch4Ch4
Ch4
 
Mysql tutorial
Mysql tutorialMysql tutorial
Mysql tutorial
 
Mysql tutorial
Mysql tutorialMysql tutorial
Mysql tutorial
 

Último

Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 

Último (20)

FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 

Database : Relational Data Model

  • 1.
  • 2. Relational DBMS  Edgar F. Codd at IBM invented the relational database in 1970. Called Father of RDBMS.  The main elements of RDBMS are based on Codd’s 13 rules for a relational system.  Tables (or relations) are related to each other by sharing common characteristics
  • 3. RDBMS A database management system that stores data in the form of related tables is called Relational Database Management System. The goal of RDBMS is to make data easy to store & retrieve Relational databases help solve problems as they are designed to create tables & then combine the information in interesting ways to create valid information.
  • 4. RDBMS Typical RDBMS include Microsoft Access Microsoft SQL Server Sybase (The forerunner of Microsoft SQL Server) IBM DB2 Oracle Ingres MySQL Postgresql etc
  • 5. RDBMS Relation Instance:- snapshot of DB Example: Schema :- Logical design of DB. Example: Account-schema = (account-number, branch-name, balance) Branch-schema = (branch-name, branch-city, assets) Customer-schema = (customer-name, customer-street, customer-city)
  • 7. Translation ER Model to Relational Model
  • 8. Translation ER Model to Relational Model
  • 9.
  • 10. Integrity Constraint An integrity constraint (IC) is a condition specified on a database schema and restricts the data that can be stored in an instance of the database. If a database instance satisfies all the integrity constraints specifies on the database schema, it is a legal instance. A DBMS permits only legal instances to be stored in the database.
  • 11. Integrity Constraint Domain Constraints: A relation schema specifies the domain of each field in the relation instance. These domain constraints in the schema specify the condition that each instance of the relation has to satisfy. Example: create domain Dollars numeric(12,2) create domain Pounds numeric(12,2) define the domains Dollars and Pounds to be decimal numbers with a total of 12 digits, two of which are placed after the decimal point.
  • 12. Integrity Constraint Referential Integrity: ensure that a value that appears in one relation for a given set of attributes also appears for a certain set of attributes in another relation. Example: SQL branch-name char(15) references branch
  • 13. Key Constraints Super Key: An attribute, or set of attributes, that uniquely identifies a tuple within a relation. However, a super key may contain additional attributes that are not necessary for a unique identification. Candidate Key: A super key such that no proper subset is a super key within the relation. There are two parts of the candidate key definition: i. Two distinct tuples in a legal instance cannot have identical values in all the fields of a key. ii. No subset of the set of fields in a candidate key is a unique identifier for a tuple.
  • 14. Key Constraints Primary Key: The candidate key that is selected to identify tuples uniquely within the relation. The candidate keys that are not selected as the primary key are called as alternate keys. Features of the primary key: 1. Primary key will not allow duplicate values. 2.Primary key will not allow null values. 3. Only one primary key is allowed per table.
  • 15. Key Constraints Foreign Key: Foreign keys represent the relationships between tables. A foreign key is a column (or a group of columns) whose values are derived from the primary key of some other table. Features of foreign key: 1. Records cannot be inserted into a detail table if corresponding records in the master table do not exist. 2. Records of the master table cannot be deleted or updated if corresponding records in the detail table actually exist.
  • 16. Integrity Constraint Assertions: An assertion is a predicate expressing a condition that we wish the database always to satisfy. create assertion <assertion-name> check <predicate> Example : create assertion sum-constraint check (not exists (select * from branch where (select sum(amount) from loan where loan.branch-name = branch.branch-name) >= (select sum(balance) from account where account.branch-name = branch.branch-name)))
  • 17. Integrity Constraint Triggers: A trigger is a statement that the system executes automatically as a side effect of a modification to the database. To design a trigger mechanism, we must meet two requirements: 1. Specify when a trigger is to be executed. This is broken up into an event that causes the trigger to be checked and a condition that must be satisfied for trigger execution to proceed. 2. Specify the actions to be taken when the trigger executes.
  • 18. Integrity Constraint Triggers: Example: define a trigger that replaces the blank value in a phone number field of an inserted tuple by the null value. create trigger setnull-trigger before update on r referencing new row as nrow for each row when nrow.phone-number = ’ ’ set nrow.phone-number = null
  • 19.
  • 20. Relational Algebra Fundamental Operations Unary Operation  Select  Project  Rename Binary Operations  Union  Set different  Cartesian product
  • 21. Relational Algebra Select (σ) : (a) Example: select those tuples of the loan relation where the branch is “Perryridge,” σbranch-name =“Perryridge” (loan) (b) Example: find those tuples pertaining to loans of more than $1200 made by the Perryridge branch σbranch-name =“Perryridge”∧ amount>1200 (loan)
  • 22. Relational Algebra Project(Π) Example: list all loan numbers and the amount of the loan as Πloan-number, amount(loan) Union(∪) Example: find the names of all bank customers who hav either an account or a loan or both. Πcustomer-name (borrower ) ∪ Πcustomer-name (depositor) borrower : Customers with a loan in the bank
  • 23. Relational Algebra Set Difference (-) Example: find all customers of the bank who have an account but not a loan Πcustomer-name (depositor) − Πcustomer-name (borrower ) Cartesian-Product (X) Example: find the names of all customers who have a loan at the Perryridge branch. 3. Πcustomer-name (σborrower .loan-number =loan.loan-number (σbranch-name =“Perryridge” (borrower × loan)))
  • 24. Relational Algebra Rename (ρ) relational-algebra expression E, ρ x (E) returns the result of expression E under the name x. Additional operations are: • Set intersection • Assignment • Natural join
  • 25. Relational Calculus Tuple Relational Calculus A query in the tuple relational calculus is expressed as {t | P(t)} the set of all tuples t such that predicate P is true for t. Domain Relational Calculus An expression in the domain relational calculus is of the form {< x1, x2, . . . , xn > | P(x1, x2, . . . , xn)} where x1, x2, . . . , xn represent domain variables. P represents a formula composed of atoms, as was the case in the tuple relational calculus.

Notas del editor

  1. relation schema corresponds to the programming-language notion of type definition. relation instance corresponds to the programming language notion of a value of a variable.
  2. A database schema, along with primary key and foreign key dependencies, can be depicted pictorially by schema diagrams. E-R diagrams do not show foreign key attributes explicitly, whereas schema diagrams show them explicity.
  3. Mapping Entity
  4. Mapping Relation
  5. Domain definitions can be physical & Logical. Such constraints may also prohibit the use of null values for particular attributes. Thus, the domain of a field is essentially the type of that field. Values of one domain can be cast (that is, converted) to another domain. Example : If the attribute A or relation r is of type Dollars, we can convert it to Pounds by writing cast r.A as Pounds
  6. By default, a foreign key references the primary key attributes of the referenced table. SQL also supports a version of the references clause where a list of attributes of the referenced relation can be specified explicitly. The specified list of attributes must be declared as a candidate key of the referenced relation.
  7. (k1,k2,k3,k4) – superkey –unique identifier for tuple k1 – primary key k2, k3 – candidate key also alternate key K1,k2,k3 – not candiate key
  8. The table in which foreign key is defined is called a Foreign table or Details table. The table that defines the primary key and is referenced by the foreign key is called the Primary table or Master table.
  9. Domain constraints and referential-integrity constraints are special forms of assertions. When an assertion is created, the system tests it for validity. If the assertion is valid, then any future modification to the database is allowed only if it does not cause that assertion to be violated.
  10. The above model of triggers is referred to as the event-condition-action model for triggers.
  11. Trigger limited use: For example, suppose an insert trigger on a relation has an action that causes another (new) insert on the same relation. The insert action then triggers yet another insert action, and so on ad infinitum. Database systems typically limit the length of such chains of triggers (for example to 16 or 32), and consider longer chains of triggering an error.
  12. The relational algebra is a procedural query language. It consists of a set of operations that take one or two relations as input and produce a new relation as their result.
  13. In general, we allow comparisons using =, =, <, ≤, >, ≥ in the selection predicate. Furthermore, we can combine several predicates into a larger predicate by using the connectives and (∧), or (∨), and not (¬). Exercise: find all customers who have the same name as their loan officer, we can write σcustomer-name =banker-name(loan-officer)
  14. Since relations are sets, duplicate values are eliminated Composition of Relational Operations Example : “Find those customers who live in Harrison.” Πcustomer-name (σcustomer-city =“Harrison” (customer))
  15. Cartesian-Product Example We need the information in both the loan relation and the borrower relation to do so. Cartesian-product operation associates every tuple of loan with every tuple of borrower, 1. σbranch-name =“Perryridge”(borrower × loan) 2. σborrower .loan-number =loan.loan-number (σbranch-name =“Perryridge”(borrower × loan))
  16. Rename Operation Excellent Example Further reading from korth
  17. The tuple relational calculus, by contrast, is a nonprocedural query language. Following our earlier notation, we use t[A] to denote the value of tuple t on attribute A, andwe use t ∈ r to denote that tuple t is in relation r.