SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Relational Model
Chapter 3
1
Relational Model
• Data are organized in two-dimensional tables called relations.
• The tables are related to each other.
• The most popular model.
2
• Relational data model first introduced by Ted Codd of IBM in 1970.
• It attracted attention due to its simplicity and mathematical
foundation.
• First commercial implementations of the relational model became
available in the early 1980s, such as the SQL/DS system on MVS
operating system by IBM and the Oracle DBMS.
• Current popular DBMSs include DB2 and Informix Dynamic Server (
from IBM), Oracle and Rdb (from Oracle), and SQL Server and Access
(from Microsoft).
3
• The relational model represents the database as a collection of
relations.
• A relation is a table of values, each row in the table represents a
collection of related data values.
• Each row in the table represents a fact that typically corresponds to a
real-world entity or relationship.
• The table name and column names are used to help to interpret the
meaning of values in each row.
4
• RDBMS (Relational Database Management System)
• external view
• The data are represented as a set of relations.
• A relation is a two-dimensional table.
• This doesn’t mean that data are stored as tables; the physical storage
of the datais independent of the way the data are logically organized.
5
• In the formal relational model terminology, a row is called a
tuple, a column header is called an attribute, and the table is called a
relation.
• The data type describing the types of values that can appear in
each column is represented by a domain of possible values.
• For example:
• Name: the set of character strings that represent names of persons.
• Employee_age: the possible ages of employees of a company; each must be
an integer between18 to 60.
• Grade_point: possible values of computed grade point average; each must a
real number between 0 to 4.
6
Properties of relation
• A relation, or table, in a relational database has certain properties. First off, its name must be
unique in the database, i.e. a database cannot contain multiple tables of the same name. Next,
each relation must have a set of columns or attributes, and it must have a set of rows to contain
the data. As with the table names, no attributes can have the same name.
• Next, no tuple (or row) can be a duplicate. In practice, a database might actually contain duplicate
rows, but there should be practices in place to avoid this, such as the use of unique primary keys
(next up).
• Given that a tuple cannot be a duplicate, it follows that a relation must contain at least one
attribute (or column) that identifies each tuple (or row) uniquely. This is usually the primary key.
This primary key cannot be duplicated. This means that no tuple can have the same unique,
primary key. The key cannot have a NULL value, which simply means that the value must be
known.
• Further, each cell, or field, must contain a single value. For example, you cannot enter something
like "Tom Smith" and expect the database to understand that you have a first and last name;
rather, the database will understand that the value of that cell is exactly what has been entered.
• Finally, all attributes—or columns—must be of the same domain, meaning that they must have
the same data type. You cannot mix a string and a number in a single cell.
• All these properties, or constraints, serve to ensure data integrity, important to maintain the
accuracy of data.
7
Schemas
• A database schema is the skeleton structure that represents the logical view of the entire
database. It defines how the data is organized and how the relations among them are associated.
It formulates all the constraints that are to be applied on the data.
• A database schema defines its entities and the relationship among them. It contains a descriptive
detail of the database, which can be depicted by means of schema diagrams. It’s the database
designers who design the schema to help programmers understand the database and make it
useful.
• A database schema can be divided broadly into two categories −
• Physical Database Schema − This schema pertains to the actual storage of data and its form of
storage like files, indices, etc. It defines how the data will be stored in a secondary storage.
• Logical Database Schema − This schema defines all the logical constraints that need to be applied
on the data stored. It defines tables, views, and integrity constraints.
•
8
Schema Diagram
9
Tuples
• A relation r of relation schema R(A 1 , A 2 , A 3 , ..., A n ), also denoted
by r(R), is a set of n-tuples, r = { t 1 , t 2 , t 3 ,... , t n }.
• Each n-tuple t is an ordered list of n values t = < t 1 , t 2 , t 3 ,... , t n >.
• The ithvalue of n-tuple t corresponds to the attribute A i .
• The terms relationintensionfor schema R and relation extension for a
relation state r(R) are commonly used.
10
Domains constraints
• Domain constraints specify that within each tuple, the value of each
attribute A must be an atomic value from the domain dom(A).
• This is specified as data types which includes standard numeric data
types integers, real numbers, characters, Booleans, fixed length
strings, variable length strings etc.
• These are specified in DDL statements.
11
Relational Algebra
• Relational algebra is a procedural query language, which takes instances of
relations as input and yields instances of relations as output. It uses operators to
perform queries. An operator can be either unary or binary. They accept
relations as their input and yield relations as their output. Relational algebra is
performed recursively on a relation and intermediate results are also considered
relations.
• The fundamental operations of relational algebra are as follows −
• Select
• Project
• Union
• Set different
• Cartesian product
• Rename
12
Select
• The SELECT operation is used to choose a subset of the tuples from a
relation that satisfies a selection condition.
• One can consider the SELECT operation to be a filter that keeps only
those tuples that satisfy a qualifying condition.
• For example, to select the EMPLOYEE tuples whose department is 4,
or those whose salary is greater than $30,000, we can individually
specify each of these two conditions with a SELECT operation as
follows:
• σ Dno=4 (EMPLOYEE)
• σ Salary>30000 (EMPLOYEE)
13
• In general, the SELECT operation is denoted by
• σ <selectioncondition> (R)
• where the symbol σ (sigma) is used to denote the SELECT operator and the
selection condition is a Boolean expression (condition) specified on the
attributes of relation R.
• Notice that R is generally a relational algebra expression whose result is a
relation—the simplest such expression is just the name of a database
relation.
• The relation resulting from the SELECT operation has the same attributes as
R.
• For example, to select the tuples for all employees who either work in
department 4 and make over $25,000 per year, or work in department 5 and
make over $30,000, we can specify the following SELECT operation:
• σ( Dno=4 AND Salary>25000) OR (Dno=5 AND Salary>30000 )(EMPLOYEE)
14
• An unaryoperation.
• It is applied to one single relationand creates another relation.
• The tuples in the resulting relationare a subset of the tuplesin the
original relation.
• Use some criteriato select
15
Project
• The PROJECT operation selects certain columns from the table and discards
the other columns.
• If we are interested in only certain attributes of a relation, we use the
PROJECT operation to project the relation over these attributes only.
• Therefore, the result of the PROJECT operation can be visualized as a
vertical partition of the relation into two relations:
• One has the needed columns (attributes) and contains the result of the
operation, and the other contains the discarded columns.
• For example, to list each employee’s first and last name and salary, we can
use the PROJECT operation as follows:
• π Lname, Fname, Salary (EMPLOYEE)
16
• The general form of the PROJECT operation is
• π <attribute list> (R)
• where π (pi) is the symbol used to represent the PROJECT operation, and <
attribute list > is the desired sub list of attributes from the attributes of
relation R.
• Again, notice that R is, in general, a relational algebra expression whose
result is a relation, which in the simplest case is just the name of a
database relation.
• The result of the PROJECT operation has only the attributes specified in
<attribute list> in the same order as they appear in the list.
• Hence, its degree is equal to the number of attributes in <attribute list>.
17
• An unaryoperation.
• It is applied to one single relationand creates another relation.
• The attributes in the resulting relationare a subset of the attributesin
the original relation.
18
Rename
• In general, for most queries, we need to apply several relational algebra operations one
after the other. Either we can write the operations as a single relational algebra
expression by nesting the operations, or we can apply one operation at a time and
create intermediate result relations.
• In the latter case, we must give names to the relations that hold the intermediate results.
• For example, to retrieve the first name, last name, and salary of all employees who work in
department number 5, we must apply a SELECT and a PROJECT operation.
• We can write a single relational algebra expression, also known as an in-line expression, as
follows:
• π Fname, Lname, Salary (σ Dno=5 (EMPLOYEE))
• Alternatively, we can explicitly show the sequence of operations, giving a name to each
intermediate relation, as follows:
• DEP5_EMPS ←σ Dno=5 (EMPLOYEE)
• RESULT ←π Fname, Lname, Salary (DEP5_EMPS)
19
Union, Intersection and Difference
• UNION: The result of this operation, denoted by R ∪S, is a relation
that includes all tuples that are either in R or in S or in both R and S.
Duplicate tuples are eliminated.
• INTERSECTION: The result of this operation, denoted by R ∩S, is a
relation that includes all tuples that are in both R and S.
• DIFFERENCE (or MINUS): The result of this operation, denoted by R –
S, is a relation that includes all tuples that are in R but not in S.
20
• For example, to retrieve the Social Security numbers of all employees
who either work in department 5 or directly supervise an employee
who works in department 5, we can use the UNION operation as
follows:
• DEP5_EMPS ←σ Dno=5 (EMPLOYEE)
• RESULT1 ←π Ssn (DEP5_EMPS)
• RESULT2 ←π Super_ssn (DEP5_EMPS)
• RESULT ←RESULT1 ∪RESULT2
21
Union
• A binary operation.
• Creates a new relation in which each tuple is either in the first relation, in
the second, or in both.
• The two relations must have the same attributes.
22
Intersection
• A binary operation.
• Creates a new relation in which each tuple is a member in both
relations.
• The two relations must have the same attributes.
23
Difference
• A binary operation.
• Creates a new relation in which each tuple is in the first relation but
not the second.
• The two relations must have the same attributes.
24
Cartesian Product
• This is also a binary set operation, but the relations on which it is applied
do not have to be union compatible.
• In its binary form, this set operation produces a new element by combining
every member (tuple) from one relation (set) with every member (tuple)
from the other relation (set).
• In general, the result of R(A1, A2, ..., An) ×S(B1, B2, ..., Bm) is a relation Q
with degree n + m attributes Q(A1, A2, ..., An, B1, B2, ..., Bm), in that order.
• The resulting relation Q has one tuple for each combination of tuples—one
from R and one from S.
• Hence, if R has n R tuples (denoted as |R| = n R ), and S has n S tuples, then
R ×S will have n R * n S tuples.
25
Join Operation
• The JOIN operation, denoted by , is used to combine related tuples from
two relations into single “longer” tuples.
• The JOIN operation can be specified as a CARTESIAN PRODUCT operation
followed by a SELECT operation.
• Suppose that we want to retrieve the name of the manager of each
department. To get the manager’s name, we need to combine each
department tuple with the employee tuple whose Ssnvalue matches the
Mgr_ssnvalue in the department tuple.
•Note that Mgr_ssnis a foreign key of the DEPARTMENT relation that
references Ssn, the primary key of the EMPLOYEE relation. This referential
integrity constraint plays a role in having matching tuples in the referenced
relation EMPLOYEE.
26
• The general form of a JOIN operation on two relations R(A1, A2, ..., An) and
S(B1, B2, ..., Bm) is
• R ⋈ <join condition> S
• The result of the JOIN is a relation Q with n + m attributes Q(A1, A2, ..., An,
B1, B2, ... , Bm) in that order; Q has one tuple for each combination of
tuples—one from R and one from S—whenever the combination satisfies
the join condition.
• This is the main difference between CARTESIAN PRODUCT and JOIN. In
JOIN, only combinations of tuples satisfying the join condition appear in
the result, whereas in the CARTESIAN PRODUCT all combinations of tuples
are included in the result.
• The join condition is specified on attributes from the two relations R and S
and is evaluated for each combination of tuples.
• Each tuple combination for which the join condition evaluate to TRUE is
included in the resulting relation Q as a single combined tuple.
27
• A binary operation.
• Combines two relations based on common attributes.
28
• Assignment
• division operations
29

Weitere ähnliche Inhalte

Was ist angesagt?

Dbms relational model
Dbms relational modelDbms relational model
Dbms relational modelChirag vasava
 
Relational Algebra,Types of join
Relational Algebra,Types of joinRelational Algebra,Types of join
Relational Algebra,Types of joinraj upadhyay
 
Database : Relational Data Model
Database : Relational Data ModelDatabase : Relational Data Model
Database : Relational Data ModelSmriti Jain
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraintsmadhav bansal
 
Object oriented database model
Object oriented database modelObject oriented database model
Object oriented database modelPAQUIAAIZEL
 
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...Raj vardhan
 
SQL Joins and Query Optimization
SQL Joins and Query OptimizationSQL Joins and Query Optimization
SQL Joins and Query OptimizationBrian Gallagher
 
Null values, insert, delete and update in database
Null values, insert, delete and update in databaseNull values, insert, delete and update in database
Null values, insert, delete and update in databaseHemant Suthar
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity ConstraintsMegha yadav
 
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
 
Architecture of dbms(lecture 3)
Architecture of dbms(lecture 3)Architecture of dbms(lecture 3)
Architecture of dbms(lecture 3)Ravinder Kamboj
 
Importance of Normalization
Importance of NormalizationImportance of Normalization
Importance of NormalizationShwe Yee
 
physical and logical data independence
physical and logical data independencephysical and logical data independence
physical and logical data independenceapoorva_upadhyay
 

Was ist angesagt? (20)

Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 
Relational Algebra,Types of join
Relational Algebra,Types of joinRelational Algebra,Types of join
Relational Algebra,Types of join
 
RDBMS
RDBMSRDBMS
RDBMS
 
Database : Relational Data Model
Database : Relational Data ModelDatabase : Relational Data Model
Database : Relational Data Model
 
Unit 2 DBMS.pptx
Unit 2 DBMS.pptxUnit 2 DBMS.pptx
Unit 2 DBMS.pptx
 
Create table
Create tableCreate table
Create table
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Object oriented database model
Object oriented database modelObject oriented database model
Object oriented database model
 
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
 
SQL Joins and Query Optimization
SQL Joins and Query OptimizationSQL Joins and Query Optimization
SQL Joins and Query Optimization
 
Null values, insert, delete and update in database
Null values, insert, delete and update in databaseNull values, insert, delete and update in database
Null values, insert, delete and update in database
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
AGGREGATE FUNCTION.pptx
AGGREGATE FUNCTION.pptxAGGREGATE FUNCTION.pptx
AGGREGATE FUNCTION.pptx
 
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...
 
Architecture of dbms(lecture 3)
Architecture of dbms(lecture 3)Architecture of dbms(lecture 3)
Architecture of dbms(lecture 3)
 
Database, Lecture-1.ppt
Database, Lecture-1.pptDatabase, Lecture-1.ppt
Database, Lecture-1.ppt
 
Data models
Data modelsData models
Data models
 
Importance of Normalization
Importance of NormalizationImportance of Normalization
Importance of Normalization
 
physical and logical data independence
physical and logical data independencephysical and logical data independence
physical and logical data independence
 
Dbms
DbmsDbms
Dbms
 

Ähnlich wie Relational model

Intro to relational model
Intro to relational modelIntro to relational model
Intro to relational modelATS SBGI MIRAJ
 
Relational algebra calculus
Relational algebra  calculusRelational algebra  calculus
Relational algebra calculusVaibhav Kathuria
 
Query Decomposition and data localization
Query Decomposition and data localization Query Decomposition and data localization
Query Decomposition and data localization Hafiz faiz
 
Relational Algebra
Relational AlgebraRelational Algebra
Relational AlgebraAmin Omi
 
E212d9a797dbms chapter3 b.sc2
E212d9a797dbms chapter3 b.sc2E212d9a797dbms chapter3 b.sc2
E212d9a797dbms chapter3 b.sc2Mukund Trivedi
 
E212d9a797dbms chapter3 b.sc2 (2)
E212d9a797dbms chapter3 b.sc2 (2)E212d9a797dbms chapter3 b.sc2 (2)
E212d9a797dbms chapter3 b.sc2 (2)Mukund Trivedi
 
E212d9a797dbms chapter3 b.sc2 (1)
E212d9a797dbms chapter3 b.sc2 (1)E212d9a797dbms chapter3 b.sc2 (1)
E212d9a797dbms chapter3 b.sc2 (1)Mukund Trivedi
 
relationalDatabaseModel.pptx
relationalDatabaseModel.pptxrelationalDatabaseModel.pptx
relationalDatabaseModel.pptxNirajG3
 
ER Digramms by Harshal wagh
ER Digramms by Harshal waghER Digramms by Harshal wagh
ER Digramms by Harshal waghharshalkwagh999
 
Relational model
Relational modelRelational model
Relational modelRUpaliLohar
 
Relational model
Relational modelRelational model
Relational modelRUpaliLohar
 
19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdf19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdfGOWTHAMR721887
 
Unit2 -DBMS.ppt with type of job operation
Unit2 -DBMS.ppt with type of job operationUnit2 -DBMS.ppt with type of job operation
Unit2 -DBMS.ppt with type of job operationshindhe1098cv
 
Introduction to R _IMPORTANT FOR DATA ANALYTICS
Introduction to R _IMPORTANT FOR DATA ANALYTICSIntroduction to R _IMPORTANT FOR DATA ANALYTICS
Introduction to R _IMPORTANT FOR DATA ANALYTICSHaritikaChhatwal1
 

Ähnlich wie Relational model (20)

Intro to relational model
Intro to relational modelIntro to relational model
Intro to relational model
 
Relational algebra calculus
Relational algebra  calculusRelational algebra  calculus
Relational algebra calculus
 
Query Decomposition and data localization
Query Decomposition and data localization Query Decomposition and data localization
Query Decomposition and data localization
 
Relational Algebra
Relational AlgebraRelational Algebra
Relational Algebra
 
DBMS UNIT 3
DBMS UNIT 3DBMS UNIT 3
DBMS UNIT 3
 
E212d9a797dbms chapter3 b.sc2
E212d9a797dbms chapter3 b.sc2E212d9a797dbms chapter3 b.sc2
E212d9a797dbms chapter3 b.sc2
 
E212d9a797dbms chapter3 b.sc2 (2)
E212d9a797dbms chapter3 b.sc2 (2)E212d9a797dbms chapter3 b.sc2 (2)
E212d9a797dbms chapter3 b.sc2 (2)
 
E212d9a797dbms chapter3 b.sc2 (1)
E212d9a797dbms chapter3 b.sc2 (1)E212d9a797dbms chapter3 b.sc2 (1)
E212d9a797dbms chapter3 b.sc2 (1)
 
relationalDatabaseModel.pptx
relationalDatabaseModel.pptxrelationalDatabaseModel.pptx
relationalDatabaseModel.pptx
 
ER Digramms by Harshal wagh
ER Digramms by Harshal waghER Digramms by Harshal wagh
ER Digramms by Harshal wagh
 
Relational model
Relational modelRelational model
Relational model
 
Relational model
Relational modelRelational model
Relational model
 
SQL.ppt
SQL.pptSQL.ppt
SQL.ppt
 
19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdf19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdf
 
Data structure
Data structureData structure
Data structure
 
Unit2 -DBMS.ppt with type of job operation
Unit2 -DBMS.ppt with type of job operationUnit2 -DBMS.ppt with type of job operation
Unit2 -DBMS.ppt with type of job operation
 
Sql server select queries ppt 18
Sql server select queries ppt 18Sql server select queries ppt 18
Sql server select queries ppt 18
 
Relational Model
Relational ModelRelational Model
Relational Model
 
Introduction to R _IMPORTANT FOR DATA ANALYTICS
Introduction to R _IMPORTANT FOR DATA ANALYTICSIntroduction to R _IMPORTANT FOR DATA ANALYTICS
Introduction to R _IMPORTANT FOR DATA ANALYTICS
 
RDBMS
RDBMSRDBMS
RDBMS
 

Mehr von Sabana Maharjan

Mehr von Sabana Maharjan (20)

All in one mis
All in one misAll in one mis
All in one mis
 
All in one mis
All in one misAll in one mis
All in one mis
 
M commerce
M commerceM commerce
M commerce
 
E marketing
E marketingE marketing
E marketing
 
Onlineshhopping final
Onlineshhopping finalOnlineshhopping final
Onlineshhopping final
 
Online shopping presentation
Online shopping presentationOnline shopping presentation
Online shopping presentation
 
Erlonggg
ErlongggErlonggg
Erlonggg
 
Er diagram
Er diagramEr diagram
Er diagram
 
Er long
Er longEr long
Er long
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
Good food for better life
Good food for better lifeGood food for better life
Good food for better life
 
Do not think about any consequences just travel around nepal
Do not think about any consequences just travel around nepalDo not think about any consequences just travel around nepal
Do not think about any consequences just travel around nepal
 
5 best place to watch sunrise and sunset naturally
5 best place to watch sunrise and sunset naturally5 best place to watch sunrise and sunset naturally
5 best place to watch sunrise and sunset naturally
 
Newari food
Newari foodNewari food
Newari food
 
This is indeed a life time experience
This is indeed a life time experienceThis is indeed a life time experience
This is indeed a life time experience
 
File tracking system
File tracking systemFile tracking system
File tracking system
 
MIS enterprise system for collaboration
MIS enterprise system for collaborationMIS enterprise system for collaboration
MIS enterprise system for collaboration
 
Mis presentation
Mis presentationMis presentation
Mis presentation
 
Chapter9
Chapter9Chapter9
Chapter9
 
Chapter8
Chapter8Chapter8
Chapter8
 

Kürzlich hochgeladen

➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...amitlee9823
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...amitlee9823
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...amitlee9823
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangaloreamitlee9823
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...SUHANI PANDEY
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...karishmasinghjnh
 
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men 🔝Mathura🔝 Escorts...
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men  🔝Mathura🔝   Escorts...➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men  🔝Mathura🔝   Escorts...
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men 🔝Mathura🔝 Escorts...amitlee9823
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysismanisha194592
 
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...only4webmaster01
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteedamy56318795
 

Kürzlich hochgeladen (20)

➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
 
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
 
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men 🔝Mathura🔝 Escorts...
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men  🔝Mathura🔝   Escorts...➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men  🔝Mathura🔝   Escorts...
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men 🔝Mathura🔝 Escorts...
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get CytotecAbortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get Cytotec
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 

Relational model

  • 2. Relational Model • Data are organized in two-dimensional tables called relations. • The tables are related to each other. • The most popular model. 2
  • 3. • Relational data model first introduced by Ted Codd of IBM in 1970. • It attracted attention due to its simplicity and mathematical foundation. • First commercial implementations of the relational model became available in the early 1980s, such as the SQL/DS system on MVS operating system by IBM and the Oracle DBMS. • Current popular DBMSs include DB2 and Informix Dynamic Server ( from IBM), Oracle and Rdb (from Oracle), and SQL Server and Access (from Microsoft). 3
  • 4. • The relational model represents the database as a collection of relations. • A relation is a table of values, each row in the table represents a collection of related data values. • Each row in the table represents a fact that typically corresponds to a real-world entity or relationship. • The table name and column names are used to help to interpret the meaning of values in each row. 4
  • 5. • RDBMS (Relational Database Management System) • external view • The data are represented as a set of relations. • A relation is a two-dimensional table. • This doesn’t mean that data are stored as tables; the physical storage of the datais independent of the way the data are logically organized. 5
  • 6. • In the formal relational model terminology, a row is called a tuple, a column header is called an attribute, and the table is called a relation. • The data type describing the types of values that can appear in each column is represented by a domain of possible values. • For example: • Name: the set of character strings that represent names of persons. • Employee_age: the possible ages of employees of a company; each must be an integer between18 to 60. • Grade_point: possible values of computed grade point average; each must a real number between 0 to 4. 6
  • 7. Properties of relation • A relation, or table, in a relational database has certain properties. First off, its name must be unique in the database, i.e. a database cannot contain multiple tables of the same name. Next, each relation must have a set of columns or attributes, and it must have a set of rows to contain the data. As with the table names, no attributes can have the same name. • Next, no tuple (or row) can be a duplicate. In practice, a database might actually contain duplicate rows, but there should be practices in place to avoid this, such as the use of unique primary keys (next up). • Given that a tuple cannot be a duplicate, it follows that a relation must contain at least one attribute (or column) that identifies each tuple (or row) uniquely. This is usually the primary key. This primary key cannot be duplicated. This means that no tuple can have the same unique, primary key. The key cannot have a NULL value, which simply means that the value must be known. • Further, each cell, or field, must contain a single value. For example, you cannot enter something like "Tom Smith" and expect the database to understand that you have a first and last name; rather, the database will understand that the value of that cell is exactly what has been entered. • Finally, all attributes—or columns—must be of the same domain, meaning that they must have the same data type. You cannot mix a string and a number in a single cell. • All these properties, or constraints, serve to ensure data integrity, important to maintain the accuracy of data. 7
  • 8. Schemas • A database schema is the skeleton structure that represents the logical view of the entire database. It defines how the data is organized and how the relations among them are associated. It formulates all the constraints that are to be applied on the data. • A database schema defines its entities and the relationship among them. It contains a descriptive detail of the database, which can be depicted by means of schema diagrams. It’s the database designers who design the schema to help programmers understand the database and make it useful. • A database schema can be divided broadly into two categories − • Physical Database Schema − This schema pertains to the actual storage of data and its form of storage like files, indices, etc. It defines how the data will be stored in a secondary storage. • Logical Database Schema − This schema defines all the logical constraints that need to be applied on the data stored. It defines tables, views, and integrity constraints. • 8
  • 10. Tuples • A relation r of relation schema R(A 1 , A 2 , A 3 , ..., A n ), also denoted by r(R), is a set of n-tuples, r = { t 1 , t 2 , t 3 ,... , t n }. • Each n-tuple t is an ordered list of n values t = < t 1 , t 2 , t 3 ,... , t n >. • The ithvalue of n-tuple t corresponds to the attribute A i . • The terms relationintensionfor schema R and relation extension for a relation state r(R) are commonly used. 10
  • 11. Domains constraints • Domain constraints specify that within each tuple, the value of each attribute A must be an atomic value from the domain dom(A). • This is specified as data types which includes standard numeric data types integers, real numbers, characters, Booleans, fixed length strings, variable length strings etc. • These are specified in DDL statements. 11
  • 12. Relational Algebra • Relational algebra is a procedural query language, which takes instances of relations as input and yields instances of relations as output. It uses operators to perform queries. An operator can be either unary or binary. They accept relations as their input and yield relations as their output. Relational algebra is performed recursively on a relation and intermediate results are also considered relations. • The fundamental operations of relational algebra are as follows − • Select • Project • Union • Set different • Cartesian product • Rename 12
  • 13. Select • The SELECT operation is used to choose a subset of the tuples from a relation that satisfies a selection condition. • One can consider the SELECT operation to be a filter that keeps only those tuples that satisfy a qualifying condition. • For example, to select the EMPLOYEE tuples whose department is 4, or those whose salary is greater than $30,000, we can individually specify each of these two conditions with a SELECT operation as follows: • σ Dno=4 (EMPLOYEE) • σ Salary>30000 (EMPLOYEE) 13
  • 14. • In general, the SELECT operation is denoted by • σ <selectioncondition> (R) • where the symbol σ (sigma) is used to denote the SELECT operator and the selection condition is a Boolean expression (condition) specified on the attributes of relation R. • Notice that R is generally a relational algebra expression whose result is a relation—the simplest such expression is just the name of a database relation. • The relation resulting from the SELECT operation has the same attributes as R. • For example, to select the tuples for all employees who either work in department 4 and make over $25,000 per year, or work in department 5 and make over $30,000, we can specify the following SELECT operation: • σ( Dno=4 AND Salary>25000) OR (Dno=5 AND Salary>30000 )(EMPLOYEE) 14
  • 15. • An unaryoperation. • It is applied to one single relationand creates another relation. • The tuples in the resulting relationare a subset of the tuplesin the original relation. • Use some criteriato select 15
  • 16. Project • The PROJECT operation selects certain columns from the table and discards the other columns. • If we are interested in only certain attributes of a relation, we use the PROJECT operation to project the relation over these attributes only. • Therefore, the result of the PROJECT operation can be visualized as a vertical partition of the relation into two relations: • One has the needed columns (attributes) and contains the result of the operation, and the other contains the discarded columns. • For example, to list each employee’s first and last name and salary, we can use the PROJECT operation as follows: • π Lname, Fname, Salary (EMPLOYEE) 16
  • 17. • The general form of the PROJECT operation is • π <attribute list> (R) • where π (pi) is the symbol used to represent the PROJECT operation, and < attribute list > is the desired sub list of attributes from the attributes of relation R. • Again, notice that R is, in general, a relational algebra expression whose result is a relation, which in the simplest case is just the name of a database relation. • The result of the PROJECT operation has only the attributes specified in <attribute list> in the same order as they appear in the list. • Hence, its degree is equal to the number of attributes in <attribute list>. 17
  • 18. • An unaryoperation. • It is applied to one single relationand creates another relation. • The attributes in the resulting relationare a subset of the attributesin the original relation. 18
  • 19. Rename • In general, for most queries, we need to apply several relational algebra operations one after the other. Either we can write the operations as a single relational algebra expression by nesting the operations, or we can apply one operation at a time and create intermediate result relations. • In the latter case, we must give names to the relations that hold the intermediate results. • For example, to retrieve the first name, last name, and salary of all employees who work in department number 5, we must apply a SELECT and a PROJECT operation. • We can write a single relational algebra expression, also known as an in-line expression, as follows: • π Fname, Lname, Salary (σ Dno=5 (EMPLOYEE)) • Alternatively, we can explicitly show the sequence of operations, giving a name to each intermediate relation, as follows: • DEP5_EMPS ←σ Dno=5 (EMPLOYEE) • RESULT ←π Fname, Lname, Salary (DEP5_EMPS) 19
  • 20. Union, Intersection and Difference • UNION: The result of this operation, denoted by R ∪S, is a relation that includes all tuples that are either in R or in S or in both R and S. Duplicate tuples are eliminated. • INTERSECTION: The result of this operation, denoted by R ∩S, is a relation that includes all tuples that are in both R and S. • DIFFERENCE (or MINUS): The result of this operation, denoted by R – S, is a relation that includes all tuples that are in R but not in S. 20
  • 21. • For example, to retrieve the Social Security numbers of all employees who either work in department 5 or directly supervise an employee who works in department 5, we can use the UNION operation as follows: • DEP5_EMPS ←σ Dno=5 (EMPLOYEE) • RESULT1 ←π Ssn (DEP5_EMPS) • RESULT2 ←π Super_ssn (DEP5_EMPS) • RESULT ←RESULT1 ∪RESULT2 21
  • 22. Union • A binary operation. • Creates a new relation in which each tuple is either in the first relation, in the second, or in both. • The two relations must have the same attributes. 22
  • 23. Intersection • A binary operation. • Creates a new relation in which each tuple is a member in both relations. • The two relations must have the same attributes. 23
  • 24. Difference • A binary operation. • Creates a new relation in which each tuple is in the first relation but not the second. • The two relations must have the same attributes. 24
  • 25. Cartesian Product • This is also a binary set operation, but the relations on which it is applied do not have to be union compatible. • In its binary form, this set operation produces a new element by combining every member (tuple) from one relation (set) with every member (tuple) from the other relation (set). • In general, the result of R(A1, A2, ..., An) ×S(B1, B2, ..., Bm) is a relation Q with degree n + m attributes Q(A1, A2, ..., An, B1, B2, ..., Bm), in that order. • The resulting relation Q has one tuple for each combination of tuples—one from R and one from S. • Hence, if R has n R tuples (denoted as |R| = n R ), and S has n S tuples, then R ×S will have n R * n S tuples. 25
  • 26. Join Operation • The JOIN operation, denoted by , is used to combine related tuples from two relations into single “longer” tuples. • The JOIN operation can be specified as a CARTESIAN PRODUCT operation followed by a SELECT operation. • Suppose that we want to retrieve the name of the manager of each department. To get the manager’s name, we need to combine each department tuple with the employee tuple whose Ssnvalue matches the Mgr_ssnvalue in the department tuple. •Note that Mgr_ssnis a foreign key of the DEPARTMENT relation that references Ssn, the primary key of the EMPLOYEE relation. This referential integrity constraint plays a role in having matching tuples in the referenced relation EMPLOYEE. 26
  • 27. • The general form of a JOIN operation on two relations R(A1, A2, ..., An) and S(B1, B2, ..., Bm) is • R ⋈ <join condition> S • The result of the JOIN is a relation Q with n + m attributes Q(A1, A2, ..., An, B1, B2, ... , Bm) in that order; Q has one tuple for each combination of tuples—one from R and one from S—whenever the combination satisfies the join condition. • This is the main difference between CARTESIAN PRODUCT and JOIN. In JOIN, only combinations of tuples satisfying the join condition appear in the result, whereas in the CARTESIAN PRODUCT all combinations of tuples are included in the result. • The join condition is specified on attributes from the two relations R and S and is evaluated for each combination of tuples. • Each tuple combination for which the join condition evaluate to TRUE is included in the resulting relation Q as a single combined tuple. 27
  • 28. • A binary operation. • Combines two relations based on common attributes. 28