際際滷

際際滷Share a Scribd company logo
RELATIONAL MODEL-CONT
Additional to Chapter 2
ICT 2073
Prepare by : Ms. Siti Hajar Binti Ismail
RELATIONAL QUERY LANGUAGES
 Query languages: Allow manipulation and retrieval of data from a
database.
 Relational model supports simple, powerful QLs:
 Strong formal foundation based on logic.
 Allows for much optimization.
 Query Languages != programming languages!
 QLs not expected to be Turing complete.
 QLs not intended to be used for complex calculations.
 QLs support easy, efficient access to large data sets.
FORMAL RELATIONAL QUERY LANGUAGES
 Two mathematical Query Languages form the basis for
real languages (e.g. SQL), and for implementation:
 Relational Algebra: More operational (procedural), very useful
for representing execution plans.
 Relational Calculus: Lets users describe what they want,
rather than how to compute it: Non-operational, declarative.
PRELIMINARIES
 A query is applied to relation instances, and the result of
a query is also a relation instance.
 Schemas of input relations for a query are fixed.
 The schema for the result of a given query is also fixed! -
determined by definition of query language constructs.
 Positional vs. named-field notation:
 Positional notation easier for formal definitions, named-field
notation more readable.
 Both used in SQL
EXAMPLE INSTANCES
 Sailors and Reserves
relations for our examples.
 Well use positional or named
field notation, assume that
names of fields in query results
are `inherited from names of
fields in query input relations.
sid sname rating age
22 dustin 7 45.0
31 lubber 8 55.5
58 rusty 10 35.0
sid sname rating age
28 yuppy 9 35.0
31 lubber 8 55.5
44 guppy 5 35.0
58 rusty 10 35.0
sid bid day
22 101 10/10/96
58 103 11/12/96
R1
S1
S2
RELATIONAL ALGEBRA
 Basic operations:
 Selection ( ) Selects a subset of rows from relation.
 Projection ( ) Deletes unwanted columns from relation.
 Cross-product ( ) Allows us to combine two relations.
 Set-difference ( ) Tuples in reln. 1, but not in reln. 2.
 Union ( ) Tuples in reln. 1 and in reln. 2.
 Additional operations:
 Intersection, join, division, renaming: Not essential, but (very!) useful.
 Since each operation returns a relation, operations can be composed:
algebra is closed.
PROJECTION
 Deletes attributes that are not in
projection list.
 Schema of result contains exactly the
fields in the projection list, with the same
names that they had in the input relation.
 Projection operator has to eliminate
duplicates! real systems typically dont do
duplicate elimination unless the user
explicitly asks for it (by DISTINCT).
sname rating
yuppy 9
lubber 8
guppy 5
rusty 10
sname rating
S
,
( )2
age
35.0
55.5
age S( )2
SELECTION
 Selects rows that satisfy
selection condition.
 No duplicates in result! Why?
 Schema of result identical to
schema of input relation.
 What is Operator
composition?
 Selection is distributive over
binary operators
 Selection is commutative
rating
S
8
2( )
sid sname rating age
28 yuppy 9 35.0
58 rusty 10 35.0
sname rating
yuppy 9
rusty 10
 sname rating rating
S
,
( ( ))
8
2
UNION, INTERSECTION, SET-DIFFERENCE
 All of these operations take
two input relations, which
must be union-compatible:
 Same number of fields.
 `Corresponding fields have
the same type.
 What is the schema of
result?
sid sname rating age
22 dustin 7 45.0
31 lubber 8 55.5
58 rusty 10 35.0
44 guppy 5 35.0
28 yuppy 9 35.0
sid sname rating age
31 lubber 8 55.5
58 rusty 10 35.0
S S1 2
S S1 2
sid sname rating age
22 dustin 7 45.0
S S1 2
CROSS-PRODUCT (CARTESIAN PRODUCT)
 Each row of S1 is paired with each row of R1.
 Result schema has one field per field of S1 and R1, with field names
`inherited if possible.
 Conflict: Both S1 and R1 have a field called sid.
 ( ( , ), )C sid sid S R1 1 5 2 1 1  
(sid) sname rating age (sid) bid day
22 dustin 7 45.0 22 101 10/10/96
22 dustin 7 45.0 58 103 11/12/96
31 lubber 8 55.5 22 101 10/10/96
31 lubber 8 55.5 58 103 11/12/96
58 rusty 10 35.0 22 101 10/10/96
58 rusty 10 35.0 58 103 11/12/96
 Renaming operator:
JOINS: USED TO COMBINE RELATIONS
 Condition Join:
 Result schema same as that of cross-product.
 Fewer tuples than cross-product, might be able to compute more
efficiently
 Sometimes called a theta-join.
R c S c R S常  器 ( )
(sid) sname rating age (sid) bid day
22 dustin 7 45.0 58 103 11/12/96
31 lubber 8 55.5 58 103 11/12/96
S R
S sid R sid
1 1
1 1
常
. .
JOIN
 Equi-Join: A special case of condition join where the condition c
contains only equalities.
 Result schema similar to cross-product, but only one copy
of fields for which equality is specified.
 Natural Join: Equijoin on all common fields.
sid sname rating age bid day
22 dustin 7 45.0 101 10/10/96
58 rusty 10 35.0 103 11/12/96
S R
sid
1 1常
PROPERTIES OF JOIN
 Selecting power: can join be used for selection?
 Is join commutative? = ?
 Is join associative?
 Join and projection perform complementary
functions
 Lossless and lossy decomposition
11 RS 種 11 SR 種
?1)11()11(1 CRSCRS 種常種常種常種
DIVISION
 Not supported as a primitive operator, but useful for expressing queries like:
Find sailors who have reserved all boats.
 Let A have 2 fields, x and y; B have only field y:
 A/B =
 i.e., A/B contains all x tuples (sailors) such that for every y tuple (boat)
in B, there is an xy tuple in A.
 Or: If the set of y values (boats) associated with an x value (sailor) in A
contains all y values in B, the x value is in A/B.
 In general, x and y can be any lists of fields; y is the list of fields in B, and x
y is the list of fields of A.
 x x y A y B| ,
EXAMPLES OF DIVISION A/B
sno pno
s1 p1
s1 p2
s1 p3
s1 p4
s2 p1
s2 p2
s3 p2
s4 p2
s4 p4
pno
p2
pno
p2
p4
pno
p1
p2
p4
sno
s1
s2
s3
s4
sno
s1
s4
sno
s1
A
B1
B2
B3
A/B1 A/B2 A/B3
EXAMPLE OF DIVISION
 Find all customers who have an account at all
branches located in Chville
 Branch (bname, assets, bcity)
 Account (bname, acct#, cname, balance)
EXAMPLE OF DIVISION
R1: Find all branches in Chville
R2: Find (bname, cname) pair from Account
R3: Customers in r2 with every branch name in r1
123
)(2
)(1
,
''
rrr
Accountr
r
cnamebname
Branch
Chvillebcitybname
醐




鰹
EXPRESSING A/B USING BASIC OPERATORS
 Division is not essential op; just a useful shorthand.
 Also true of joins, but joins are so common that systems implement
joins specially.
 Idea: For A/B, compute all x values that are not `disqualified by some y
value in B.
 x value is disqualified if by attaching y value from B, we obtain an xy
tuple that is not in A.
Disqualified x values:
A/B:
)))((( ABAxx 器逸
 x A( )  all disqualified tuples
SUMMARY OF RELATIONAL ALGEBRA
 The relational model has rigorously defined query
languages that are simple and powerful.
 Relational algebra is more operational; useful as
internal representation for query evaluation plans.
 Several ways of expressing a given query; a query
optimizer should choose the most efficient version.

More Related Content

What's hot (20)

Polymorphic Table Functions in 18c
Polymorphic Table Functions in 18cPolymorphic Table Functions in 18c
Polymorphic Table Functions in 18c
Andrej Pashchenko
R Markdown Tutorial For Beginners
R Markdown Tutorial For BeginnersR Markdown Tutorial For Beginners
R Markdown Tutorial For Beginners
Rsquared Academy
R Programming: Introduction to Matrices
R Programming: Introduction to MatricesR Programming: Introduction to Matrices
R Programming: Introduction to Matrices
Rsquared Academy
Back patching
Back patchingBack patching
Back patching
santhiya thavanthi
SKEL 4273 CAD with HDL Topic 2
SKEL 4273 CAD with HDL Topic 2SKEL 4273 CAD with HDL Topic 2
SKEL 4273 CAD with HDL Topic 2
alhadi81
SKEL 4273 CAD with HDL Topic 3
SKEL 4273 CAD with HDL Topic 3SKEL 4273 CAD with HDL Topic 3
SKEL 4273 CAD with HDL Topic 3
alhadi81
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)
Tasif Tanzim
C++ presentation
C++ presentationC++ presentation
C++ presentation
SudhanshuVijay3
Intermediate code
Intermediate codeIntermediate code
Intermediate code
Vishal Agarwal
C# operators
C# operatorsC# operators
C# operators
baabtra.com - No. 1 supplier of quality freshers
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generation
Vipul Naik
Lecture 2 C++ | Variable Scope, Operators in c++
Lecture 2 C++ | Variable Scope, Operators in c++Lecture 2 C++ | Variable Scope, Operators in c++
Lecture 2 C++ | Variable Scope, Operators in c++
Himanshu Kaushik
Theory of Computation FSM Grammar Minimisation and Normal Forms
Theory of Computation FSM Grammar Minimisation and Normal FormsTheory of Computation FSM Grammar Minimisation and Normal Forms
Theory of Computation FSM Grammar Minimisation and Normal Forms
Rushabh2428
Control flow Graph
Control flow GraphControl flow Graph
Control flow Graph
Md Arif Hasan
A Benchmark for Interpretability Methods in Deep Neural Networks
A Benchmark for Interpretability Methods in Deep Neural NetworksA Benchmark for Interpretability Methods in Deep Neural Networks
A Benchmark for Interpretability Methods in Deep Neural Networks
Sungchul Kim
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomesh
praveensomesh
Lecture 12 intermediate code generation
Lecture 12 intermediate code generationLecture 12 intermediate code generation
Lecture 12 intermediate code generation
Iffat Anjum
FP305 data structure PAPER FINAL SEM 3
FP305 data structure PAPER FINAL SEM 3FP305 data structure PAPER FINAL SEM 3
FP305 data structure PAPER FINAL SEM 3
Syahriha Ruslan
Basic blocks and control flow graphs
Basic blocks and control flow graphsBasic blocks and control flow graphs
Basic blocks and control flow graphs
Tilakpoudel2
DBMS - Relational Algebra
DBMS - Relational AlgebraDBMS - Relational Algebra
DBMS - Relational Algebra
MythiliMurugan3
Polymorphic Table Functions in 18c
Polymorphic Table Functions in 18cPolymorphic Table Functions in 18c
Polymorphic Table Functions in 18c
Andrej Pashchenko
R Markdown Tutorial For Beginners
R Markdown Tutorial For BeginnersR Markdown Tutorial For Beginners
R Markdown Tutorial For Beginners
Rsquared Academy
R Programming: Introduction to Matrices
R Programming: Introduction to MatricesR Programming: Introduction to Matrices
R Programming: Introduction to Matrices
Rsquared Academy
SKEL 4273 CAD with HDL Topic 2
SKEL 4273 CAD with HDL Topic 2SKEL 4273 CAD with HDL Topic 2
SKEL 4273 CAD with HDL Topic 2
alhadi81
SKEL 4273 CAD with HDL Topic 3
SKEL 4273 CAD with HDL Topic 3SKEL 4273 CAD with HDL Topic 3
SKEL 4273 CAD with HDL Topic 3
alhadi81
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)
Tasif Tanzim
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generation
Vipul Naik
Lecture 2 C++ | Variable Scope, Operators in c++
Lecture 2 C++ | Variable Scope, Operators in c++Lecture 2 C++ | Variable Scope, Operators in c++
Lecture 2 C++ | Variable Scope, Operators in c++
Himanshu Kaushik
Theory of Computation FSM Grammar Minimisation and Normal Forms
Theory of Computation FSM Grammar Minimisation and Normal FormsTheory of Computation FSM Grammar Minimisation and Normal Forms
Theory of Computation FSM Grammar Minimisation and Normal Forms
Rushabh2428
Control flow Graph
Control flow GraphControl flow Graph
Control flow Graph
Md Arif Hasan
A Benchmark for Interpretability Methods in Deep Neural Networks
A Benchmark for Interpretability Methods in Deep Neural NetworksA Benchmark for Interpretability Methods in Deep Neural Networks
A Benchmark for Interpretability Methods in Deep Neural Networks
Sungchul Kim
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomesh
praveensomesh
Lecture 12 intermediate code generation
Lecture 12 intermediate code generationLecture 12 intermediate code generation
Lecture 12 intermediate code generation
Iffat Anjum
FP305 data structure PAPER FINAL SEM 3
FP305 data structure PAPER FINAL SEM 3FP305 data structure PAPER FINAL SEM 3
FP305 data structure PAPER FINAL SEM 3
Syahriha Ruslan
Basic blocks and control flow graphs
Basic blocks and control flow graphsBasic blocks and control flow graphs
Basic blocks and control flow graphs
Tilakpoudel2
DBMS - Relational Algebra
DBMS - Relational AlgebraDBMS - Relational Algebra
DBMS - Relational Algebra
MythiliMurugan3

Similar to Relational Model (20)

Relational Algebra and Calculus.ppt
Relational Algebra and Calculus.pptRelational Algebra and Calculus.ppt
Relational Algebra and Calculus.ppt
Ankush138
uniT 4 (1).pptx
uniT 4 (1).pptxuniT 4 (1).pptx
uniT 4 (1).pptx
YashWaghmare27
Algebra
AlgebraAlgebra
Algebra
Hira Maharjan
DB LECTURE 7 Relational Algebra.pptx
DB LECTURE 7     Relational Algebra.pptxDB LECTURE 7     Relational Algebra.pptx
DB LECTURE 7 Relational Algebra.pptx
grahamoyigo19
U-2.pptx igxitditdursruzyezrzmyayeTeYrsyrsurzursursursursursrusursruzruRuUeYe...
U-2.pptx igxitditdursruzyezrzmyayeTeYrsyrsurzursursursursursrusursruzruRuUeYe...U-2.pptx igxitditdursruzyezrzmyayeTeYrsyrsurzursursursursursrusursruzruRuUeYe...
U-2.pptx igxitditdursruzyezrzmyayeTeYrsyrsurzursursursursursrusursruzruRuUeYe...
dagadsai0330
Relational Algebra
Relational AlgebraRelational Algebra
Relational Algebra
SahilKaushik27
Cs501 rel algebra
Cs501 rel algebraCs501 rel algebra
Cs501 rel algebra
Kamal Singh Lodhi
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
Radhika Talaviya
Chapter 5 Relational Algebra.pdf
Chapter  5 Relational Algebra.pdfChapter  5 Relational Algebra.pdf
Chapter 5 Relational Algebra.pdf
TamiratDejene1
Ch7
Ch7Ch7
Ch7
muteddy
Unit04 dbms
Unit04 dbmsUnit04 dbms
Unit04 dbms
arnold 7490
Lecture 06 relational algebra and calculus
Lecture 06 relational algebra and calculusLecture 06 relational algebra and calculus
Lecture 06 relational algebra and calculus
emailharmeet
ch14.ppt
ch14.pptch14.ppt
ch14.ppt
ssuser67281d
Ch4_Algebra.pdf
Ch4_Algebra.pdfCh4_Algebra.pdf
Ch4_Algebra.pdf
Jyothi Jangam
database management system presentation on integrity constraints
database management system presentation on integrity constraintsdatabase management system presentation on integrity constraints
database management system presentation on integrity constraints
MadhaviNandikonda
Bt0066 database management system2
Bt0066 database management system2Bt0066 database management system2
Bt0066 database management system2
Techglyphs
Relational algebra
Relational algebraRelational algebra
Relational algebra
Edward Blurock
Relational Algebra.pptx for Module four
Relational Algebra.pptx for  Module fourRelational Algebra.pptx for  Module four
Relational Algebra.pptx for Module four
Monaliaghosh
Relational Algebra and it's Operations pptx
Relational Algebra and it's Operations pptxRelational Algebra and it's Operations pptx
Relational Algebra and it's Operations pptx
danishriasat792
DBMS CS3
DBMS CS3DBMS CS3
DBMS CS3
Infinity Tech Solutions
Relational Algebra and Calculus.ppt
Relational Algebra and Calculus.pptRelational Algebra and Calculus.ppt
Relational Algebra and Calculus.ppt
Ankush138
DB LECTURE 7 Relational Algebra.pptx
DB LECTURE 7     Relational Algebra.pptxDB LECTURE 7     Relational Algebra.pptx
DB LECTURE 7 Relational Algebra.pptx
grahamoyigo19
U-2.pptx igxitditdursruzyezrzmyayeTeYrsyrsurzursursursursursrusursruzruRuUeYe...
U-2.pptx igxitditdursruzyezrzmyayeTeYrsyrsurzursursursursursrusursruzruRuUeYe...U-2.pptx igxitditdursruzyezrzmyayeTeYrsyrsurzursursursursursrusursruzruRuUeYe...
U-2.pptx igxitditdursruzyezrzmyayeTeYrsyrsurzursursursursursrusursruzruRuUeYe...
dagadsai0330
Chapter 5 Relational Algebra.pdf
Chapter  5 Relational Algebra.pdfChapter  5 Relational Algebra.pdf
Chapter 5 Relational Algebra.pdf
TamiratDejene1
Lecture 06 relational algebra and calculus
Lecture 06 relational algebra and calculusLecture 06 relational algebra and calculus
Lecture 06 relational algebra and calculus
emailharmeet
database management system presentation on integrity constraints
database management system presentation on integrity constraintsdatabase management system presentation on integrity constraints
database management system presentation on integrity constraints
MadhaviNandikonda
Bt0066 database management system2
Bt0066 database management system2Bt0066 database management system2
Bt0066 database management system2
Techglyphs
Relational Algebra.pptx for Module four
Relational Algebra.pptx for  Module fourRelational Algebra.pptx for  Module four
Relational Algebra.pptx for Module four
Monaliaghosh
Relational Algebra and it's Operations pptx
Relational Algebra and it's Operations pptxRelational Algebra and it's Operations pptx
Relational Algebra and it's Operations pptx
danishriasat792

Recently uploaded (20)

Blind Spots in AI and Formulation Science Knowledge Pyramid (Updated Perspect...
Blind Spots in AI and Formulation Science Knowledge Pyramid (Updated Perspect...Blind Spots in AI and Formulation Science Knowledge Pyramid (Updated Perspect...
Blind Spots in AI and Formulation Science Knowledge Pyramid (Updated Perspect...
Ajaz Hussain
How to Setup WhatsApp in Odoo 17 - Odoo 際際滷s
How to Setup WhatsApp in Odoo 17 - Odoo 際際滷sHow to Setup WhatsApp in Odoo 17 - Odoo 際際滷s
How to Setup WhatsApp in Odoo 17 - Odoo 際際滷s
Celine George
Essentials of a Good PMO, presented by Aalok Sonawala
Essentials of a Good PMO, presented by Aalok SonawalaEssentials of a Good PMO, presented by Aalok Sonawala
Essentials of a Good PMO, presented by Aalok Sonawala
Association for Project Management
QuickBooks Desktop to QuickBooks Online How to Make the Move
QuickBooks Desktop to QuickBooks Online  How to Make the MoveQuickBooks Desktop to QuickBooks Online  How to Make the Move
QuickBooks Desktop to QuickBooks Online How to Make the Move
TechSoup
How to attach file using upload button Odoo 18
How to attach file using upload button Odoo 18How to attach file using upload button Odoo 18
How to attach file using upload button Odoo 18
Celine George
Lesson Plan M1 2024 Lesson Plan M1 2024 Lesson Plan M1 2024 Lesson Plan M1...
Lesson Plan M1 2024  Lesson Plan M1 2024  Lesson Plan M1 2024  Lesson Plan M1...Lesson Plan M1 2024  Lesson Plan M1 2024  Lesson Plan M1 2024  Lesson Plan M1...
Lesson Plan M1 2024 Lesson Plan M1 2024 Lesson Plan M1 2024 Lesson Plan M1...
pinkdvil200
How to Configure Restaurants in Odoo 17 Point of Sale
How to Configure Restaurants in Odoo 17 Point of SaleHow to Configure Restaurants in Odoo 17 Point of Sale
How to Configure Restaurants in Odoo 17 Point of Sale
Celine George
The Dravidian Languages: Tamil, Telugu, Kannada, Malayalam, Brahui, Kuvi, Tulu
The Dravidian Languages: Tamil, Telugu, Kannada, Malayalam, Brahui, Kuvi, TuluThe Dravidian Languages: Tamil, Telugu, Kannada, Malayalam, Brahui, Kuvi, Tulu
The Dravidian Languages: Tamil, Telugu, Kannada, Malayalam, Brahui, Kuvi, Tulu
DrIArulAram
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptxTLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
RizaBedayo
TPR Data strategy 2025 (1).pdf Data strategy
TPR Data strategy 2025 (1).pdf Data strategyTPR Data strategy 2025 (1).pdf Data strategy
TPR Data strategy 2025 (1).pdf Data strategy
Henry Tapper
Kaun TALHA quiz Prelims - El Dorado 2025
Kaun TALHA quiz Prelims - El Dorado 2025Kaun TALHA quiz Prelims - El Dorado 2025
Kaun TALHA quiz Prelims - El Dorado 2025
Conquiztadors- the Quiz Society of Sri Venkateswara College
The Constitution, Government and Law making bodies .
The Constitution, Government and Law making bodies .The Constitution, Government and Law making bodies .
The Constitution, Government and Law making bodies .
saanidhyapatel09
Year 10 The Senior Phase Session 3 Term 1.pptx
Year 10 The Senior Phase Session 3 Term 1.pptxYear 10 The Senior Phase Session 3 Term 1.pptx
Year 10 The Senior Phase Session 3 Term 1.pptx
mansk2
Adventure Activities Final By H R Gohil Sir
Adventure Activities Final By H R Gohil SirAdventure Activities Final By H R Gohil Sir
Adventure Activities Final By H R Gohil Sir
GUJARATCOMMERCECOLLE
TRANSFER OF PATIENTS IN HOSPITAL SETTING.pptx
TRANSFER OF PATIENTS IN HOSPITAL SETTING.pptxTRANSFER OF PATIENTS IN HOSPITAL SETTING.pptx
TRANSFER OF PATIENTS IN HOSPITAL SETTING.pptx
PoojaSen20
CRITICAL THINKING AND NURSING JUDGEMENT.pptx
CRITICAL THINKING AND NURSING JUDGEMENT.pptxCRITICAL THINKING AND NURSING JUDGEMENT.pptx
CRITICAL THINKING AND NURSING JUDGEMENT.pptx
PoojaSen20
Useful environment methods in Odoo 18 - Odoo 際際滷s
Useful environment methods in Odoo 18 - Odoo 際際滷sUseful environment methods in Odoo 18 - Odoo 際際滷s
Useful environment methods in Odoo 18 - Odoo 際際滷s
Celine George
cervical spine mobilization manual therapy .pdf
cervical spine mobilization manual therapy .pdfcervical spine mobilization manual therapy .pdf
cervical spine mobilization manual therapy .pdf
SamarHosni3
English 4 Quarter 4 Week 4 Classroom Obs
English 4 Quarter 4 Week 4 Classroom ObsEnglish 4 Quarter 4 Week 4 Classroom Obs
English 4 Quarter 4 Week 4 Classroom Obs
NerissaMendez1
How to use Init Hooks in Odoo 18 - Odoo 際際滷s
How to use Init Hooks in Odoo 18 - Odoo 際際滷sHow to use Init Hooks in Odoo 18 - Odoo 際際滷s
How to use Init Hooks in Odoo 18 - Odoo 際際滷s
Celine George
Blind Spots in AI and Formulation Science Knowledge Pyramid (Updated Perspect...
Blind Spots in AI and Formulation Science Knowledge Pyramid (Updated Perspect...Blind Spots in AI and Formulation Science Knowledge Pyramid (Updated Perspect...
Blind Spots in AI and Formulation Science Knowledge Pyramid (Updated Perspect...
Ajaz Hussain
How to Setup WhatsApp in Odoo 17 - Odoo 際際滷s
How to Setup WhatsApp in Odoo 17 - Odoo 際際滷sHow to Setup WhatsApp in Odoo 17 - Odoo 際際滷s
How to Setup WhatsApp in Odoo 17 - Odoo 際際滷s
Celine George
QuickBooks Desktop to QuickBooks Online How to Make the Move
QuickBooks Desktop to QuickBooks Online  How to Make the MoveQuickBooks Desktop to QuickBooks Online  How to Make the Move
QuickBooks Desktop to QuickBooks Online How to Make the Move
TechSoup
How to attach file using upload button Odoo 18
How to attach file using upload button Odoo 18How to attach file using upload button Odoo 18
How to attach file using upload button Odoo 18
Celine George
Lesson Plan M1 2024 Lesson Plan M1 2024 Lesson Plan M1 2024 Lesson Plan M1...
Lesson Plan M1 2024  Lesson Plan M1 2024  Lesson Plan M1 2024  Lesson Plan M1...Lesson Plan M1 2024  Lesson Plan M1 2024  Lesson Plan M1 2024  Lesson Plan M1...
Lesson Plan M1 2024 Lesson Plan M1 2024 Lesson Plan M1 2024 Lesson Plan M1...
pinkdvil200
How to Configure Restaurants in Odoo 17 Point of Sale
How to Configure Restaurants in Odoo 17 Point of SaleHow to Configure Restaurants in Odoo 17 Point of Sale
How to Configure Restaurants in Odoo 17 Point of Sale
Celine George
The Dravidian Languages: Tamil, Telugu, Kannada, Malayalam, Brahui, Kuvi, Tulu
The Dravidian Languages: Tamil, Telugu, Kannada, Malayalam, Brahui, Kuvi, TuluThe Dravidian Languages: Tamil, Telugu, Kannada, Malayalam, Brahui, Kuvi, Tulu
The Dravidian Languages: Tamil, Telugu, Kannada, Malayalam, Brahui, Kuvi, Tulu
DrIArulAram
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptxTLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
RizaBedayo
TPR Data strategy 2025 (1).pdf Data strategy
TPR Data strategy 2025 (1).pdf Data strategyTPR Data strategy 2025 (1).pdf Data strategy
TPR Data strategy 2025 (1).pdf Data strategy
Henry Tapper
The Constitution, Government and Law making bodies .
The Constitution, Government and Law making bodies .The Constitution, Government and Law making bodies .
The Constitution, Government and Law making bodies .
saanidhyapatel09
Year 10 The Senior Phase Session 3 Term 1.pptx
Year 10 The Senior Phase Session 3 Term 1.pptxYear 10 The Senior Phase Session 3 Term 1.pptx
Year 10 The Senior Phase Session 3 Term 1.pptx
mansk2
Adventure Activities Final By H R Gohil Sir
Adventure Activities Final By H R Gohil SirAdventure Activities Final By H R Gohil Sir
Adventure Activities Final By H R Gohil Sir
GUJARATCOMMERCECOLLE
TRANSFER OF PATIENTS IN HOSPITAL SETTING.pptx
TRANSFER OF PATIENTS IN HOSPITAL SETTING.pptxTRANSFER OF PATIENTS IN HOSPITAL SETTING.pptx
TRANSFER OF PATIENTS IN HOSPITAL SETTING.pptx
PoojaSen20
CRITICAL THINKING AND NURSING JUDGEMENT.pptx
CRITICAL THINKING AND NURSING JUDGEMENT.pptxCRITICAL THINKING AND NURSING JUDGEMENT.pptx
CRITICAL THINKING AND NURSING JUDGEMENT.pptx
PoojaSen20
Useful environment methods in Odoo 18 - Odoo 際際滷s
Useful environment methods in Odoo 18 - Odoo 際際滷sUseful environment methods in Odoo 18 - Odoo 際際滷s
Useful environment methods in Odoo 18 - Odoo 際際滷s
Celine George
cervical spine mobilization manual therapy .pdf
cervical spine mobilization manual therapy .pdfcervical spine mobilization manual therapy .pdf
cervical spine mobilization manual therapy .pdf
SamarHosni3
English 4 Quarter 4 Week 4 Classroom Obs
English 4 Quarter 4 Week 4 Classroom ObsEnglish 4 Quarter 4 Week 4 Classroom Obs
English 4 Quarter 4 Week 4 Classroom Obs
NerissaMendez1
How to use Init Hooks in Odoo 18 - Odoo 際際滷s
How to use Init Hooks in Odoo 18 - Odoo 際際滷sHow to use Init Hooks in Odoo 18 - Odoo 際際滷s
How to use Init Hooks in Odoo 18 - Odoo 際際滷s
Celine George

Relational Model

  • 1. RELATIONAL MODEL-CONT Additional to Chapter 2 ICT 2073 Prepare by : Ms. Siti Hajar Binti Ismail
  • 2. RELATIONAL QUERY LANGUAGES Query languages: Allow manipulation and retrieval of data from a database. Relational model supports simple, powerful QLs: Strong formal foundation based on logic. Allows for much optimization. Query Languages != programming languages! QLs not expected to be Turing complete. QLs not intended to be used for complex calculations. QLs support easy, efficient access to large data sets.
  • 3. FORMAL RELATIONAL QUERY LANGUAGES Two mathematical Query Languages form the basis for real languages (e.g. SQL), and for implementation: Relational Algebra: More operational (procedural), very useful for representing execution plans. Relational Calculus: Lets users describe what they want, rather than how to compute it: Non-operational, declarative.
  • 4. PRELIMINARIES A query is applied to relation instances, and the result of a query is also a relation instance. Schemas of input relations for a query are fixed. The schema for the result of a given query is also fixed! - determined by definition of query language constructs. Positional vs. named-field notation: Positional notation easier for formal definitions, named-field notation more readable. Both used in SQL
  • 5. EXAMPLE INSTANCES Sailors and Reserves relations for our examples. Well use positional or named field notation, assume that names of fields in query results are `inherited from names of fields in query input relations. sid sname rating age 22 dustin 7 45.0 31 lubber 8 55.5 58 rusty 10 35.0 sid sname rating age 28 yuppy 9 35.0 31 lubber 8 55.5 44 guppy 5 35.0 58 rusty 10 35.0 sid bid day 22 101 10/10/96 58 103 11/12/96 R1 S1 S2
  • 6. RELATIONAL ALGEBRA Basic operations: Selection ( ) Selects a subset of rows from relation. Projection ( ) Deletes unwanted columns from relation. Cross-product ( ) Allows us to combine two relations. Set-difference ( ) Tuples in reln. 1, but not in reln. 2. Union ( ) Tuples in reln. 1 and in reln. 2. Additional operations: Intersection, join, division, renaming: Not essential, but (very!) useful. Since each operation returns a relation, operations can be composed: algebra is closed.
  • 7. PROJECTION Deletes attributes that are not in projection list. Schema of result contains exactly the fields in the projection list, with the same names that they had in the input relation. Projection operator has to eliminate duplicates! real systems typically dont do duplicate elimination unless the user explicitly asks for it (by DISTINCT). sname rating yuppy 9 lubber 8 guppy 5 rusty 10 sname rating S , ( )2 age 35.0 55.5 age S( )2
  • 8. SELECTION Selects rows that satisfy selection condition. No duplicates in result! Why? Schema of result identical to schema of input relation. What is Operator composition? Selection is distributive over binary operators Selection is commutative rating S 8 2( ) sid sname rating age 28 yuppy 9 35.0 58 rusty 10 35.0 sname rating yuppy 9 rusty 10 sname rating rating S , ( ( )) 8 2
  • 9. UNION, INTERSECTION, SET-DIFFERENCE All of these operations take two input relations, which must be union-compatible: Same number of fields. `Corresponding fields have the same type. What is the schema of result? sid sname rating age 22 dustin 7 45.0 31 lubber 8 55.5 58 rusty 10 35.0 44 guppy 5 35.0 28 yuppy 9 35.0 sid sname rating age 31 lubber 8 55.5 58 rusty 10 35.0 S S1 2 S S1 2 sid sname rating age 22 dustin 7 45.0 S S1 2
  • 10. CROSS-PRODUCT (CARTESIAN PRODUCT) Each row of S1 is paired with each row of R1. Result schema has one field per field of S1 and R1, with field names `inherited if possible. Conflict: Both S1 and R1 have a field called sid. ( ( , ), )C sid sid S R1 1 5 2 1 1 (sid) sname rating age (sid) bid day 22 dustin 7 45.0 22 101 10/10/96 22 dustin 7 45.0 58 103 11/12/96 31 lubber 8 55.5 22 101 10/10/96 31 lubber 8 55.5 58 103 11/12/96 58 rusty 10 35.0 22 101 10/10/96 58 rusty 10 35.0 58 103 11/12/96 Renaming operator:
  • 11. JOINS: USED TO COMBINE RELATIONS Condition Join: Result schema same as that of cross-product. Fewer tuples than cross-product, might be able to compute more efficiently Sometimes called a theta-join. R c S c R S常 器 ( ) (sid) sname rating age (sid) bid day 22 dustin 7 45.0 58 103 11/12/96 31 lubber 8 55.5 58 103 11/12/96 S R S sid R sid 1 1 1 1 常 . .
  • 12. JOIN Equi-Join: A special case of condition join where the condition c contains only equalities. Result schema similar to cross-product, but only one copy of fields for which equality is specified. Natural Join: Equijoin on all common fields. sid sname rating age bid day 22 dustin 7 45.0 101 10/10/96 58 rusty 10 35.0 103 11/12/96 S R sid 1 1常
  • 13. PROPERTIES OF JOIN Selecting power: can join be used for selection? Is join commutative? = ? Is join associative? Join and projection perform complementary functions Lossless and lossy decomposition 11 RS 種 11 SR 種 ?1)11()11(1 CRSCRS 種常種常種常種
  • 14. DIVISION Not supported as a primitive operator, but useful for expressing queries like: Find sailors who have reserved all boats. Let A have 2 fields, x and y; B have only field y: A/B = i.e., A/B contains all x tuples (sailors) such that for every y tuple (boat) in B, there is an xy tuple in A. Or: If the set of y values (boats) associated with an x value (sailor) in A contains all y values in B, the x value is in A/B. In general, x and y can be any lists of fields; y is the list of fields in B, and x y is the list of fields of A. x x y A y B| ,
  • 15. EXAMPLES OF DIVISION A/B sno pno s1 p1 s1 p2 s1 p3 s1 p4 s2 p1 s2 p2 s3 p2 s4 p2 s4 p4 pno p2 pno p2 p4 pno p1 p2 p4 sno s1 s2 s3 s4 sno s1 s4 sno s1 A B1 B2 B3 A/B1 A/B2 A/B3
  • 16. EXAMPLE OF DIVISION Find all customers who have an account at all branches located in Chville Branch (bname, assets, bcity) Account (bname, acct#, cname, balance)
  • 17. EXAMPLE OF DIVISION R1: Find all branches in Chville R2: Find (bname, cname) pair from Account R3: Customers in r2 with every branch name in r1 123 )(2 )(1 , '' rrr Accountr r cnamebname Branch Chvillebcitybname 醐 鰹
  • 18. EXPRESSING A/B USING BASIC OPERATORS Division is not essential op; just a useful shorthand. Also true of joins, but joins are so common that systems implement joins specially. Idea: For A/B, compute all x values that are not `disqualified by some y value in B. x value is disqualified if by attaching y value from B, we obtain an xy tuple that is not in A. Disqualified x values: A/B: )))((( ABAxx 器逸 x A( ) all disqualified tuples
  • 19. SUMMARY OF RELATIONAL ALGEBRA The relational model has rigorously defined query languages that are simple and powerful. Relational algebra is more operational; useful as internal representation for query evaluation plans. Several ways of expressing a given query; a query optimizer should choose the most efficient version.