0% found this document useful (0 votes)
12 views167 pages

Mod 2

The document provides an overview of the Relational Model in database management, detailing key concepts such as relations, tuples, attributes, and domains. It explains the formal definitions and characteristics of relations, including integrity constraints like key, entity integrity, and referential integrity. Additionally, it discusses the structure of relational database schemas and the operations for updating database states.

Uploaded by

Bindushree Bade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views167 pages

Mod 2

The document provides an overview of the Relational Model in database management, detailing key concepts such as relations, tuples, attributes, and domains. It explains the formal definitions and characteristics of relations, including integrity constraints like key, entity integrity, and referential integrity. Additionally, it discusses the structure of relational database schemas and the operations for updating database states.

Uploaded by

Bindushree Bade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 167

Data Base Management System

BCS403
MODULE-2

Relational Model

Text Book: Fundamentals of Database Systems, Ramez Elmasri and


Shamkant B. Navathe, 7th Edition, 2017, Pearson. ”

Course Coordinator
Dr Archana R A

6/19/24 1
Department of Computer Science and Engg

Transform Here

Relational Model Concepts


• A Relation is a mathematical concept based on the ideas of sets
• The model was first proposed by Dr. E.F. Codd of IBM Research in
1970 in the following paper:
•"A Relational Model for Large Shared Data
Banks," Communications of the ACM, June 1970
• The above paper caused a major revolution in the field of database
management and earned Dr. Codd the coveted ACM Turing Award

Slide 5- 2
Department of Computer Science and Engg

Transform Here

Informal Definitions

•Informally, a relation looks like a table of values.

•A relation typically contains a set of rows.

•The data elements in each row represent certain facts that


correspond to a real-world entity or relationship
•In the formal model, rows are called tuples

•Each column has a column header that gives an indication of


the meaning of the data items in that column
• In the formal model, the column header is called an
attribute name (or just attribute) Slide 5- 3
Department of Computer Science and Engg

Transform Here

Example of a Relation

Slide 5- 4
Department of Computer Science and Engg

Transform Here

Informal Definitions
• Key of a Relation:
•Each row has a value of a data item (or set of
items) that uniquely identifies that row in the
table
•Called the key
•In the STUDENT table, SSN is the key

•Sometimes row-ids or sequential numbers are


assigned as keys to identify the rows in a table
•Called artificial key or surrogate key

Slide 5- 5
Department of Computer Science and Engg

Transform Here

Formal Definitions - Schema

•The Schema (or description) of a Relation:


• Denoted by R(A1, A2, .....An)
• R is the name of the relation
• The attributes of the relation are A1, A2, ..., An
•Example:
CUSTOMER (Cust-id, Cust-name, Address, Phone#)
• CUSTOMER is the relation name
• Defined over the four attributes: Cust-id, Cust-name,
Address, Phone#
•Each attribute has a domain or a set of valid values.
• For example, the domain of Cust-id is 6 digit numbers.

Slide 5- 6
Department of Computer Science and Engg

Transform Here

Formal Definitions -
Tuple
•A tuple is an ordered set of values (enclosed in angled
brackets ‘< … >’)
•Each value is derived from an appropriate domain.
•A row in the CUSTOMER relation is a 4-tuple and
would consist of four values, for example:
• <632895, "John Smith", "101 Main St. Atlanta, GA
30332", "(404) 894-2000">
• This is called a 4-tuple as it has 4 values
• A tuple (row) in the CUSTOMER relation.
•A relation is a set of such tuples (rows)

Slide 5- 7
Department of Computer Science and Engg

Transform Here

Formal Definitions - Domain


• A domain has a logical definition:
• Example: “USA_phone_numbers” are the set of 10 digit phone numbers
valid in the U.S.
• A domain also has a data-type or a format defined for it.
• The USA_phone_numbers may have a format: (ddd)ddd-dddd
where each d is a decimal digit.
• Dates have various formats such as year, month, date formatted as
yyyy-mm-dd, or as dd mm,yyyy etc.

• The attribute name designates the role played by a domain in a relation:


• Used to interpret the meaning of the data elements corresponding
to that attribute
• Example: The domain Date may be used to define two attributes named
“Invoice-date” and “Payment-date” with different meanings Slide 5- 8
Department of Computer Science and Engg

Transform Here

Formal Definitions -
State
• The relation state is a subset of the Cartesian product of the
domains of its attributes
•each domain contains the set of all
possible values the attribute can take.
• Example: attribute Cust-name is defined over the domain
of character strings of maximum length 25
•dom(Cust-name) is varchar(25)
• The role these strings play in the CUSTOMER relation is that of the
name of a customer.

Slide 5- 9
Department of Computer Science and Engg

Transform Here

Formal Definitions - Summary

•Formally,
• Given R(A1, A2, .........., An)
• r(R) ⊂ dom (A1) X dom (A2) X ....X dom(An)
•R(A1, A2, …, An) is the schema of the relation
•R is the name of the relation
•A1, A2, …, An are the attributes of the relation
•r(R): a specific state (or "value" or “population”) of
relation
R – this is a set of tuples (rows)
• r(R) = {t1, t2, …, tn} where each ti is an n-tuple
• ti = <v1, v2, …, vn> where each vj element-of dom(Aj)
Slide 5- 10
Department of Computer Science and Engg

Transform Here

Formal Definitions - Example

•Let R(A1, A2) be a relation schema:


• Let dom(A1) = {0,1}
• Let dom(A2) = {a,b,c}
•Then: dom(A1) X dom(A2) is all possible combinations:
{<0,a> , <0,b> , <0,c>, <1,a>, <1,b>, <1,c> }

•The relation state r(R) ⊂ dom(A1) X dom(A2)


•For example: r(R) could be {<0,a> , <0,b> , <1,c> }
• this is one possible state (or “population” or “extension”) r
of
the relation R, defined over A1 and A2.
• It has three 2-tuples: <0,a> , <0,b> , <1,c>
Slide 5- 11
Department of Computer Science and Engg

Transform Here

Definition Summary
Informal Terms Formal Terms
Table Relation
Column Header Attribute
All possible Column Domain
Values
Row Tuple

Table Definition Schema of a Relation


Populated Table State of the Relation
Slide 5- 12
Department of Computer Science and Engg

Transform Here

Example – A relation STUDENT

Slide 5- 13
Department of Computer Science and Engg

Transform Here

Characteristics Of Relations
• Ordering of tuples in a relation r(R):
•The tuples are not considered to be ordered,
even though they appear to be in the tabular
form.
• Ordering of attributes in a relation schema R (and of values
within each tuple):
•We will consider the attributes in R(A1, A2,
..., An) and the values in t=<v1, v2, ..., vn>
to be ordered .
• (However, a more general alternative definition of relation does not require this
ordering).

Slide 5- 14
Department of Computer Science and Engg

Transform Here

Same state as previous Figure (but


with different order of tuples)

Slide 5- 15
Department of Computer Science and Engg

Transform Here

Characteristics Of Relations
• Values in a tuple:
•All values are considered atomic (indivisible).
•Each value in a tuple must be from the domain
of the attribute for that column
• If tuple t = <v1, v2, …, vn> is a tuple (row) in the relation state r of R(A1, A2, …, An)
• Then each vi must be a value from dom(Ai)

•A special null value is used to represent


values that are unknown or inapplicable to
certain tuples.

Slide 5- 16
Department of Computer Science and Engg

Transform Here

Characteristics Of Relations

• Notation:
•We refer to component values of a tuple t by:
• t[Ai] or t.Ai
• This is the value vi of attribute Ai for tuple t

•Similarly, t[Au, Av, ..., Aw] refers to the subtuple


of t containing the values of attributes Au, Av, ...,
Aw, respectively in t

Slide 5- 17
Department of Computer Science and Engg

Transform Here

Relational Integrity Constraints

•Constraints are conditions that must hold on all


valid relation states.
•There are three main types of constraints in the
relational model:
• Key constraints
• Entity integrity constraints
• Referential integrity constraints
•Another implicit constraint is the domain constraint
• Every value in a tuple must be from the domain of its
attribute
(or it could be null, if allowed for that attribute)
Slide 5- 18
Department of Computer Science and Engg

Transform Here

Key
Constraints
•Superkey of R:
• Is a set of attributes SK of R with the following condition:
• No two tuples in any valid relation state r(R) will have the
same value for SK
• That is, for any distinct tuples t1 and t2 in r(R), t1[SK] ≠ t2[SK]
• This condition must hold in any valid state r(R)
•Key of R:
• A "minimal" superkey
• That is, a key is a superkey K such that removal of any
attribute from K results in a set of attributes that is not a
superkey (does not possess the superkey uniqueness
property)
Slide 5- 19
Department of Computer Science and Engg

Transform Here

Key Constraints (continued)

•Example: Consider the CAR relation schema:


• CAR(State, Reg#, SerialNo, Make, Model, Year)
• CAR has two keys:
• Key1 = {State, Reg#}
• Key2 = {SerialNo}
• Both are also superkeys of CAR
• {SerialNo, Make} is a superkey but not a key.
•In general:
• Any key is a superkey (but not vice versa)
• Any set of attributes that includes a key is a
superkey
• A minimal superkey is also a key

Slide 5- 20
Department of Computer Science and Engg

Transform Here

Key Constraints (continued)

•If a relation has several candidate keys, one is


chosen arbitrarily to be the primary key.
• The primary key attributes are underlined.
•Example: Consider the CAR relation schema:
• CAR(State, Reg#, SerialNo, Make, Model, Year)
• We chose SerialNo as the primary key
•The primary key value is used to uniquely identify each
tuple
in a relation
• Provides the tuple identity
•Also used to reference the tuple from another tuple
• General rule: Choose as primary key the smallest of the Slide 5- 21

candidate keys (in terms of size)


Department of Computer Science and Engg

CAR table with two candidate keys –


Transform Here

LicenseNumber chosen as Primary


Key

Slide 5- 22
Department of Computer Science and Engg

Transform Here

Relational Database Schema


• Relational Database Schema:
•A set S of relation schemas that belong to
the same database.
•S is the name of the whole database schema
•S = {R1, R2, ..., Rn}
•R1, R2, …, Rn are the names of the individual
relation schemas within the database S
• Following slide shows a COMPANY database schema with 6
relation schemas

Slide 5- 23
Department of Computer Science and Engg

Transform Here

COMPANY Database Schema

Slide 5- 24
Department of Computer Science and Engg

Transform Here

Entity Integrity

•Entity Integrity:
•The primary key attributes PK of each relation schema
R in S cannot have null values in any tuple of r(R).
• This is because primary key values are used to identify the
individual tuples.
• t[PK] ≠ null for any tuple t in r(R)
• If PK has several attributes, null is not allowed in any of these
attributes
•Note: Other attributes of R may be constrained to
disallow null values, even though they are not
members of the primary key.

Slide 5- 25
Department of Computer Science and Engg

Transform Here

Referential Integrity

• A constraint involving two relations


•The previous constraints involve a single relation.
• Used to specify a relationship among tuples in two relations:
•The referencing relation and the
referenced relation.

Slide 5- 26
Department of Computer Science and Engg

Transform Here

Referential Integrity

• Tuples in the referencing relation R1 have attributes FK (called


foreign key attributes) that reference the primary key attributes PK
of the referenced relation R2.
•A tuple t1 in R1 is said to reference a tuple t2 in
R2 if t1[FK] = t2[PK].
• A referential integrity constraint can be displayed in a relational
database schema as a directed arc from R1.FK to R2.

Slide 5- 27
Department of Computer Science and Engg

Transform Here

Referential Integrity (or foreign


key) Constraint
• Statement of the constraint
•The value in the foreign key column (or columns)
FK of the the referencing relation R1 can be
either:
• (1) a value of an existing primary key value of a corresponding primary key PK in the
• referenced relation R2, or
• (2) a null.
• In case (2), the FK in R1 should not be a part of its own primary key.

Slide 5- 28
Department of Computer Science and Engg

Transform Here

Displaying a relational database schema


and its constraints
•Each relation schema can be displayed as a row of
attribute names
•The name of the relation is written above the
attribute names
•The primary key attribute (or attributes) will be underlined
•A foreign key (referential integrity) constraints is displayed
as a directed arc (arrow) from the foreign key attributes
to the referenced table
• Can also point the the primary key of the referenced
relation for clarity
•Next slide shows the COMPANY relational schema diagram
Slide 5- 29
Department of Computer Science and Engg

Transform Here

Referential Integrity Constraints for COMPANY


database

Slide 5- 30
Department of Computer Science and Engg

Transform Here

Other Types of Constraints


• Semantic Integrity Constraints:
•based on application semantics and cannot be
expressed by the model per se
•Example: “the max. no. of hours per employee
for all projects he or she works on is 56 hrs
per week”
• A constraint specification language may have to be used to
express these
• SQL-99 allows triggers and ASSERTIONS to express for some of
these

Slide 5- 31
Department of Computer Science and Engg

Transform Here
Populated database
state
•Each relation will have many tuples in its current
relation state
•The relational database state is a union of all the
individual relation states
•Whenever the database is changed, a new state arises
•Basic operations for changing the database:
• INSERT a new tuple in a relation
• DELETE an existing tuple from a relation
• MODIFY an attribute of an existing tuple
•Next slide shows an example state for the COMPANY
database
Slide 5- 32
Populated database state for
COMPANY

Department of Computer Science and Engg Slide 5- 33


Transform
Department of Computer Science and Engg

Transform Here

Update Operations on Relations

• INSERT a tuple.
• DELETE a tuple.
• MODIFY a tuple.
• Integrity constraints should not be violated by the update
operations.
• Several update operations may have to be grouped together.
• Updates may propagate to cause other updates automatically. This
may be necessary to maintain integrity constraints.

Slide 5- 34
Department of Computer Science and Engg

Transform Here

Update Operations on Relations

• In case of integrity violation, several actions can be taken:


•Cancel the operation that causes the
violation (RESTRICT or REJECT option)
•Perform the operation but inform the user of
the violation
•Trigger additional updates so the violation is
corrected (CASCADE option, SET NULL
option)
•Execute a user-specified error-correction routine

Slide 5- 35
Department of Computer Science and Engg

Transform Here

Possible violations for each operation

•INSERT may violate any of the constraints:


• Domain constraint:
• if one of the attribute values provided for the new tuple is not
of the specified attribute domain
• Key constraint:
• if the value of a key attribute in the new tuple already exists in
another tuple in the relation
• Referential integrity:
• if a foreign key value in the new tuple references a primary
key value that does not exist in the referenced relation
• Entity integrity:
• if the primary key value is null in the new tuple

Slide 5- 36
Department of Computer Science and Engg

Transform Here

Possible violations for each operation


•DELETE may violate only referential integrity:
• If the primary key value of the tuple being deleted is
referenced from other tuples in the database
• Can be remedied by several actions: RESTRICT, CASCADE,
SET NULL (see Chapter 8 for more details)
• RESTRICT option: reject the deletion
• CASCADE option: propagate the new primary key value into the
foreign keys of the referencing tuples
• SET NULL option: set the foreign keys of the referencing tuples
to NULL
• One of the above options must be specified during
database design for each foreign key constraint

Slide 5- 37
Department of Computer Science and Engg

Transform Here

Possible violations for each operation

•UPDATE may violate domain constraint and NOT


NULL constraint on an attribute being modified
•Any of the other constraints may also be violated,
depending on the attribute being updated:
• Updating the primary key (PK):
• Similar to a DELETE followed by an INSERT
• Need to specify similar options to DELETE
• Updating a foreign key (FK):
• May violate referential integrity
• Updating an ordinary attribute (neither PK nor FK):
• Can only violate domain constraints

Slide 5- 38
Department of Computer Science and Engg

Transform Here

Relational Algebra Overview

• Relational algebra is the basic set of operations for the


relational model
•These operations enable a user to specify
basic retrieval requests (or queries)
• The result of an operation is a new relation, which may have
been formed from one or more input relations
•This property makes the algebra “closed” (all
objects in relational algebra are relations)

Slide 6- 39
Department of Computer Science and Engg

Transform Here

Relational Algebra Overview (continued)

• The algebra operations thus produce new relations


•These can be further manipulated
using operations of the same algebra
• A sequence of relational algebra operations forms a
relational algebra expression
•The result of a relational algebra expression is also a
relation that represents the result of a database
query (or retrieval request)

Slide 6- 40
Department of Computer Science and Engg

Transform Here

Relational Algebra Overview


• Relational Algebra consists of several groups of operations
• Unary Relational Operations
• SELECT (symbol: σ (sigma))
• PROJECT (symbol: π (pi))
• RENAME (symbol: ρ (rho))
• Relational Algebra Operations From Set Theory
• UNION ( ∪ ), INTERSECTION ( ∩ ), DIFFERENCE (or MINUS, – )
• CARTESIAN PRODUCT ( x )
• Binary Relational Operations
• JOIN (several variations of JOIN exist)
• DIVISION
• Additional Relational Operations
• OUTER JOINS, OUTER UNION
• AGGREGATE FUNCTIONS (These compute summary of Computer: for
Slide 6- 41
example, SUM, COUNT, AVG, MIN, MAX)
Department of Computer Science and Engg

Transform Here

Database State for COMPANY

• All examples discussed below refer to the COMPANY database


shown here.

Slide 6- 42
Department of Computer Science and Engg

Transform Here

Unary Relational Operations: SELECT

• The SELECT operation (denoted by σ (sigma)) is used to select a subset of


the tuples from a relation based on a selection condition.
• The selection condition acts as a filter
• Keeps only those tuples that satisfy the qualifying condition
• Tuples satisfying the condition are selected whereas the
other tuples are discarded (filtered out)
• Examples:
• Select the EMPLOYEE tuples whose department number is 4:
σ DNO = 4 (EMPLOYEE)
• Select the employee tuples whose salary is greater than $30,000:
σ (EMPLOYEE)
SALARY > 30,000

Slide 6- 43
Department of Computer Science and Engg

Transform Here

Unary Relational Operations: SELECT

•In general, the select operation is denoted by σ


(R) where
<selection condition>

• the symbol σ (sigma) is used to denote the select operator


• the selection condition is a Boolean (conditional) expression specified on the
attributes of relation R
• tuples that make the condition true are selected
• appear in the result of the operation
• tuples that make the condition false are filtered out
• discarded from the result of the operation

Slide 6- 44
Department of Computer Science and Engg

Transform Here

Unary Relational Operations: SELECT (contd.)

•SELECT Operation Properties


• The SELECT operation σ <selection condition> (R) produces a relation S
that has the same schema (same attributes) as R
• SELECT σ is commutative:
σ (σ (R)) = σ (σ (R))
• <condition1> < condition2> <condition2> < condition1>
• Because of commutativity property, a cascade (sequence)
of SELECT operations may be applied in any order:
σ (σ (σ (R)) = σ (σ (σ ( R)))
• <cond1> <cond2> <cond3> <cond2> <cond3> <cond1>

• A cascade of SELECT operations may be replaced by a


single selection with a conjunction of all the conditions:
σ (σ (σ (R)) = σ (R)))
• <cond1> < cond2> <cond3> <cond1> AND < cond2> AND < cond3>
• The number of tuples in the result of a SELECT is less than (or
equal to) the number of tuples in the input relation R
Slide 6- 45
Department of Computer Science and Engg

Transform Here

The following query results refer to


this database state

Slide 6- 46
Department of Computer Science and Engg

Transform Here

Unary Relational Operations: PROJECT

• PROJECT Operation is denoted by π (pi)


• This operation keeps certain columns (attributes) from a relation
and
discards the other columns.
•PROJECT creates a vertical partitioning
• The list of specified columns (attributes) is kept in each tuple
• The other attributes in each tuple are discarded
• Example: To list each employee’s first and last name and salary, the
following is used:
π (EMPLOYEE)
LNAME, FNAME,SALARY

Slide 6- 47
Department of Computer Science and Engg

Transform Here

Unary Relational Operations: PROJECT (cont.)

• The general form of the project operation is:


π (R)
<attribute list>

•π (pi) is the symbol used to represent the project


operation
•<attribute list> is the desired list of
attributes from relation R.
• The project operation removes any duplicate tuples
•This is because the result of the project
operation must be a set of tuples
• Mathematical sets do not allow duplicate elements.

Slide 6- 48
Department of Computer Science and Engg

Transform Here

Unary Relational Operations: PROJECT


(contd.)
• PROJECT Operation Properties
•The number of tuples in the result of projection
π<list>(R) is always less or equal to the number of
tuples in R
• If the list of attributes includes a key of R, then the number of tuples in the result
of PROJECT is equal to the number of tuples in R

•PROJECT is not commutative


• π <list1> (π <list2> (R) ) = π <list1> (R) as long as <list2> contains the attributes in <list1>

Slide 6- 49
Department of Computer Science and Engg

Transform Here

Examples of applying SELECT and


PROJECT operations

Slide 6- 50
Department of Computer Science and Engg

Transform Here

Relational Algebra Expressions

• We may want 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.
Slide 6- 51
Department of Computer Science and Engg

Transform Here

Single expression versus sequence of


relational operations (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
as follows:
π (σ (EMPLOYEE))
• FNAME, LNAME, SALARY DNO=5

•OR We can explicitly show the sequence of operations,


giving a name to each intermediate relation:
•DEP5_EMPS ← σ DNO=5(EMPLOYEE)
•RESULT ← π FNAME, LNAME, SALARY (DEP5_EMPS)

Slide 6- 52
Department of Computer Science and Engg

Transform Here

Unary Relational Operations: RENAME

• The RENAME operator is denoted by ρ (rho)


• In some cases, we may want to rename the attributes of a relation or
the relation name or both
•Useful when a query requires multiple
operations
•Necessary in some cases (see JOIN
operation later)

Slide 6- 53
Department of Computer Science and Engg

Transform Here

Unary Relational Operations: RENAME


(contd.)
• The general RENAME operation ρ can be expressed by any of
the following forms:
•ρS (B1, B2, …, Bn )(R) changes both:
• the relation name to S, and
• the column (attribute) names to B1, B1, …..Bn

•ρS(R) changes:
• the relation name only to S

•ρ(B1, B2, …, Bn )(R) changes:


• the column (attribute) names only to B1, B1, …..Bn

Slide 6- 54
Department of Computer Science and Engg

Transform Here

Unary Relational Operations: RENAME


(contd.)
• For convenience, we also use a shorthand for renaming attributes
in an intermediate relation:
•If we write:
•RESULT ← π FNAME, LNAME, SALARY (DEP5_EMPS)
•RESULT will have the same attribute names
as DEP5_EMPS (same attributes as
EMPLOYEE)
• If we write:
•RESULT (F, M, L, S, B, A, SX, SAL, SU, DNO)← π
(DEP5_EMPS)
FNAME, LNAME, SALARY
•The 10 attributes of DEP5_EMPS are renamed to F,
M, L, S, B, A, SX, SAL, SU, DNO, respectively Slide 6- 55
Department of Computer Science and Engg

Transform Here

Example of applying multiple operations


and RENAME

Slide 6- 56
Department of Computer Science and Engg

Transform Here

Relational Algebra Operations


from Set Theory: UNION
• UNION Operation
•Binary operation, denoted by ∪
•The result of 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
•The two operand relations R and S must be
“type compatible” (or UNION compatible)
•R and S must have same number of attributes
•Each pair of corresponding attributes must be type
compatible (have same or compatible domains)
Slide 6- 57
Department of Computer Science and Engg

Transform Here

Relational Algebra Operations


from Set Theory: UNION
•Example:
• To retrieve the social security numbers of all employees who
either work in department 5 (RESULT1 below) or directly
supervise an employee who works in department 5 (RESULT2
below)
• We can use the UNION operation as follows:
DEP5_EMPS ← σDNO=5 (EMPLOYEE)
RESULT1 ← π SSN(DEP5_EMPS)
RESULT2(SSN) ←
πSUPERSSN(DEP5_EMPS) RESULT ←
RESULT1 ∪ RESULT2
• The union operation produces the tuples that are in
either RESULT1 or RESULT2 or both Slide 6- 58
Department of Computer Science and Engg

Transform Here

Example of the result of a UNION operation


• UNION Example

Slide 6- 59
Department of Computer Science and Engg

Transform Here

Relational Algebra Operations


from Set Theory
•Type Compatibility of operands is required for the binary
set operation UNION ∪, (also for INTERSECTION ∩, and
SET DIFFERENCE –, see next slides)
•R1(A1, A2, ..., An) and R2(B1, B2, ..., Bn) are type
compatible if:
• they have the same number of attributes, and
• the domains of corresponding attributes are type compatible
(i.e. dom(Ai)=dom(Bi) for i=1, 2, ..., n).
•The resulting relation for R1∪R2 (also for R1∩R2, or R1–R2,
see next slides) has the same attribute names as the first
operand relation R1 (by convention)

Slide 6- 60
Department of Computer Science and Engg

Transform Here

Relational Algebra Operations from Set


Theory: INTERSECTION
•INTERSECTION is denoted by ∩
•The result of the operation R ∩ S, is a relation
that includes all tuples that are in both R and
S
•The attribute names in the result will be
the same as the attribute names in R
•The two operand relations R and S must be
“type compatible”
Slide 6- 61
Department of Computer Science and Engg

Transform Here

Relational Algebra Operations from Set


Theory: SET DIFFERENCE (cont.)
• SET DIFFERENCE (also called MINUS or EXCEPT) is denoted by –
• The result of R – S, is a relation that includes all tuples that are in R
but not in S
•The attribute names in the result will be
the same as the attribute names in R
•The two operand relations R and S must be
“type compatible”

Slide 6- 62
Department of Computer Science and Engg

Transform Here

Example to illustrate the result of UNION,


INTERSECT, and DIFFERENCE

Slide 6- 63
Department of Computer Science and Engg

Transform Here

Some properties of UNION, INTERSECT,


and DIFFERENCE
•Notice that both union and intersection are commutative
operations; that is
• R ∪ S = S ∪ R, and R ∩ S = S ∩ R
•Both union and intersection can be treated as n-ary
operations applicable to any number of relations as both
are associative operations; that is
• R ∪ (S ∪ T) = (R ∪ S) ∪ T
• (R ∩ S) ∩ T = R ∩ (S ∩ T)
•The minus operation is not commutative; that is, in general
•R – S ≠ S – R

Slide 6- 64
Department of Computer Science and Engg

Transform Here

Relational Algebra Operations from Set


Theory: CARTESIAN PRODUCT
•CARTESIAN (or CROSS) PRODUCT Operation
• This operation is used to combine tuples from two relations in
a combinatorial fashion.
• Denoted by R(A1, A2, . . ., An) x S(B1, B2, . . ., Bm)
• Result is a relation Q with degree n + m attributes:
• Q(A1, A2, . . ., An, B1, B2, . . ., Bm), in that order.
• The resulting relation state has one tuple for each
combination
of tuples—one from R and one from S.
• Hence, if R has nR tuples (denoted as |R| = nR ), and S has nS
tuples, then R x S will have nR * nS tuples.
• The two operands do NOT have to be "type compatible”
Slide 6- 65
Department of Computer Science and Engg

Transform Here

Relational Algebra Operations from Set


Theory: CARTESIAN PRODUCT (cont.)
• Generally, CROSS PRODUCT is not a meaningful operation
•Can become meaningful when followed by
other operations
• Example (not meaningful):
• FEMALE_EMPS ← σ SEX=’F’(EMPLOYEE)
• EMPNAMES ← π FNAME, LNAME, SSN (FEMALE_EMPS)
• EMP_DEPENDENTS ← EMPNAMES x DEPENDENT
•EMP_DEPENDENTS will contain every combination
of EMPNAMES and DEPENDENT
• whether or not they are actually related

Slide 6- 66
Department of Computer Science and Engg

Transform Here

Relational Algebra Operations from Set


Theory: CARTESIAN PRODUCT (cont.)
• To keep only combinations where the DEPENDENT is related to
the EMPLOYEE, we add a SELECT operation as follows
• Example (meaningful):
• FEMALE_EMPS ← σ SEX=’F’(EMPLOYEE)
• EMPNAMES ← π FNAME, LNAME, SSN (FEMALE_EMPS)
• EMP_DEPENDENTS ← EMPNAMES x DEPENDENT
• ACTUAL_DEPS ← σ SSN=ESSN(EMP_DEPENDENTS)
RESULT ← π (ACTUAL_DEPS)
• FNAME, LNAME, DEPENDENT_NAME

•RESULT will now contain the name of female employees


and their dependents

Slide 6- 67
Department of Computer Science and Engg

Transform Here

Example of applying CARTESIAN PRODUCT

Slide 6- 68
Department of Computer Science and Engg

Transform Here

Binary Relational Operations: JOIN

•JOIN Operation (denoted by )


• The sequence of CARTESIAN PRODECT followed by SELECT is
used quite commonly to identify and select related tuples
from two relations
• A special operation, called JOIN combines this sequence into
a single operation
• This operation is very important for any relational database
with more than a single relation, because it allows us
combine related tuples from various relations
• The general form of a join operation on two relations R(A1, A2,
. . ., An) and S(B1, B2, . . ., Bm) is:
R S
<join condition>
• where R and S can be any relations that result from
general
relational algebra expressions.
Slide 6- 69
Department of Computer Science and Engg

Binary Relational Operations: JOIN Transform Here

(cont.)
•Example: 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 SSN
value matches the MGRSSN value in the department tuple.
• We do this by using the join operation.
• DEPT_MGR ← EMPLOYEE
MGRSSN=SSN
DEPARTMENT
•MGRSSN=SSN is the join condition
• Combines each department record with the employee who
manages the department
• The join condition can also be specified as
DEPARTMENT.MGRSSN= EMPLOYEE.SSN

Slide 6- 70
Department of Computer Science and Engg

Transform Here

Example of applying the JOIN operation

Slide 6- 71
Department of Computer Science and Engg

Transform Here

Some properties of JOIN

•Consider the following JOIN operation:


• R(A1, A2, . . ., An) S(B1, B2, . . ., Bm)
R.Ai=S.Bj
• Result is a relation Q with degree n + m attributes:
• Q(A1, A2, . . ., An, B1, B2, . . ., Bm), in that order.
• The resulting relation state has one tuple for each combination
of tuples—r from R and s from S, but only if they satisfy the join
condition r[Ai]=s[Bj]
• Hence, if R has nR tuples, and S has nS tuples, then the join
result will generally have less than nR * nS tuples.
• Only related tuples (based on the join condition) will appear in
the result

Slide 6- 72
Department of Computer Science and Engg

Transform Here

Some properties of JOIN


• The general case of JOIN operation is called a Theta-join: R S
theta
• The join condition is called theta
• Theta can be any general boolean expression on the attributes of
R and S; for example:
•R.Ai<S.Bj AND (R.Ak=S.Bl OR R.Ap<S.Bq)
• Most join conditions involve one or more equality conditions
“AND”ed together; for example:
•R.Ai=S.Bj AND R.Ak=S.Bl AND R.Ap=S.Bq

Slide 6- 73
Department of Computer Science and Engg

Transform Here

Binary Relational Operations: EQUIJOIN


• EQUIJOIN Operation
• The most common use of join involves join conditions with equality
comparisons only
• Such a join, where the only comparison operator used is =, is
called an EQUIJOIN.
•In the result of an EQUIJOIN we always have
one or more pairs of attributes (whose names
need not be identical) that have identical
values in every tuple.
•The JOIN seen in the previous example was
an EQUIJOIN.
Slide 6- 74
Department of Computer Science and Engg

Binary Relational Transform Here

Operations: NATURAL JOIN


Operation
•NATURAL JOIN Operation
• Another variation of JOIN called NATURAL JOIN — denoted
by
* — was created to get rid of the second (superfluous)
attribute in an EQUIJOIN condition.
• because one of each pair of attributes with identical values is
superfluous
• The standard definition of natural join requires that the
two join attributes, or each pair of corresponding join
attributes, have the same name in both relations
• If this is not the case, a renaming operation is applied first.

Slide 6- 75
Department of Computer Science and Engg

Binary Relational Operations NATURAL Transform Here

JOIN
(contd.)
• Example: To apply a natural join on the DNUMBER attributes of
DEPARTMENT and DEPT_LOCATIONS, it is sufficient to write:
• DEPT_LOCS ← DEPARTMENT * DEPT_LOCATIONS
• Only attribute with the same name is DNUMBER
• An implicit join condition is created based on this attribute:
DEPARTMENT.DNUMBER=DEPT_LOCATIONS.DNUMBER

• Another example: Q ← R(A,B,C,D) * S(C,D,E)


• The implicit join condition includes each pair of attributes with the same
name, “AND”ed together:
• R.C=S.C AND R.D.S.D
• Result keeps only one attribute of each such pair:
• Q(A,B,C,D,E)

Slide 6- 76
Department of Computer Science and Engg

Transform Here

Example of NATURAL JOIN operation

Slide 6- 77
Department of Computer Science and Engg

Transform Here

Complete Set of Relational Operations

• The set of operations including SELECT σ, PROJECT π , UNION ∪,


DIFFERENCE − , RENAME ρ, and CARTESIAN PRODUCT X is called
a
complete set because any other relational algebra expression can
be
expressed by a combination of these five operations.
•Rexample:
• For S=σ (R X S)
•R ∩ S = (R ∪ S ) – ((R − S) ∪ (S − R))
<join condition> <join condition>

Slide 6- 78
Department of Computer Science and Engg

Transform Here

Binary Relational Operations: DIVISION

•DIVISION Operation
• The division operation is applied to two relations
• R(Z) ÷ S(X), where X subset Z. Let Y = Z - X (and hence Z = X
∪ Y); that is, let Y be the set of attributes of R that are not
attributes of S.

• The result of DIVISION is a relation T(Y) that includes a tuple t if


tuples tR appear in R with tR [Y] = t, and with
• tR [X] = ts for every tuple ts in S.

• For a tuple t to appear in the result T of the DIVISION, the


values in t must appear in R in combination with every tuple
in S.
Slide 6- 79
Department of Computer Science and Engg

Transform Here

Example of DIVISION

Slide 6- 80
Department of Computer Science and Engg

Transform Here

Recap of Relational Algebra Operations

Slide 6- 81
Department of Computer Science and Engg

Transform Here

Additional Relational Operations:


Aggregate Functions and Grouping
•A type of request that cannot be expressed in the
basic relational algebra is to specify mathematical
aggregate functions on collections of values from
the database.
•Examples of such functions include retrieving the average
or total salary of all employees or the total number of
employee tuples.
• These functions are used in simple statistical queries that
summarize Computer from the database tuples.
•Common functions applied to collections of numeric
values include
• SUM, AVERAGE, MAXIMUM, and MINIMUM.
•The COUNT function is used for counting tuples or values.
Slide 6- 82
Department of Computer Science and Engg

Transform Here

Aggregate Function Operation

•Use of the Aggregate Functional operation ℱ


• ℱMAX Salary (EMPLOYEE) retrieves the maximum salary value
from the EMPLOYEE relation
• ℱMIN Salary (EMPLOYEE) retrieves the minimum Salary value from
the EMPLOYEE relation
• ℱSUM Salary (EMPLOYEE) retrieves the sum of the Salary from the
EMPLOYEE relation
• ℱCOUNT SSN, AVERAGE Salary(EMPLOYEE) computes the
count (number) of employees and their average salary
• Note: count just counts the number of rows, without
removing duplicates

Slide 6- 83
Department of Computer Science and Engg

Transform Here

Using Grouping with Aggregation

•The previous examples all summarized one or


more attributes for a set of tuples
• Maximum Salary or Count (number of) Ssn
•Grouping can be combined with Aggregate Functions
•Example: For each department, retrieve the DNO,
COUNT SSN, and AVERAGE SALARY
•A variation of aggregate operation ℱ allows this:
• Grouping attribute placed to left of symbol
• Aggregate functions to right of symbol
ℱ (EMPLOYEE)
• DNO COUNT SSN, AVERAGE Salary
•Above operation groups employees by DNO (department
number) and computes the count of employees and
average salary per department Slide 6- 84
Department of Computer Science and Engg

Transform Here

Examples of applying aggregate functions


and grouping

Slide 6- 85
Department of Computer Science and Engg

Transform Here

Illustrating aggregate functions and grouping

Slide 6- 86
Department of Computer Science and Engg

Transform Here

Additional Relational Operations (cont.)


• Recursive Closure Operations
•Another type of operation that, in general, cannot
be specified in the basic original relational
algebra is recursive closure.
• This operation is applied to a recursive relationship.

•An example of a recursive operation is to retrieve


all SUPERVISEES of an EMPLOYEE e at all levels
— that is, all EMPLOYEE e’ directly supervised by
e; all employees e’’ directly supervised by each
employee e’; all employees e’’’ directly
supervised by each employee e’’; and so on.

Slide 6- 87
Department of Computer Science and Engg

Transform Here

Additional Relational Operations (cont.)


• Although it is possible to retrieve employees at each level and
then take their union, we cannot, in general, specify a query such
as
“retrieve the supervisees of ‘James Borg’ at all levels” without
utilizing a looping mechanism.
•The SQL3 standard includes syntax for
recursive closure.

Slide 6- 88
Department of Computer Science and Engg

Transform Here

Additional Relational Operations


(cont.)
■ Click to edit Master text
styles
■ Second level
■ Third level
■ Fourth level
■ Fifth level

Slide 6- 89
Department of Computer Science and Engg

Transform Here

Additional Relational Operations (cont.)

•The OUTER JOIN Operation


• In NATURAL JOIN and EQUIJOIN, tuples without a matching (or
related) tuple are eliminated from the join result
• Tuples with null in the join attributes are also eliminated
• This amounts to loss of Computer.
• A set of operations, called OUTER joins, can be used when we
want to keep all the tuples in R, or all those in S, or all those in
both relations in the result of the join, regardless of whether
or not they have matching tuples in the other relation.

Slide 6- 90
Department of Computer Science and Engg

Transform Here

Additional Relational Operations (cont.)


• The left outer join operation keeps every tuple in the first or
left relation R in R S; if no matching tuple is found in S,
then the attributes of S in the join result are filled or
“padded” with null values.
• A similar operation, right outer join, keeps every tuple in the
second or right relation S in the result of R S.
• A third operation, full outer join, denoted by keeps all tuples in
both the left and the right relations when no matching tuples are
found, padding them with null values as needed.

Slide 6- 91
Department of Computer Science and Engg

Transform Here

Additional Relational Operations (cont.)

Slide 6- 92
Department of Computer Science and Engg

Transform Here

Additional Relational Operations (cont.)


• OUTER UNION Operations
•The outer union operation was developed to
take the union of tuples from two relations if
the relations are not type compatible.
•This operation will take the union of tuples in
two relations R(X, Y) and S(X, Z) that are
partially compatible, meaning that only some of
their attributes, say X, are type compatible.
•The attributes that are type compatible are
represented only once in the result, and those
attributes that are not type compatible from
either relation are also kept in the result
relation T(X, Y, Z).
Slide 6- 93
Department of Computer Science and Engg

Transform Here

Additional Relational Operations (cont.)


•Example: An outer union can be applied to two relations
whose schemas are STUDENT(Name, SSN, Department,
Advisor) and INSTRUCTOR(Name, SSN, Department,
Rank).
• Tuples from the two relations are matched based on having
the same combination of values of the shared attributes—
Name, SSN, Department.
• If a student is also an instructor, both Advisor and Rank will have
a
value; otherwise, one of these two attributes will be null.
• The result relation STUDENT_OR_INSTRUCTOR will have
the following attributes:
STUDENT_OR_INSTRUCTOR (Name, SSN,
Department, Advisor, Rank)
Slide 6- 94
Department of Computer Science and Engg

Transform Here

Examples of Queries in Relational Algebra


■ Q1: Retrieve the name and address of all employees who work for the
‘Research’ department.
RESEARCH_DEPT ← σ DNAME=’Research’ (DEPARTMENT)
RESEARCH_EMPS ← (RESEARCH_DEPT EMPLOYEE)
DNUMBER= DNOEMPLOYEE

RESULT ← π FNAME, LNAME, ADDRESS (RESEARCH_EMPS)

■ Q6: Retrieve the names of employees who have no dependents.


ALL_EMPS ← π SSN(EMPLOYEE)

EMPS_WITH_DEPS(SSN) ← π
ESSN (DEPENDENT)
EMPS_WITHOUT_DEPS ← (ALL_EMPS - EMPS_WITH_DEPS)
RESULT ← π LNAME, FNAME (EMPS_WITHOUT_DEPS *
EMPLOYEE)
Slide 6- 95
Department of Computer Science and Engg

Transform Here

Data Definition, Constraints, and


Schema Changes
• Used to CREATE, DROP, and ALTER the descriptions of the
tables (relations) of a database

Slide 8- 96
Department of Computer Science and Engg

Transform Here

CREATE
TABLE
•Specifies a new base relation by giving it a name, and
specifying each of its attributes and their data types
(INTEGER, FLOAT, DECIMAL(i,j), CHAR(n),
VARCHAR(n))
•A constraint NOT NULL may be specified on an
attribute
DNAME VARCHAR(10) NOT NULL,
DNUMBER
CREATE DEPARTMENT ( NOT NULL,
INTEGER
TABLE
MGRSSN CHAR(9),
MGRSTARTDATE CHAR(9) );

Slide 8- 97
Department of Computer Science and Engg

Transform Here

CREATE
TABLE
• In SQL2, can use the CREATE TABLE command for specifying the primary key
attributes, secondary keys, and referential integrity constraints (foreign
keys).
• Key attributes can be specified via the PRIMARY KEY and UNIQUE phrases
CREATE
DNAME TABLE DEPTVARCHAR(10)
( NOT
NULL,
DNUMBER INTEGERNOT NULL,
MGRSSN CHAR(9),
MGRSTARTDATE CHAR(9),
PRIMARY KEY (DNUMBER),
UNIQUE (DNAME),
FOREIGN KEY (MGRSSN) REFERENCES EMP
);
Slide 8- 98
Department of Computer Science and Engg

DROP Transform Here

TABLE
• Used to remove a relation (base table) and its definition
• The relation can no longer be used in queries, updates, or any
other
commands since its description no longer exists
• Example:

DROP TABLE DEPENDENT;

Slide 8- 99
Department of Computer Science and Engg

Transform Here

ALTER TABLE
• Used to add an attribute to one of the base relations
•The new attribute will have NULLs in all the tuples of
the relation right after the command is executed;
hence, the NOT NULL constraint is not allowed
for such an attribute
• Example:
ALTER TABLE EMPLOYEE ADD JOB
VARCHAR(12);

• The database users must still enter a value for the new attribute
JOB for each EMPLOYEE tuple.
•This can be done using the UPDATE command.
Slide 8- 100
Department of Computer Science and Engg

Transform Here

Features Added in SQL2 and SQL-99


• Create schema
• Referential integrity
options

Slide 8- 101
Department of Computer Science and Engg

Transform Here

CREATE SCHEMA
• Specifies a new database schema by giving it a name

Slide 8- 102
Department of Computer Science and Engg

Transform Here

REFERENTIAL INTEGRITY OPTIONS


•We can specify RESTRICT, CASCADE, SET NULL or SET
DEFAULT
on referential integrity constraints (foreign keys)
CREATE TABLE DEPT (
DNAME VARCHAR(10) NOT NULL,
DNUMBER INTEGER NOT NULL,
MGRSSN CHAR(9), MGRSTARTDATE
CHAR(9),
PRIMARY KEY (DNUMBER),
UNIQUE (DNAME),
FOREIGN KEY (MGRSSN) REFERENCES
EMP ON DELETE SET DEFAULT ON UPDATE Slide 8- 103
Department of Computer Science and Engg

REFERENTIAL INTEGRITY Transform Here

OPTIONS
(continued)
CREATE TABLE EMP(
ENAME VARCHAR(30) NOT NULL,
ESSN CHAR(9),
BDATE DATE,
DNO INTEGER DEFAULT 1,
SUPERSSNCHAR(9),
PRIMARY KEY (ESSN),
FOREIGN KEY (DNO) REFERENCES DEPT
ON DELETE SET DEFAULT ON UPDATE
CASCADE,
FOREIGN KEY (SUPERSSN) REFERENCES EMP
ON DELETE SET NULL ON UPDATE
Slide 8- 104
CASCADE);
Department of Computer Science and Engg

Transform Here

Additional Data Types in SQL2 and SQL-99

Has DATE, TIME, and TIMESTAMP data types


•DATE:
• Made up of year-month-day in the format yyyy-mm-dd
•TIME:
• Made up of hour:minute:second in the format
hh:mm:ss
•TIME(i):
• Made up of hour:minute:second plus i additional
digits specifying fractions of a second
• format is hh:mm:ss:ii...i

Slide 8- 105
Department of Computer Science and Engg

Transform Here

Additional Data Types in SQL2 and


SQL-99 (contd.)
• TIMESTAMP:
•Has both DATE and TIME components
• INTERVAL:
•Specifies a relative value rather than an absolute
value
•Can be DAY/TIME intervals or YEAR/MONTH
intervals
•Can be positive or negative when added to or
subtracted from an absolute value, the result is
an absolute value
Slide 8- 106
Department of Computer Science and Engg

Transform Here

Retrieval Queries in
SQL
•SQL has one basic statement for retrieving Computer from
a database; the SELECT statement
• This is not the same as the SELECT operation of the
relational algebra
•Important distinction between SQL and the formal
relational model:
• SQL allows a table (relation) to have two or more tuples that
are identical in all their attribute values
• Hence, an SQL relation (table) is a multi-set (sometimes called
a bag) of tuples; it is not a set of tuples
•SQL relations can be constrained to be sets by
specifying PRIMARY KEY or UNIQUE attributes, or by Slide 8- 107
Department of Computer Science and Engg

Transform Here

Retrieval Queries in SQL (contd.)

• A bag or multi-set is like a set, but an element may appear more


than once.
•Example: {A, B, C, A} is a bag. {A, B, C} is also
a bag that also is a set.
•Bags also resemble lists, but the order
is irrelevant in a bag.
• Example:
•{A, B, A} = {B, A, A} as bags
•However, [A, B, A] is not equal to [B, A, A] as lists

Slide 8- 108
Department of Computer Science and Engg

Transform Here

Retrieval Queries in SQL (contd.)


•Basic form of the SQL SELECT statement is called a
mapping
or a SELECT-FROM-WHERE block
SELECT <attribute
FROM list>
WHERE <table list>
<condition>
• <attribute list> is a list of attribute names whose values are
to be retrieved by the query
• <table list> is a list of the relation names required to
process the query
• <condition> is a conditional (Boolean) expression that
identifies
the tuples to be retrieved by the query Slide 8- 109
Department of Computer Science and Engg

Transform Here

Simple SQL Queries

• Basic SQL queries correspond to using the following operations of


the relational algebra:
•SELECT
•PROJECT
•JOIN
• All subsequent examples use the COMPANY database

Slide 8- 110
Department of Computer Science and Engg

Transform Here

Simple SQL Queries (contd.)


•Example of a simple query on one relation
•Query 0: Retrieve the birthdate and address of the
employee whose name is 'John B. Smith'.
Q0: SELECT BDATE, ADDRESS FROM
EMPLOYEE
WHERE FNAME='John' AND MINIT='B’
AND LNAME='Smith’
• Similar to a SELECT-PROJECT pair of relational
algebra operations:
• The SELECT-clause specifies the projection attributes and the
WHERE-clause specifies the selection condition
• However, the result of the query may contain duplicate tuples

Slide 8- 111
Department of Computer Science and Engg

Transform Here

Simple SQL Queries (contd.)


•Query 1: Retrieve the name and address of all
employees who work for the 'Research' department.
Q1: SELECT FNAME, LNAME, ADDRESS
FROM EMPLOYEE, DEPARTMENT
WHERE DNAME='Research' AND DNUMBER=DNO

• Similar to a SELECT-PROJECT-JOIN sequence of


relational algebra operations
• (DNAME='Research') is a selection condition (corresponds to a
SELECT operation in relational algebra)
• (DNUMBER=DNO) is a join condition (corresponds to a JOIN
operation in relational algebra)
Slide 8- 112
Department of Computer Science and Engg

Transform Here

Simple SQL Queries (contd.)


• Query 2: For every project located in 'Stafford', list the project number,
the controlling department number, and the department manager's
last name, address, and birthdate.

Q2: SELECT PNUMBER, DNUM, LNAME, BDATE, ADDRESS


FROM
WHERE PROJECT, DEPARTMENT,
DNUM=DNUMBER ANDEMPLOYEE
MGRSSN=SSN
AND PLOCATION='Stafford'

• In Q2, there are two join conditions


• The join condition DNUM=DNUMBER relates a project to
its controlling department
• The join condition MGRSSN=SSN relates the controlling department
to the employee who manages that department
Slide 8- 113
Department of Computer Science and Engg

Transform Here

Aliases, * and DISTINCT, Empty


WHERE-clause
• In SQL, we can use the same name for two (or more) attributes
as long as the attributes are in different relations
• A query that refers to two or more attributes with the same name
must qualify the attribute name with the relation name by
prefixing the relation name to the attribute name
• Example:

• EMPLOYEE.LNAME, DEPARTMENT.DNAME

Slide 8- 114
Department of Computer Science and Engg

Transform Here

ALIASES
• Some queries need to refer to the same relation twice
• In this case, aliases are given to the relation name
• Query 8: For each employee, retrieve the employee's name, and the
name of his or her immediate supervisor.
Q8: SELECT E.FNAME, E.LNAME, S.FNAME, S.LNAME
FROM EMPLOYEE E S
WHERE E.SUPERSSN=S.SSN
• In Q8, the alternate relation names E and S are called aliases or tuple
variables for the EMPLOYEE relation
• We can think of E and S as two different copies of EMPLOYEE;
E represents employees in role of supervisees and S
represents employees in role of supervisors

Slide 8- 115
Department of Computer Science and Engg

Transform Here

ALIASES
(contd.)
• Aliasing can also be used in any SQL query for
convenience
• Can also use the AS keyword to specify aliases

Q8: SELECT E.FNAME, E.LNAME,


S.FNAME, S.LNAME
FROMEMPLOYEE AS E,
EMPLOYEE AS S
WHERE E.SUPERSSN=S.SSN

Slide 8- 116
Department of Computer Science and Engg

UNSPECIFIED Transform Here

WHERE-claus
e
•A missing WHERE-clause indicates no condition; hence,
all tuples of the relations in the FROM-clause are
selected
• This is equivalent to the condition WHERE TRUE
•Query 9: Retrieve the SSN values for all employees.
• Q9: SELECT SSN
FROM EMPLOYEE

•If more than one relation is specified in the


FROM-clause and there is no join condition, then the
CARTESIAN PRODUCT of tuples is selected

Slide 8- 117
Department of Computer Science and Engg

UNSPECIFIED Transform Here

WHERE-clause
(contd.)
• Example:

Q10: SELECT SSN, DNAME


FROM EMPLOYEE,
DEPARTMENT
•It is extremely important not to overlook
specifying any selection and join conditions in the
WHERE-clause; otherwise, incorrect and very
large relations may result

Slide 8- 118
Department of Computer Science and Engg

Transform Here

USE OF *

•To retrieve all the attribute values of the selected tuples, a


* is used, which stands for all the attributes
Examples:
Q1C: SELECT *
FROM EMPLOYE
WHERE E
DNO=5
Q1D: SELECT *
FROM EMPLOYEE,
WHERE DEPARTMENT
DNO=DNUMBER
DNAME='Research' AND

Slide 8- 119
Department of Computer Science and Engg

Transform Here

USE OF DISTINCT

•SQL does not treat a relation as a set; duplicate tuples


can appear
•To eliminate duplicate tuples in a query result, the
keyword
DISTINCT is used
•For example, the result of Q11 may have duplicate
Q11: values
SALARY SALARY
SELECT whereas Q11A does not have any
duplicate FROM
values EMPLOYEE
Q11A:
DISTINCT SALARY
SELECT EMPLOYEE
FROM

Slide 8- 120
Department of Computer Science and Engg

Transform Here

SET OPERATIONS
•SQL has directly incorporated some set operations
•There is a union operation (UNION), and in some versions
of SQL there are set difference (MINUS) and intersection
(INTERSECT) operations
•The resulting relations of these set operations are sets
of tuples; duplicate tuples are eliminated from the
result
•The set operations apply only to union compatible
relations; the two relations must have the same
attributes and the attributes must appear in the same
order
Slide 8- 121
Department of Computer Science and Engg

Transform Here

SET OPERATIONS (contd.)

• Query 4: Make a list of all project numbers for projects that involve an
employee whose last name is 'Smith' as a worker or as a manager of
the department that controls the project.

Q4: (SELECT PNAME PROJECT,


FROM
EMPLOYE DEPARTMENT,
DNUM=DNUMBER AND
E WHERE
MGRSSN=SSN AND LNAME='Smith')
UNION
(SELECT PNAME
FROM PROJECT, WORKS_ON,
WHERE EMPLOYEE PNUMBER=PNO AND
ESSN=SSN AND NAME='Smith')

Slide 8- 122
Department of Computer Science and Engg

Transform Here

NESTING OF QUERIES
•A complete SELECT query, called a nested query, can be
specified within the WHERE-clause of another query,
called the outer query
• Many of the previous queries can be specified in an
alternative form using nesting
•Query 1: Retrieve the name and address of all
employees who work for the 'Research' department.

Q1: SELECT FNAME, LNAME, ADDRESS FROM


EMPLOYEE
WHERE DNO IN (SELECTDNUMBER
FROM DEPARTMENT
WHERE DNAME='Research' )

Slide 8- 123
Department of Computer Science and Engg

Transform Here

NESTING OF QUERIES (contd.)


•The nested query selects the number of the
'Research' department
•The outer query select an EMPLOYEE tuple if its DNO value
is in the result of either nested query
•The comparison operator IN compares a value v with a set
(or multi-set) of values V, and evaluates to TRUE if v is one
of the elements in V
•In general, we can have several levels of nested queries
•A reference to an unqualified attribute refers to the
relation declared in the innermost nested query
•In this example, the nested query is not correlated with
Slide 8- 124
the outer query
Department of Computer Science and Engg

Transform Here

CORRELATED NESTED QUERIES


• If a condition in the WHERE-clause of a nested query references an
attribute of a relation declared in the outer query, the two queries
are said to be correlated
• The result of a correlated nested query is different for each tuple
(or combination of tuples) of the relation(s) the outer query
• Query 12: Retrieve the name of each employee who has a dependent
with the same first name as the employee.
Q12: SELECT E.FNAME, E.LNAME
FROM EMPLOYEE AS E
WHERE E.SSN IN
ESSN
(SELECT DEPENDENT
FROM ESSN=E.SSN AND
E.FNAME=DEPENDENT_NAME)
WHERE
Slide 8- 125
Department of Computer Science and Engg

Transform Here

CORRELATED NESTED QUERIES (contd.)


•In Q12, the nested query has a different result in the
outer query
•A query written with nested SELECT... FROM... WHERE...
blocks and using the = or IN comparison operators can
always be expressed as a single block query. For
example, Q12 may be written as in Q12A
Q12A: SELECT E.FNAME, E.LNAME
FROM EMPLOYEE E, DEPENDENT
WHERE D E.SSN=D.ESSN AND
E.FNAME=D.DEPENDENT_NAME

Slide 8- 126
Department of Computer Science and Engg

Transform Here

CORRELATED NESTED QUERIES (contd.)


•The original SQL as specified for SYSTEM R also had
a CONTAINS comparison operator, which is used in
conjunction with nested correlated queries
• This operator was dropped from the language,
possibly because of the difficulty in implementing it
efficiently
• Most implementations of SQL do not have this
operator
• The CONTAINS operator compares two sets of values,
and
returns TRUE if one set contains all values in the other
set
• Reminiscent of the division operation of algebra Slide 8- 127
Department of Computer Science and Engg

Transform Here

CORRELATED NESTED QUERIES (contd.)


•Query 3: Retrieve the name of each employee who works
on all the projects controlled by department number 5.
Q3: SELECT FNAME, LNAME
FROM EMPLOYE
WHERE ( (SELECTPNO
E
FROM WORKS_ON
WHERE SSN=ESSN)
CONTAIN
S
(SELECT PNUMBER
FROM PROJECT
WHERE DNUM=5) )

Slide 8- 128
Department of Computer Science and Engg

Transform Here

CORRELATED NESTED QUERIES (contd.)


• In Q3, the second nested query, which is not correlated with the
outer query, retrieves the project numbers of all projects
controlled by department 5
• The first nested query, which is correlated, retrieves the project
numbers on which the employee works, which is different for
each employee tuple because of the correlation

Slide 8- 129
Department of Computer Science and Engg

Transform Here

THE EXISTS FUNCTION

• EXISTS is used to check whether the result of a correlated


nested query is empty (contains no tuples) or not
•We can formulate Query 12 in an alternative
form that uses EXISTS as Q12B

Slide 8- 130
Department of Computer Science and Engg

Transform Here

THE EXISTS FUNCTION (contd.)


• Query 12: Retrieve the name of each employee who has a
dependent with the same first name as the employee.

Q12B: SELECT FNAME, LNAME


FROM EMPLOYEE
WHERE EXISTS *
FROM DEPENDENT
(SELECT
WHERE SSN=ESSN
AND
FNAME=DEPENDENT_NAME)

Slide 8- 131
Department of Computer Science and Engg

Transform Here

THE EXISTS FUNCTION (contd.)


•Query 6: Retrieve the names of employees who have
no dependents.

Q6: SELECT FNAME, LNAME


FROM EMPLOYEE
WHERE NOT EXISTS (SELECT *
FROM DEPENDENT
WHERE SSN=ESSN)
•In Q6, the correlated nested query retrieves all
DEPENDENT tuples related to an EMPLOYEE tuple. If none
exist, the EMPLOYEE tuple is selected
• EXISTS is necessary for the expressive power of SQL

Slide 8- 132
Department of Computer Science and Engg

Transform Here

EXPLICIT SETS

• It is also possible to use an explicit (enumerated) set of values in


the WHERE-clause rather than a nested query
• Query 13: Retrieve the social security numbers of all employees who
work on project number 1, 2, or 3.
Q13: SELECT DISTINCT ESSN
FROM WORKS_ON
WHERE PNO IN (1, 2, 3)

Slide 8- 133
Department of Computer Science and Engg

Transform Here

NULLS IN SQL QUERIES

•SQL allows queries that check if a value is NULL (missing


or undefined or not applicable)
•SQL uses IS or IS NOT to compare NULLs because it
considers each NULL value distinct from other NULL
values, so equality comparison is not appropriate.
•Query 14: Retrieve the names of all employees who do
Q14: haveSELECT
not FNAME, LNAME
supervisors.
FROM EMPLOYEE
WHERE SUPERSSN IS NULL
• Note: If a join condition is specified, tuples with NULL values
for the join attributes are not included in the result

Slide 8- 134
Department of Computer Science and Engg

Transform Here

Joined Relations
Feature in SQL2
• Can specify a "joined relation" in the FROM-clause
•Looks like any other relation but is the result of a
join
•Allows the user to specify different types of joins
(regular "theta" JOIN, NATURAL JOIN, LEFT OUTER
JOIN, RIGHT OUTER JOIN, CROSS JOIN,
•etc)

Slide 8- 135
Department of Computer Science and Engg

Transform Here

Joined Relations
Feature in SQL2
(contd.)
•Examples:
Q8: SELECT E.FNAME, E.LNAME, S.FNAME, S.LNAME
FROM EMPLOYEE E S
WHERE E.SUPERSSN=S.SSN

•can be written as:


Q8: SELECT E.FNAME, E.LNAME, S.FNAME, S.LNAME
FROM (EMPLOYEE E LEFT OUTER JOIN
EMPLOYEES ON E.SUPERSSN=S.SSN)

Slide 8- 136
Department of Computer Science and Engg

Joined Relations Transform Here

Feature in SQL2
(contd.)
•Examples:
Q1: SELECT FNAME, LNAME, ADDRESS
FROM EMPLOYEE, DEPARTMENT
WHERE DNAME='Research' AND DNUMBER=DNO
•could be written as:
Q1: SELECT FNAME, LNAME, ADDRESS FROM
ON DNUMBER=DNO)
(EMPLOYEE
WHERE JOIN DEPARTMENT
DNAME='Research’
•or as:
Q1: SELECT FNAME, LNAME, ADDRESS
FROM (EMPLOYEE NATURAL JOIN DEPARTMENT
AS DEPT(DNAME, DNO, MSSN,
WHERE MSDATE)
DNAME='Research’
Slide 8- 137
Department of Computer Science and Engg

Joined Relations Transform Here

Feature in SQL2
(contd.)
• Another Example: Q2 could be written as follows; this
illustrates multiple joins in the joined tables
Q2: SELECT PNUMBER, DNUM,
LNAME, BDATE, ADDRESS
FROM(PROJECT JOIN
DEPARTMENT ON
DNUM=DNUMBER) JOIN
EMPLOYEE ON
MGRSSN=SSN) )
WHERE PLOCATION='Stafford’
Slide 8- 138
Department of Computer Science and Engg

Transform Here

AGGREGATE FUNCTIONS

• Include COUNT, SUM, MAX, MIN, and AVG


• Query 15: Find the maximum salary, the minimum salary, and the
average salary among all employees.
Q15: SELECT MAX(SALARY),
MIN(SALARY),
AVG(SALARY) FROM
EMPLOYEE

• Some SQL implementations may not allow more than one function
in the SELECT-clause

Slide 8- 139
Department of Computer Science and Engg

Transform Here

AGGREGATE FUNCTIONS (contd.)

• Query 16: Find the maximum salary, the minimum salary, and
the average salary among employees who work for the
'Research' department.
Q16: SELECT MAX(SALARY),
MIN(SALARY),
FROM EMPLOYEE,
AVG(SALARY)
WHERE DEPARTMENT
DNAME='Research
DNO=DNUMBER AND
'

Slide 8- 140
Department of Computer Science and Engg

Transform Here

AGGREGATE FUNCTIONS (contd.)

•Queries 17 and 18: Retrieve the total number of


employees in the company (Q17), and the number of
employees in the 'Research' department (Q18).
Q17: SELECT COUNT (*)
FROM EMPLOYE
E
Q18: SELECT COUNT (*)
FROM EMPLOYEE,
WHERE
DNAME='Research’DEPARTMENT DNO=DNUMBER
AND

Slide 8- 141
Department of Computer Science and Engg

Transform Here

GROUPING
• In many cases, we want to apply the aggregate functions to
subgroups of tuples in a relation
• Each subgroup of tuples consists of the set of tuples that have the
same value for the grouping attribute(s)
• The function is applied to each subgroup independently
• SQL has a GROUP BY-clause for specifying the grouping
attributes,
which must also appear in the SELECT-clause

Slide 8- 142
Department of Computer Science and Engg

Transform Here

GROUPING
(contd.)
•Query 20: For each department, retrieve the department
number, the number of employees in the department,
and their average salary.
Q20: SELECT DNO, COUNT (*), AVG (SALARY)
FROM EMPLOYEE
GROUP BY DNO
• In Q20, the EMPLOYEE tuples are divided into groups-
• Each group having the same value for the grouping attribute DNO
• The COUNT and AVG functions are applied to each such
group of tuples separately
• The SELECT-clause includes only the grouping attribute and
the
functions to be applied on each group of tuples
• A join condition can be used in conjunction with grouping Slide 8- 143
Department of Computer Science and Engg

Transform Here

GROUPING (contd.)

•Query 21: For each project, retrieve the project number,


project name, and the number of employees who work
on that project.

Q21: SELECT PNUMBER, PNAME, COUNT (*)


FROM PROJECT, WORKS_ON
WHERE
PNUMBER=PNO
GROUP
BY PNUMBER, PNAME
• In this case, the grouping and functions are applied after the
joining of the two relations

Slide 8- 144
Department of Computer Science and Engg

Transform Here

THE HAVING-CLAUSE
• Sometimes we want to retrieve the values of these functions for
only those groups that satisfy certain conditions
• The HAVING-clause is used for specifying a selection condition on
groups (rather than on individual tuples)

Slide 8- 145
Department of Computer Science and Engg

Transform Here

THE HAVING-CLAUSE (contd.)


• Query 22: For each project on which more than two employees
work, retrieve the project number, project name, and the number
of employees who work on that project.
Q22: SELECT PNUMBER, PNAME,
COUNT(*)
FROM PROJECT,
WHERE WORKS_ON
GROUP BYPNUMBER=PNO
PNUMBER, PNAME
HAVING COUNT (*) > 2

Slide 8- 146
Department of Computer Science and Engg

Transform Here

SUBSTRING COMPARISON
• The LIKE comparison operator is used to compare partial strings
• Two reserved characters are used: '%' (or '*' in some
implementations) replaces an arbitrary number of characters, and
'_' replaces a single arbitrary character

Slide 8- 147
Department of Computer Science and Engg

Transform Here

SUBSTRING COMPARISON (contd.)

• Query 25: Retrieve all employees whose address is in Houston,


Texas. Here, the value of the ADDRESS attribute must contain
the substring 'Houston,TX‘ in it.
Q25: SELECT FNAME, LNAME
FROM EMPLOYEE
WHERE ADDRESS LIKE
'%Houston,TX%
'

Slide 8- 148
Department of Computer Science and Engg

Transform Here

SUBSTRING COMPARISON (contd.)


•Query 26: Retrieve all employees who were born during
the 1950s.
• Here, '5' must be the 8th character of the string (according
to our format for date), so the BDATE value is ' 5_', with
each underscore as a place holder for a single arbitrary
character.
Q26: SELECT FNAME, LNAME
FROM EMPLOYEE
WHERE BDATE LIKE ' 5_’
•The LIKE operator allows us to get around the fact that
each value is considered atomic and indivisible
• Hence, in SQL, character string attribute values are not
atomic
Slide 8- 149
Department of Computer Science and Engg

Transform Here

ARITHMETIC OPERATIONS
•The standard arithmetic operators '+', '-'. '*', and '/'
(for addition, subtraction, multiplication, and division,
respectively) can be applied to numeric values in an
SQL query result
•Query 27: Show the effect of giving all employees who
work on the 'ProductX' project a 10% raise.
Q27: SELECT FNAME, LNAME, 1.1*SALARY
FROM EMPLOYEE,
PROJECT
WORKS_ON,
WHERE SSN=ESSN AND PNO=PNUMBER
AND PNAME='ProductX’

Slide 8- 150
Department of Computer Science and Engg

Transform Here

ORDER
BY
•The ORDER BY clause is used to sort the tuples in a
query result based on the values of some attribute(s)
•Query 28: Retrieve a list of employees and the projects each
works in, ordered by the employee's department, and
within each department ordered alphabetically by
employee
Q28: last name.
SELECT DNAME, LNAME, FNAME, PNAME
FROM DEPARTMENT, EMPLOYEE,
WORKS_ON, PROJECT
WHERE DNUMBER=DNO AND SSN=ESSN
AND PNO=PNUMBER
ORDER BY DNAME, LNAME

Slide 8- 151
Department of Computer Science and Engg

Transform Here

ORDER BY (contd.)
• The default order is in ascending order of values
• We can specify the keyword DESC if we want a descending order;
the keyword ASC can be used to explicitly specify ascending
order, even though it is the default

Slide 8- 152
Department of Computer Science and Engg

Transform Here

Summary of SQL Queries


• A query in SQL can consist of up to six clauses, but only the first
two, SELECT and FROM, are mandatory. The clauses are specified
in the following order:
SELECT <attribute list>
FROM <table list>
[WHERE <condition>]
[GROUP
BY <grouping attribute(s)>]
[HAVING <group condition>]
[ORDER BY <attribute list>]

Slide 8- 153
Department of Computer Science and Engg

Transform Here

Summary of SQL Queries


(contd.)
• The SELECT-clause lists the attributes or functions to be retrieved
• The FROM-clause specifies all relations (or aliases) needed in the query
but not those needed in nested queries
• The WHERE-clause specifies the conditions for selection and join of
tuples from the relations specified in the FROM-clause
• GROUP BY specifies grouping attributes
• HAVING specifies a condition for selection of groups
• ORDER BY specifies an order for displaying the result of a query
• A query is evaluated by first applying the WHERE-clause, then GROUP
BY and HAVING, and finally the SELECT-clause

Slide 8- 154
Department of Computer Science and Engg

Transform Here

Specifying Updates in SQL


• There are three SQL commands to modify the database:
INSERT, DELETE, and UPDATE

Slide 8- 155
Department of Computer Science and Engg

Transform Here

INSERT
• In its simplest form, it is used to add one or more tuples to a
relation
• Attribute values should be listed in the same order as the attributes
were specified in the CREATE TABLE command

Slide 8- 156
Department of Computer Science and Engg

INSERT
Transform Here

(contd.)
•Example:
U1: INSERT INTO EMPLOYEE
VALUES ('Richard','K','Marini', '653298653', '30-DEC-52',
'98 Oak Forest,Katy,TX', 'M', 37000,'987654321', 4 )

•An alternate form of INSERT specifies explicitly the


attribute names that correspond to the values in the new
tuple
• Attributes with NULL values can be left out
•Example: Insert a tuple for a new EMPLOYEE for whom
we only know the FNAME, LNAME, and SSN attributes.
U1A:INSERT INTO EMPLOYEE (FNAME, LNAME,
SSN)
VALUES ('Richard', 'Marini', '653298653') Slide 8- 157
Department of Computer Science and Engg

INSERT
Transform Here

(contd.)
• Important Note: Only the constraints specified in the DDL commands
are automatically enforced by the DBMS when updates are
applied to the database
•Another variation of INSERT allows insertion
of multiple tuples resulting from a query into a
relation

Slide 8- 158
Department of Computer Science and Engg

Transform Here

INSERT
(contd.)
• Example: Suppose we want to create a temporary table that has the
name, number of employees, and total salaries for each department.
• A table DEPTS_INFO is created by U3A, and is loaded with the
summary Computer retrieved from the database by the query in
U3B.
U3A: CREATE TABLE DEPTS_INFO
(DEPT_NAME VARCHAR(10),
NO_OF_EMPS INTEGER,
TOTAL_SAL INTEGER);
U3B: INSERT INTO DEPTS_INFO (DEPT_NAME,
NO_OF_EMPS, TOTAL_SAL)
SELECT DNAME, COUNT (*), SUM (SALARY)
FROM DEPARTMENT, EMPLOYEE
WHERE DNUMBER=DNO
GROUP BY DNAME ;

Slide 8- 159
Department of Computer Science and Engg

INSERT Transform Here

(contd.)
• Note: The DEPTS_INFO table may not be up-to-date if we change the
tuples in either the DEPARTMENT or the EMPLOYEE relations after
issuing U3B. We have to create a view (see later) to keep such a
table up to date.

Slide 8- 160
Department of Computer Science and Engg

Transform Here

DELETE
•Removes tuples from a relation
• Includes a WHERE-clause to select the tuples to be deleted
• Referential integrity should be enforced
• Tuples are deleted from only one table at a time (unless
CASCADE is specified on a referential integrity
constraint)
• A missing WHERE-clause specifies that all tuples in the relation
are to be deleted; the table then becomes an empty table
• The number of tuples deleted depends on the number of
tuples in the relation that satisfy the WHERE-clause

Slide 8- 161
Department of Computer Science and Engg

DELETE Transform Here

(contd.)
• Examples:
U4A: DELETE FROM EMPLOYEE
WHERE LNAME='Brown’
U4B: DELETE FROM EMPLOYEE
WHERE SSN='123456789’
U4C: DELETE FROM EMPLOYEE
WHERE DNO IN
(SELECT DNUMBER
FROM
DEPARTMENT
WHERE
DNAME='Research')
U4D: DELETE FROM EMPLOYEE

Slide 8- 162
Department of Computer Science and Engg

Transform Here

UPDAT
E
• Used to modify attribute values of one or more selected tuples
• A WHERE-clause selects the tuples to be modified
• An additional SET-clause specifies the attributes to be modified and
their new values
• Each command modifies tuples in the same relation
• Referential integrity should be enforced

Slide 8- 163
Department of Computer Science and Engg

Transform Here
UPDATE
(contd.)
• Example: Change the location and controlling department number
of project number 10 to 'Bellaire' and 5, respectively.
U5: PROJECT
UPDAT PLOCATION =
DNUM = 5
E SET 'Bellaire',
WHERE PNUMBER=10

Slide 8- 164
Department of Computer Science and Engg

Transform Here

UPDATE
(contd.)
•Example: Give all employees in the 'Research' department
a 10% raise in salary.
U6: UPDATE EMPLOYEE
SET SALARY = SALARY *1.1
WHERE DNO IN (SELECT
FROM DEPARTMENT
DNUMBER
WHERE DNAME='Research')

•In this request, the modified SALARY value depends on


the original SALARY value in each tuple
• The reference to the SALARY attribute on the right of =
refers to the old SALARY value before modification
• The reference to the SALARY attribute on the left of = refers
to
the new SALARY value after modification Slide 8- 165
Department of Computer Science and Engg

Transform Here

Recap of SQL Queries

•A query in SQL can consist of up to six clauses, but only the


first two, SELECT and FROM, are mandatory. The clauses
are specified in the following order:
SELECT <attribute list>
FROM <table list>
[WHERE <condition>]
[GROUP
BY <grouping attribute(s)>]
[HAVING <group condition>]
[ORDER
•There areBYthree<attribute list>] to modify the
SQL commands
database:
INSERT, DELETE, and UPDATE
Slide 8- 166
Department of Computer Science and Engg

Transform Here

Contact Details:

Dr.Manjunath T N
Professor and Dean – ER
Department of Computer Science and Engg
BMS Institute of Technology and Management
Mobile: +91-9900130748
E-Mail: [email protected] / [email protected]

10-09-2020 167

You might also like