SlideShare ist ein Scribd-Unternehmen logo
1 von 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.

Weitere ähnliche Inhalte

Was ist angesagt?

Dbms relational model
Dbms relational modelDbms relational model
Dbms relational modelChirag vasava
 
Degree of relationship set
Degree of relationship setDegree of relationship set
Degree of relationship setMegha Sharma
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introductionSmriti Jain
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraintsmadhav bansal
 
Introduction to databases
Introduction to databasesIntroduction to databases
Introduction to databasesBryan Corpuz
 
Er model ppt
Er model pptEr model ppt
Er model pptPihu Goel
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts Bharat Kalia
 
Basic Concept of Database
Basic Concept of DatabaseBasic Concept of Database
Basic Concept of DatabaseMarlon Jamera
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity ConstraintsMegha yadav
 
data modeling and models
data modeling and modelsdata modeling and models
data modeling and modelssabah N
 
Introduction to Database
Introduction to DatabaseIntroduction to Database
Introduction to DatabaseSiti Ismail
 
Database Normalization
Database NormalizationDatabase Normalization
Database NormalizationArun Sharma
 
Nested Queries Lecture
Nested Queries LectureNested Queries Lecture
Nested Queries LectureFelipe Costa
 

Was ist angesagt? (20)

Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 
Degree of relationship set
Degree of relationship setDegree of relationship set
Degree of relationship set
 
Data models
Data modelsData models
Data models
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
 
Data models
Data modelsData models
Data models
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Introduction to databases
Introduction to databasesIntroduction to databases
Introduction to databases
 
Er model ppt
Er model pptEr model ppt
Er model ppt
 
Advantages of DBMS
Advantages of DBMSAdvantages of DBMS
Advantages of DBMS
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts
 
ER Model in DBMS
ER Model in DBMSER Model in DBMS
ER Model in DBMS
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
Basic Concept of Database
Basic Concept of DatabaseBasic Concept of Database
Basic Concept of Database
 
Rdbms
RdbmsRdbms
Rdbms
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
data modeling and models
data modeling and modelsdata modeling and models
data modeling and models
 
Introduction to Database
Introduction to DatabaseIntroduction to Database
Introduction to Database
 
Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
 
Nested Queries Lecture
Nested Queries LectureNested Queries Lecture
Nested Queries Lecture
 
View of data DBMS
View of data DBMSView of data DBMS
View of data DBMS
 

Andere mochten auch

Cardinality and participation constraints
Cardinality and participation constraintsCardinality and participation constraints
Cardinality and participation constraintsNikhil Deswal
 
Relational database management system (rdbms) i
Relational database management system (rdbms) iRelational database management system (rdbms) i
Relational database management system (rdbms) iRavinder Kamboj
 
Urinary system embryology
Urinary system embryologyUrinary system embryology
Urinary system embryologyishtiaqqazi
 
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 MulhallJohn 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...Mustafa Kamel Mohammadi
 
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
 
Introduction to RDBMS
Introduction to RDBMSIntroduction to RDBMS
Introduction to RDBMSSarmad Ali
 
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 constraintsKumar
 
3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMSkoolkampus
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMSkoolkampus
 
Rdbms
RdbmsRdbms
Rdbmsrdbms
 

Andere mochten auch (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
 

Ähnlich wie Database : Relational Data Model

Ähnlich wie Database : Relational Data Model (20)

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
 
Mysql tutorial
Mysql tutorialMysql tutorial
Mysql tutorial
 

Kürzlich hochgeladen

Secure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech LabsSecure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech Labsamber724300
 
STATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectSTATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectGayathriM270621
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Coursebim.edu.pl
 
Curve setting (Basic Mine Surveying)_MI10412MI.pptx
Curve setting (Basic Mine Surveying)_MI10412MI.pptxCurve setting (Basic Mine Surveying)_MI10412MI.pptx
Curve setting (Basic Mine Surveying)_MI10412MI.pptxRomil Mishra
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdfHafizMudaserAhmad
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmDeepika Walanjkar
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONjhunlian
 
Theory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfTheory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfShreyas Pandit
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Communityprachaibot
 
List of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfList of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfisabel213075
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSneha Padhiar
 
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSHigh Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSsandhya757531
 
A brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProA brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProRay Yuan Liu
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptxmohitesoham12
 
Forming section troubleshooting checklist for improving wire life (1).ppt
Forming section troubleshooting checklist for improving wire life (1).pptForming section troubleshooting checklist for improving wire life (1).ppt
Forming section troubleshooting checklist for improving wire life (1).pptNoman khan
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...Erbil Polytechnic University
 
Javier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier Fernández Muñoz
 
Artificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewArtificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewsandhya757531
 
Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Romil Mishra
 

Kürzlich hochgeladen (20)

Secure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech LabsSecure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech Labs
 
STATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectSTATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subject
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Course
 
Curve setting (Basic Mine Surveying)_MI10412MI.pptx
Curve setting (Basic Mine Surveying)_MI10412MI.pptxCurve setting (Basic Mine Surveying)_MI10412MI.pptx
Curve setting (Basic Mine Surveying)_MI10412MI.pptx
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
 
Theory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfTheory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdf
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Community
 
List of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfList of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdf
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
 
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSHigh Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
 
A brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProA brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision Pro
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptx
 
Forming section troubleshooting checklist for improving wire life (1).ppt
Forming section troubleshooting checklist for improving wire life (1).pptForming section troubleshooting checklist for improving wire life (1).ppt
Forming section troubleshooting checklist for improving wire life (1).ppt
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...
 
Javier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptx
 
Artificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewArtificial Intelligence in Power System overview
Artificial Intelligence in Power System overview
 
Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________
 

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.

Hinweis der Redaktion

  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.