SYSTEMS
1
DEPARTMENT OF COMPUTER SCIENCE AND
ENGINEERING
Fifth
Semester
CS1 25 4 DATABASE MANAGEMEN T SYSTEMS
Prepared
By
H.Pra
ha
!e"t#rer$
CSE
CS1254 DATABASE MANAGEMENT
SYSTEMS
2
CS1 25 4 DATABASE MANAGEMEN T SYSTEMS
UNIT I FUNDAMENTALS 9
Purpose of database system Views of data Data models Database languages Database system architecture
Database users and administrator Entity Relationship model (E-R Model ) E-R diagrams Introduction to
relational databases
UNIT II RELATIONAL MODEL 9
!he relational model !he catalog !ypes "eys Relational algebra Domain relational calculus !uple
relational calculus #undamental operations $dditional operations %&' fundamentals Integrity
!riggers
%ecurity $d(anced %&' features Embedded %&' Dynamic %&' Missing information Views
Introduction to distributed databases and client)ser(er databases
UNIT III DATABASE DESIGN 9
#unctional dependencies *on-loss decomposition #unctional dependencies #irst %econd !hird normal
forms Dependency preser(ation +oyce)codd normal form Multi-(alued dependencies and fourth normal
form ,oin dependencies and fifth normal form
UNIT IV TRANSACTIONS 9
!ransaction concepts !ransaction reco(ery $-ID properties %ystem reco(ery Media reco(ery !wo
phase commit %a(e points %&' facilities for reco(ery -oncurrency *eed for concurrency 'oc.ing
protocols !wo phase loc.ing Intent loc.ing Deadloc. %eriali/ability Reco(ery Isolation 'e(els %&'
#acilities for -oncurrency.
UNIT V IMPLEMENTATION TECHNIQUES 9
0(er(iew of Physical %torage Media Magnetic Dis.s R$ID !ertiary %torage #ile 0rgani/ation
0rgani/ation of Records in #iles Inde1ing and 2ashing 0rdered Indices +3 !ree Inde1 #iles + !ree
inde1 files %tatic hashing Dynamic hashing &uery processing o(er(iew -atalog information for cost
estimation %election operation %orting ,oin operation Database !uning
Tot!" 45
TE#T BOO$S
4 %ilberschat/5 $5 "orth5 2# and %udharshan5 %., Database System Concepts, 5th Edition, Tata Mc-
6raw
2ill5 7889
2. Date, C. J., Kannan, A. and Samynathan, S., An !nt"od#ction to Database Systems, $th Edition,
%ea"son
Education5 7889
REFERENCES
&. E'mas"i, (. and )a*athe, S.+., ,#ndamenta's o- Database Systems, .
th
Edition5 Pearson ) $ddison
:esley5
788;
2. (ama/"ishnan, (., Database Mana0ement Systems, 1"d Edition, Mc-6raw 2ill5 788<
1. Sin0h, S. K., Database Systems Concepts, Desi0n and App'ications, &
st
Edition5 Pearson Education5
7889
CS1254 DATABASE MANAGEMENT
SYSTEMS
3
2)!T !
!)T(3D2CT!3)
Purpose of Database systems- Views of data- Data Models- Database 'anguages- Database system
$rchitecture Database users and $dministrator- Entity Relationship Model (ER model) E-R
Diagram Introduction to relational databases
&. !)T(3D2CT!3)
Dt= "nown facts that can be recorded that ha(e implicit meaning
Eg %tudent roll no5 names5 address etc
Dt%&'" collection of inter-related data organi/ed meaningfully for a specific purpose.
DBMS" D+M% is a collection of interrelated data and a set of program to access those data !he primary
goal of a D+M% is to pro(ide a way to store and retrie(e database information that is both convenient and
efficient
Dt%&' S(&t')" Database and D+M% collecti(ely .nown as database system
I*!R0D>-!I0* !0 #I'E $*D D$!$+$%E %?%!EM%=
D t % &' A ** !+ , t+o - &
+an.ing= all transactions
$irlines= reser(ations5 schedules
>ni(ersities= registration5 grades
%ales= customers5 products5 purchases
0nline retailers= order trac.ing5 customi/ed recommendations
Manufacturing= production5 in(entory5 orders5 supply chain
2uman resources= employee records5 salaries5 ta1 deductions
-redit card transactions
!elecommunications @ #inance
CS1254 DATABASE MANAGEMENT
SYSTEMS
4
2. %2(%3SE 3, DATA+ASE S4STEMS
D . / % , 0 & o1 Co-2'-t +o- ! F +! ' P . o , ' && +- 3 S (&t ' )
+. Dt .'45-4-,( -4 +-,o-&+&t'-,(
%ince the files and application programs are created by different programmers o(er a long
period of time5 the files ha(e different formats and the programs may be written in se(eral
programming language !he same piece of information may be duplicated in se(eral files
Fo. E6)*!'" !he address and phone number of particular customer may appear in a file that
consists of personal information and in sa(ing account records file also !his redundancy
leads to data consistency that is5 the (arious copies of the same data may no longer agree
Fo. '6)*!'" a changed customer address may be reflected in personal information file5 but
not in sa(ing account records file
++. D+11+,5!t( +- ,,'&&+-3 4t
-on(entional file processing en(ironments do not allow needed data to be retrie(ed in a
con(enient and efficient manner
Fo. E6)*!'" %uppose that ban. officer needs to find out the names of all customers who
li(e within the city5s .&&627 8ip code. The ban/ o--icer has now two choices= Either get
the list of customers and e1tract the needed information manually5 or as. the data
processing
department to ha(e a system programmer write the necessary application program +oth
alternati(es are unsatisfactory
+++. Dt +&o!t+o-
%ince5 data is scattered in (arious files5 and files may be in different formats5 it is difficult to
write new application programs to retrie(e appropriate data
+2. Co-,5..'-t ,,'&& -o)!+'&
In order to impro(e the o(erall performance of the system and obtain a faster response time
many systems allow multiple users to update the data simultaneously In such en(ironment5
interaction of concurrent updates may results in inconsistent data
Fo. E6)*!'" -onsider ban. account $5 with AB88If two customers with draw funds (say
AB8 and A488 resp ) from account $ at the same time5 the result of the concurrent e1ecutions
AC885 rather than A<B8 In order to guard against this possibility5 some form of super(ision
must be maintained in the system
2. Ato)+,+t( P.o%!')
%ystem failure will lead to atomicity problem
CS1254 DATABASE MANAGEMENT
SYSTEMS
5
Fo. E6)*!'" #ailure during transfer of fund from system $ to $ It will be debited from $
but not credited to + leading to wrong transaction
2+. Co-,5..'-t A,,'&& A-o)!+'&
In order to impro(e the o(erall performance of the system and obtain a faster response time
many systems allow multiple users to update the data simultaneously In such en(ironment5
interaction of concurrent updates may result in inconsistent data
Fo. E6)*!'" -onsider ban. account A5 containing AB88 If two customers withdraw funds
say AB8 and A488 respecti(ely) from account A at about the same time5 the result of the
concurrent e1ecutions may lea(e the account in an incorrect (or inconsistent) state +alance
will be AC88 instead of A<B8 !o protect against this possibility5 the system must maintain
some form of super(ision
2++. S',5.+t( *.o%!')&
*ot e(ery user of the database system should be able to access all the data %ystem should be
protected using proper security
Fo. E6)*!'" In a ban.ing system5 pay roll personnel should be only gi(en authority to see
the part of the database that has information about the (arious ban. employees !hey do not
need access to information about customer accounts
%ince application programs added to the system in an ad-hoc manner5 it is difficult to enforce
such security constraints
2+++. I-t'3.+t( *.o%!')&
!he data (alues stored in the database must satisfy certain types of consistency constrains
Fo. E6)*!'" !he balance of a ban. account may ne(er fall below a prescribed amount (say
A488)!hese constraints are enforced in the system by adding appropriate code in the (arious
application programs
A42- t3'& o1 Dt% &'
Data base is a way to consolidate and control the operational data centrally It is a better way to control
the operational data !he ad(antages of ha(ing a centrali/ed control of data are=
+. R'45-4-,( ,- %' .'45,'4
In non-database systems5 each application or department has its own pri(ate files resulting in
considerable amount of redundancy of the stored data !hus storage space is wasted +y ha(ing a
centrali/ed database most of this can be a(oided
++. I-,o-&+&t'-,( ,- %' 2o+4'4
CS1254 DATABASE MANAGEMENT
SYSTEMS
6
:hen the same data is duplicated and changes are made at one side5 which is not propagated
to the other site5 it gi(es rise to inconsistency !hen the two entries regarding the same data will not
agree %o5 if the redundancy is remo(ed5 chances of ha(ing inconsistent data are also remo(ed
+++. T7' 4t ,- %' &7.'4
!he data stored from one application5 can be used for another application !hus5 the data of
database stored for one application can be shared with new applications
+2. St-4.4& ,- %' '-1o.,'4
:ith central control of the database5 the D+$ can ensure that all applicable standards are
obser(ed in the representation of the data
2. S',5.+t( ,- %' '-1o.,'4
D+$ can define the access paths for accessing the data stored in database and he can define
authori/ation chec.s whene(er access to sensiti(e data is attempted
2+. I-t'3.+t( ,- %' )+-t+-'4
Integrity means that the data in the database is accurate -entrali/ed control of the data helps
in permitting the administrator to define integrity constraints to the data in the database
1. 9!E: 3, DATA
$ maDor purpose of a database system is to pro(ide users with an abstract (iew of the data !hat is5
the system hides certain details of how the data are stored and maintained
D t % &t . , t+o-
!he -omple1ity is hidden from the users through se(eral le(el of abstraction !here are three le(els
of data abstraction=
i P7(&+,! !'2'!" It is the lowest le(el of abstraction that describes how th e d a ta a r e a c tual l y stor e d
!he physical le(el describes comple1 low-le(el data structures in details
ii Lo3+,! !'2'!" It is the ne1t higher le(el of abstraction that describes w h a t d a ta a r e stor e d in th e
d a tab a se and what relationships e1ist among those data
iii V+'/ !'2'!" It is the highest le(el of abstraction that describes only part of the entire database
CS1254 DATABASE MANAGEMENT
SYSTEMS
7
F+35.' !he three le(els of data abstraction
D t I -4 ' * ' -4 ' - , '
!he ability to modify a scheme definition in one le(el without affecting a scheme definition in the
ne1t higher le(el is called data independence !here are two le(els of data independence=
1. P7(&+,! 4t +-4'*'-4'-,' is the ability to modify the physical scheme without causing application
programs to be rewritten Modifications at the physical le(el are occasionally necessary in order to impro(e
performance
2. Lo3+,! 4t +-4'*'-4'-,' is the ability to modify the conceptual scheme without causing application
programs to be rewritten Modifications at the conceptual le(el are necessary whene(er the logical structure
of the database is altered
'ogical data independence is more difficult to achie(e than physical data independence since
application programs are hea(ily dependent on the logical structure of the data they access
I- &t-,'& - 4 &,7')&
Database change o(er times as information is inserted and deleted !he collection of information
stored in the database at a particular moment is called an +-&t-,' of the database
!he o(erall design of the database is called the database &,7')
T(*'& o1 4t%&' &,7')&
+. P7(&+,! &,7')= It describes the database design at the physical le(el
++. Lo3+,! &,7')" It describes the database design at the physical le(el
CS1254 DATABASE MANAGEMENT
SYSTEMS
8
+++. S5%&,7')" $ database may also ha(e se(eral subschemas at the (iew le(el called as subschemas
that describe different (iews of the database
.. DATA M3DE;S
>nderlying structure of the database is called as data models
It is a collection of conceptual tools for describing data5 data relationships5 data semantics5 and
consistency constraints
It is a way to describe the design of the database at physical5 logical and (iew le(el
D+11'.'-t t(*'& o1 4t )o4'!& .'=
Entity relationship model
Relational model
2ierarchical model
*etwor. model
0bDect +ased model
0bDect Relational model
%emi %tructured Data model
E - t+ t( .' !t+o - & 7 +* ) o 4 ' !
It is based on a collection of real world things or obDects called entities and the relationship among
these obDects
!he Entity relationship model is widely used in database design
R ' !t+o - ! Mo4'!
!he relational model uses a collection of tables to represent both data and the relationship among
those data
Each table has multiple columns and each column has a uniEue name
%oftware such as 0racle5 Microsoft %&' %er(er and %ybase are based on the relational model
Eg Record +ased model It is based on fi1ed format records of se(eral types
H + '. ., 7 +,! M o 4 ' !
2ierarchical database organi/e data in to a tree data structure such that each record type has only one
owner
2ierarchical structures were widely used in the first main frame database management systems
'in.s are possible (ertically but not hori/ontally or diagonally
CS1254 DATABASE MANAGEMENT
SYSTEMS
9
A42-t3'&
2igh speed of access to large datasets
Ease of updates
%implicity= the design of a hierarchical database is simple
Data security= 2ierarchical model was the first database model that offered the data security
that is pro(ided and enforced by the D+M%
Efficiency= !he hierarchical database model is a (ery efficient one when the database
contains a large number of transactions5 using data whose relationships are fi1ed
D+&42-t3'&
Implementation comple1ity
Database management problems
'ac. of structural independence
N ' t/ o . 0 M o 4 ' !
!he model is based on directed graph theory
!he networ. model replaces the hierarchical tree with a graph thus allowing more general
connections among the nodes
!he main difference of the networ. model from the hierarchical model is its ability to handle many-
to-many (n= n) relationship or in other words5 it allows a record to ha(e more than one parent
E6)*!' is5 an employee wor.ing for two departments
S)*!' -'t/o.0 )o4'!
A42-t3'&"
-onceptual simplicity =
-apability to handle more relationship types=
Data independence=
D+&42-t3'&"
Detailed structural .nowledge is reEuired
'ac. of structural independence
O % 8' , t9B& ' 4 D t ) o 4 ' !
!he obDect- oriented model is an e1tension of E-R model
!he obDect- oriented model is based on a collection of obDects
$n obDect contains (alues stored in instance (ariables within the obDect
$n obDect also contains bodies of code that operate in the obDect these bodies of code are called
methods
0bDects that contain the same types of (alues and methods are grouped together into classes
A42-t3'&"
$pplications reEuire less code
$pplications use more natural data model
-ode is easier to maintain
It pro(ides higher performance management of obDects and comple1 interrelationships
between obDects
0bDect-oriented features impro(e producti(ityData access is easy
O % 8' , t R' !t+o - ! Mo4 ' !
0bDect-relational data model combines the feature of modern obDect-oriented programming
languages with relational database features
%ome of the obDect-relational systems a(ailable in the mar.et are I+M D+7 uni(ersal ser(er5
3"ac'e Co"po"ation5s oracle F5 Microsoft -orporations %&' ser(er ; and so
on
S ' ) + S t. 5, t5. ' 4 D t M o 4 ' !
!his data model allows the indi(idual data items of same type to ha(e different sets of attributes
0ther data model allows a particular type of data item to ha(e same set of attributes
E1tensible Mar.up 'anguage (GM') is used to represent structured data
5. DATA+ASE ;A)<2A<ES
$ database system pro(ides
$ Dt D'1+-+t+o- L-353' to specify the database schema (DD')
$ Dt M-+*5!t+o- L-353' to e1press database Eueries and updates
Data definition and data manipulation languages are not two separate languages but part of a single
database language such as %&' language
D t 4 ' 1 +- +t+o- ! - 3 5 3 '
DD' specifies the database schema and some additional properties to data
!he storage structure and access methods are specified using specified using special type of DD' called
s 4t &to.3' -4 4t 4'1+-+t+o- !-35age
!he data (alues stored in the database must satisfy certain ,o-&+&t'-,( ,o-&t.+-t& #or e1ample5
suppose the balance on an account should not fall below A488
Database system concentrates on constraints that ha(e less o(erload
1. Do)+- Co-&t.+-t&"
Domain of possible (alue should be associated with e(ery attributes
Eg integer type5 character type5 date)time type
Declaring attributes to a particular domain will act as a constraint on that (alue
!hey are tested as and when (alues are entered in to database
2. R'1'.'-t+! Co-&t.+-t&"
In some cases there will be (alue that appears in one relation for a gi(en set of attributes also
appears for a certain set of attributes in some other relation %uch constraint is called
Referential -onstraints
If any modification (iolates the constraints then the action that caused the (iolation should be
reDected
:. A&&'.t+o-&
It is a condition that database should always satisfy
Domains and referential integrity are special form of assertion
Eg E(ery loan should ha(e a customer whose account balance is minimum of A488888
Modifications to database should not cause (iolation to assertion
4. A5t7o.+;t+o-
!he users are differentiated as per the access permit gi(en to them on the different data of the
database !his is .nown as authori/ation
!he most common authori/ations are
+. R'4 5t7o.+;t+o-
$llows reading but no modification of data
++. I-&'.t 5t7o.+;t+o-
$llows insertion of new data but no modification of e1isting data
+++. U*4t' 5t7o.+;t+o-
$llows modification but not deletion
+2. D'!'t' 5t7o.+;t+o-
$llows deletion of data
!he users may be assigned with all5 none or combination of these types
!he DD' gets some input and generates some output
!his output is placed in data dictionary which contains Meta data
Meta data is data about data
Data Dictionary is a special type of table which can only be accessed and updated by database
system
Database system consults the Data Dictionary before reading or modifying actual data
D t M - +*5 !t+o- L - 3 5 3'
$ 4t9)-+*5!t+o- !-353' <DML= is a language that helps users to access or manipulate data
$ Euery is a statement reEuesting the retrie(al of information
!he portion of DM' that in(ol(es information retrie(al is called as Euery language
!here are basically two types of DM'=
P.o,'45.! DML&
>ser should specify what data are needed and how to get those data
D',!.t+2' DML& (-o-*.o,'45.! DM's)
>ser should specify what data are needed without specifying how to get those data !his is
easier to learn and user than procedural DM'
Data manipulation that can be performed using DM' are
!he retrie(al of information stored in the database
!he insertion of new information into the database
!he deletion of information from the database
!he modification of information stored in the database
=. DATA+ASE S4STEM A(C>!TECT2(E
$ database system is partitioned into modules that deal with each of the responsibilities of the
o(erall system !he functional components of a database system can be broadly di(ided into
%torage Manager
&uery Processor
!he database system architecture is influenced by the underlying computer
architecture !he database system can be centrali/ed or client ser(er
Database systems are partitioned into two or three parts
In t/o t+'. .,7+t',t5.'5 the application is partitioned into a component that resides at the client
machine and in(o.es database functionality at the ser(er machine through Euery language
$pplication program interface standards li.e 0D+- and ,D+- are used for interaction between the
client and the ser(er
T/o t+'. .,7+t',t5.'
In t7.'' t+'. .,7+t',t5.'5 the client machines act as a front end and do not contain any direct database
calls
!he client end communicates with the application ser(ers through interface
!he application ser(er interacts with database system to access data
!he business logic of application says what actions to be carried out under what condition
!hree tier is more appropriate for large applications
T7.'' t+'. .,7+t',t5.'
S to.3' M- 3' .
$ storage manager is a program module that pro(ides the interface between the low le(el data stored in
the database and the application programs and Eueries submitted to the system
!he storage manager is responsible for the interaction with the file manager
!he storage manager translates the (arious DM' statements into low-le(el file system commands !hus5
the storage manager is responsible for storing5 retrie(ing5 and updating data in the database
Co)*o-'-t& o1 t7' &to.3' )-3'. .'"
1. A5t7o.+;t+o- -4 +-t'3.+t( )-3'.= It tests for satisfaction of (arious integrity constraints and
chec.s the authority of users accessing the data
2. T.-&,t+o- )-3'.= It ensures that the database remains in a consistent state despite system
failures5 and concurrent e1ecutions proceed without conflicting
:. F+!' )-3'.= It manages the allocation of space on dis. storage and the data structures used to
represent information stored on dis.
4. B511'. )-3'.= It is responsible for fetching data from dis. storage into main memory and to
decide what data to cache in main memory It enables the database to handle data si/es that are much
larger than the si/e of the main memory !he storage manager implements se(eral data structures as
part of physical system implementation
i Dt 1+!'&= which store the database itself
ii Dt 4+,t+o-.(= It contains metadata that is data about data !he schema of a table is an
e1ample of metadata $ database system consults the data dictionary before reading and
modifying actual data
iii I-4+,'&= :hich pro(ide fast access to data items that hold particular (alues
T 7 ' Q 5 '. ( P . o ,' &&o.
!he Euery processor is an important part of the database system It helps the database system to simplify
and facilitate access to data !he Euery processor components include=
1. DDL +-t'.*.'t'.5 which interprets DD' statements and records the definitions in the data
dictionary
2. DML ,o)*+!'.5 which translates DM' statements in a Euery language into an e(aluation plan
consisting of low-le(el instructions that the Euery e(aluation engine understands
$ Euery can be translates into any number of e(aluations plans that all gi(e the same result
!he DM' compiler also performs Euery optimi/ation5 that is5 it pic.s up the lowest cost
e(aluation plan from among the alternati(es
:. Q5'.( '2!5t+o- '-3+-'5 which e1ecutes low-le(el instructions generated by the DM'
compiler
Dt%&' S(&t') St.5,t5.'"
7. DATA+ASE 2SE(S A)D ADM!)!ST(AT3(
People who wor. with a database can be categori/ed as=
Database >sers
Database administrators
>.1. DATABASE USERS
!here are four types of database users5 differentiated by the way they interact with the system
1. N+2' 5&'.&
*ai(e users interact with the system by in(o.ing one of the application programs that ha(e
been written pre(iously
*ai(e users are typical users of form interface5 where the user can fill in appropriate fields of
the form
*ai(e users may also simply read reports generated from the database
2. A**!+,t+o- P.o3.))'.&
$pplication programmers are computer professionals who write application programs
Rapid application de(elopment (R$D) tools enable the application programmer to construct
forms and reports without writing a program
%pecial types of programming languages that combine control structures with data
manipulation language !hese languages5 sometimes called fourth-generation languages.
:. So*7+&t+,t'4 5&'.&
%ophisticated users interact with the system without writing programs Instead5 they form their
reEuests in a database Euery language
!hey submit each such Euery to a ?5'.( *.o,'&&o. that the storage manager understands
O-!+-' -!(t+,! *.o,'&&+-3 <OLAP= tools simplify analysis and 4t )+-+-3 tools specify
certain .inds of patterns in data
4. S*',+!+;'4 5&'.&
%peciali/ed users are sophisticated users who write speciali/ed database applications that do not
fit into the traditional data-processing framewor.
!he applications are computer-aided design systems5 .nowledge base and e1pert systems5
systems that store data with comple1 data types
>.2. DATABASE ADMINISTRATORS
$ person who has such central control o(er the system is called a 4t%&' 4)+-+&t.to. (DBA)
T7' 15-,t+o-& o1 DBA +-,!54'"
S,7') 4'1+-+t+o- !he D+$ creates the original database schema by e1ecuting a set of data definition
statements in the DD'
Sto.3' &t.5,t5.' -4 ,,'&&9)'t7o4 4'1+-+t+o-
S,7') -4 *7(&+,!9o.3-+;t+o- )o4+1+,t+o- !he D+$ carries out changes to the schema and
physical organi/ation to reflect the changing needs of the organi/ation
G.-t+-3 o1 5t7o.+;t+o- 1o. 4t ,,'&& +y granting different types of authori/ation5 the database
administrator can regulate which parts of the database (arious users can access
$uthori/ation information is .ept in a special system structure that the database system consults whene(er
someone attempts to access the data in the system
Ro5t+-' )+-t'--,'. E?amp'es o- the database administ"ato"5s "o#tine maintenance acti*ities a"e@
4 periodically bac.ing up the database
7 Ensuring that enough free dis. space
< Monitoring Dobs running on the database and ensuring that performance is not degraded by (ery
e1pensi(e tas.s submitted by some users
C Ensuring that performance is not degraded by (ery e1pensi(e tas.s submitted by some users
$. E)T!T4 (E;AT!3)S>!% M3DE; AE( M3DE;B
!he E-R data model considers the real world consisting of a set of basic obDects5 called entities5 and
relationships among these obDects
!he E-R data model employs three basic notions=
4 Entity sets
7 Relationship sets
< $ttributes
1. E-t+t( S't&
$n entity is Cthin05 o" CobDect in the real world that is distinguishable from all other
obDects #or e1ample5 each person is an entity
$n entity has a set of properties5 and the (alues for some set of properties may uniEuely identify an
entity
#or e1ample5 a customer with customer-id property with (alue -484 uniEuely identifies that person
$n entity may be concrete5 such as person or a boo.5 or it may be abstract5 such as a loan5 or a
holiday
$n entity set is a set of entities of the same type that share the same properties5 or attributes
#or e1ample all persons who are customers at a gi(en ban. can be defined as entity set customer
!he properties that describe an entity are called tt.+%5t'&
2. R'!t+o-&7+*& -4 R'!t+o-&7+*& &'t&
R'!t+o-&7+* is an association among se(eral entities
R'!t+o-&7+* &'t is a set of relationships of the same type
!he association between entity set is referred to as *.t+,+*t+o-. !hat is5 the entity sets E4, E7, . .
.,En *.t+,+*t' in relationship set R
R',5.&+2' .'!t+o-&7+* &'t" %ame entity set participating in a relationship more than once in a
different role is called Recursi(e relationship set
!he attributes of entities in Recursi(e relationship set is called 4'&,.+*t+2' tt.+%5t'&
T(*'& o1 .'!t+o-&7+*&
+= U-.( .'!t+o-&7+*" $ unary relationship e1ists when an association is maintained within a single entity
Manager
+oss Emp%&yee
:or.er
#igure$ssociation between two obDects of the same entity set
++= B+-.( .'!t+o-&7+*" $ binary relationship e1ists when two entities are associated
P#%is
her
P#%ish
es
B&&'
+++= T'.-.( .'!t+o-&7+*" $ ternary relationship e1ists when there are three entities associated
Tea"her Tea"h
es
S#(e"t
St#de
)t
+2= Q5t'.-.( .'!t+o-&7+*" $ Euaternary relationship e1ists when there are four entities associated
Tea"h
er
St#de)t
St#di
es
C&#rse materia%
S#(e
"t
!he number of entity set participating in a relationship is called 4'3.'' o1 t7' .'!t+o-&7+* &'t.
+inary relationship set is of degree 7H a tertiary relationship set is of degree <
E-t+t( .o!'" !he function that an entity p'ays in a "e'ationship is ca''ed that entity5s "o'e. A "o'e is one
end
of an association
Pers
&)
*&r'
s+
f&
r
Employee Employee
C&mpa)y
2ere Entity role is Employee
:. Att.+%5t'&
!he properties that describes an entity is called attributes
!he attributes of customer entity set are customerIid5 customerIname and city
Each attributes has a set of permitted (alues called the domain or (alue set
Each entity will ha(e (alue for its attributes
E1ample=
-ustomer *ame ,ohn
-ustomer Id <74
Att.+%5t'& .' ,!&&+1+'4 &
%imple
-omposite
%ingle- (alued
M
u
l
t
i
-
(
a
l
u
e
d
D
e
r
i
(
e
d
1= S+)*!' tt.+%5t'"
!his type of attributes cannot be di(ided into sub parts
E6)*!'" $ge5 se15 6P$
2= Co)*o&+t' tt.+%5t'"
!his type of attributes -an be subdi(ided
E6)*!'" $ddress= street5 city5 state5 /ip
:= S+-3!'92!5'4 tt.+%5t'"
!his type of attributes can ha(e only a single (alue
E6)*!'" %ocial security number
4= M5!t+92!5'4 tt.+%5t'"
Multi-(alued attribute -an ha(e many (alues
E6)*!'" Person may ha(e se(eral college degrees5 phone numbers
5= D'.+2'4 tt.+%5t'"
Deri(ed attribute -an be calculated or deri(ed from other related attributes or entities
E6)*!'" $ge can be deri(ed from D0+
@= Sto.'4 tt.+%5t'&=
!he attributes stored in a data base are called stored attributes
$n attribute ta.es a null (alue when an entity does not ha(e a (alue for it
*ull (alues indicate the (alue for the particular attribute does not e1ists or un.nown
Eg = 4 Middle name may not be present for a person (non e1istence case)
7 $partment number may be missing or un.nown
CONSTRAINTS
$n E-R enterprise schema may define certain constraints to which the contents of a database system
must conform
!hree types of constraints are
4 Mapping cardinalities
7 "ey constraints
< Participation constraints
1. M**+-3 ,.4+-!+t+'&
Mapping cardinalities e1press the number of entities to which another entity can be associated (ia
a relationship set
-ardinality in E-R diagram that is represented by two ways=
i) Directed line ( ) ii) >ndirected line ( )
!here are C categories of cardinality
+= O-' to o-'" $n entity in $ is associated with at most one entity in +5 and an entity in + is associated
with at most one entity in $
E,amp%e- A c#stome" ith sin0'e acco#nt at 0i*en b"anch is shon
by oneEtoEone "e'ationship as 0i*en be'o
C#st&m
er
Dep&sit
&r
A""&#)t
++= O-'9to9)-(" $n entity in $ is associated with any number of entities (/ero or more) in + $n
entity in +5 howe(er5 can be associated with at most one entity in $
E,amp%e- A c#stome" ha*in0 to acco#nts at a 0i*en b"anch is shon
by oneEtoEmany "e'ationship as 0i*en be'o.
C#stome"
Deposito"
Acco#nt
+++= M-(9to9o-'" $n entity in $ is associated with at most one entity in + $n entity in +5 howe(er5 can
be associated with any number (/ero or more) of entities in $
E6)*!'" Many employees wor.s for a company !his relationship is shown by many-to-one as gi(en
below
Emp'oyees :o"/sE-o"
Company
+2= M-(9to9)-(" $n entity in $ is associated with any number (/ero or more) of entities in +5 and an
entity in + is associated with any number (/ero or more) of entities in $
E6)*!'" Employee wor.s on number of proDects and proDect is handled by number of employees
!herefore5 the relationship between employee and proDect is many-to-many as shown below
Emp'oyee
:o"/sE
%"oDect
on
2. $'(&
$ .ey allows us to identify a set of attributes and thus distinguishes entities from each other
"eys also help uniEuely identify relationships5 and thus distinguish relationships from each other
$'( T(*' D'1+-+t+o-
S5*'.0'(
$ny attribute or combination of attributes that uniEuely identifies a row in the table
E6)*!'" (o''F)o att"ib#te o- the entity set Cst#dent5 distin0#ishes one st#dent
entity
from another -ustomerIname5 -ustomerIid together is a %uper .ey
C-4+t' $'(
Minimal %uper.ey $ super.ey that does not contain a subset of attributes that is itself a
super.ey
E6)*!'" %tudentIname and %tudentIstreet5are sufficient to uniEuely identify one
particular student
P.+).( $'(
!he candidate .ey selected to uniEuely identify all rows It should be rarely changed and
cannot contain null (alues
E6)*!'" (o''F)o is a p"ima"y set o- Cst#dent5 entity set.
Fo.'+3- $'(
$n attribute (or combination of attributes) in one table that must either match the primary
.ey of another table or be null
E6)*!'" -onsider in the staff relation the branchIno attribute e1ists to match staff to the
branch office they wor. in In the staff relation5 branchIno is foreign .ey
S',o-4.( $'( $n attribute or combination of attributes used to ma.e data retrie(al more efficient
:. P.t+,+*t+o- Co-&t.+-t
Participation can be di(ided into two types.
4 !otal 7 Partial
If e(ery entity in the entity set E participates in at least one relationship in R !hen participation is
called !otal Participation
If only some entities in the entity set E participate in relationships in R !hen the participation is
called Partial Participation
G. E)T!T4E(E;AT!3)S>!%AEE(B D!A<(AMS
E9R 4+3.) can e1press the o(erall logical structure of a database graphically
E9R 4+3.) consists of the following maDor components=
Component name Symbol Description
R',t-3!'& represent entity sets
E!!+*&'& represent attributes
D+)o-4& represent relationship sets
L+-'&
lin. attributes to entity sets and entity sets to
relationship sets
Do5%!' '!!+*&'& represent multi(alued attributes
D&7'4 '!!+*&'& represent deri(ed attributes
Do5%!' !+-'&
Represent total participation of an entity in a
relationship set
Do5%!' .',t-3!'& represent wea. entity sets
E9R 4+3.) /+t7 ,o)*o&+t'A )5!t+2!5'4A -4 4'.+2'4 tt.+%5t'&.
Do5%!' !+-'& are used in an E-R diagram to indicate that the participation of an entity set in a
relationship set is totalH that is5 each entity in the entity set occurs in at least one relationship in that
relationship set
!he number of time an entity participates in a relationship can be specified using comple1
,.4+-!+t+'&.
$n edge between an entity set and binary relationship set can ha(e an associated minimum and
ma1imum cardinality assigned in the form of lh
l 9 Minimum cardinality
h 9 Ma1imum cardinality
$ minimum (alue of 4 indicates total participation of the entity set in the relationship set
$ ma1imum (alue of 4 indicates that the entity participates in at most one relationship
$ ma1imum (alue J indicates no limit
$ label 4... on an edge is eEui(alent to a double line
St.o-3 -4 B'0 '-t+t( &'t&
8J indicates a customer can ha(e 8 or more loan
44 indicates a loan must ha(e one associated customer
$n entity set may not ha(e sufficient attributes to form a primary .ey %uch an entity set is termed a
/'0 '-t+t( &'t
$n entity set that has a primary .ey is termed a &t.o-3 '-t+t( &'t
:ea. entity set is associated with another entity set called the +4'-t+1(+-3 or o/-'. '-t+t( &'t ie5
wea. entity set is said to be e1istence dependent on the identifying entity set
Identifying entity set is said to own the wea. entity set
!he relationship among the wea. and identifying entity set is called the +4'-t+1(+-3 .'!t+o-&7+*
Discriminator in a wea. entity set is a set of attributes that distinguishes the different entities among
the wea. entity also called as partial .ey
E6t'-4'4 E9R F't5.'&
ER model that is supported with the additional semantic concepts is called the e1tended entity
relationship model or EER model
EER model deals with
4 %peciali/ation
7 6enerali/ation
< $ggregation
1. S*',+!+;t+o-"
!he process of designating subgroupings within an entity set is called S*',+!+;t+o-
S*',+!+;t+o- is a top-down process
-onsider an entity set person. $ person may be further classified as one of the following=
Customer
Employee
$ll person has a set of attributes in common with some additional attributes
%peciali/ation is depicted by a triangle component labeled ISA
The 'abe' !SA stands -o" is a -o" e?amp'e, that a c#stome" is a pe"son.
!he I%$ relationship may also be referred to as a &5*'. ,!&&9&5%,!&& relationship
2. G'-'.!+;t+o-"
6enerali/ation is a simple in(ersion of speciali/ation
6enerali/ation is the process of defining a more general entity type from a set of more speciali/ed
entity types
G'-'.!+;t+o- is a bottom-up approach
6enerali/ation results in the identification of a generali/ed super class from the original subclasses
Person is the higher-le(el entity set
Customer and employee are lower-le(el entity sets
!he person entity set is the superclass of the customer and employee subclasses
Att.+%5t' I-7'.+t-,'
$ property of the higher- and lower-le(el entities created by speciali/ation and generali/ation is
tt.+%5t' +-7'.+t-,'
!he attributes of the higher-le(el entity sets are said to be +-7'.+t'4 by the lower-le(el entity
sets
#or e1ample5 customer and employee inherit the attributes of person
!he outcome of attribute inheritance is
4 $ higher-le(el entity set with attributes and relationships that apply to all of its lower-le(el
entity sets
7 'ower-le(el entity sets with distincti(e features that apply only within a particular lower-
le(el entity set
If an entity set is in(ol(ed as a lower-le(el entity set in only one I%$ relationship5 then the entity
set has &+-3!' +-7'.+t-,'
If an entity set is in(ol(ed as a lower-le(el entity set in more than one I%$ relationship5 then the
entity set has )5!t+*!' +-7'.+t-,' and the resulting structure is said to be a lattice
Co-&t.+-t& o- G'-'.!+;t+o-&
4 0ne type of constraint determining which entities can be members of a lower-le(el entity set %uch
membership may be one of the following=
Co-4+t+o-94'1+-'4 In condition-defined the members of lower-le(el entity set is e(aluated on
the basis of whether or not an entity satisfies an e1plicit condition
U&'.94'1+-'4 >ser defined constraints are defined by user
7 $ second type of constraint relates to whether or not entities may belong to more than one lower-
le(el entity set within a single generali/ation !he lower-le(el entity sets may be one of the
following=
D+&8o+-t $ disjointness constraint reEuires that an entity belong to no more than one lower-
le(el entity set
O2'.!**+-3 %ame entity may belong to more than one lower-le(el entity set within a single
generali/ation
< $ final constraint5 the ,o)*!'t'-'&& ,o-&t.+-t specifies whether or not an entity in the higher-le(el
entity set must belong to at least one of the lower-le(el entity sets !his constraint may be one of the
following=
Tot! 3'-'.!+;t+o- or &*',+!+;t+o- Each higher-le(el entity must belong to a lower-le(el
entity set It is represented by double line
P.t+! 3'-'.!+;t+o- or &*',+!+;t+o- %ome higher-le(el entities may not belong to any
lower-le(el entity set
:. A33.'3t+o-
0ne limitation of the E-R model is that it cannot e1press relationships among relationships
-onsider the ternary relationship wors-on5 between a employee5 !ranch5 and jo! *ow5 suppose
we want to record managers for tas.s performed by an employee at a branch !here another
entity set manager is created
!he best way to model such a situation is to use aggregation
A33.'3t+o- is an abstraction through which relationships are treated as higherle(el entities
In our e1ample wor.s-on act as high le(el entity
E-R diagram with redundant relationships E-R diagram with aggregation
S5)).( o1 ER 4+3.)
$ccount number +alance
$-484
$-74B
$-487
B88
;88
C88
&6. !)T(3D2CT!3) T3 (E;AT!3)A;DATA+ASES
$ relational database is based on the relational model and uses a collection of tables to represent
both data and the relationship among those data
It includes DM' and DD' languages
T%!'&=
Each table has multiple columns and each column has uniEue name
$ relational model is an e1ample of a record based model
Record based model are structured in fi1ed format record of se(eral types
Each table contains record of particular type Each record type defines a fi1ed number of fields or
attributes
!he columns of the table correspond to the attribute of record type
Dt M-+*5!t+o- L-353' <DML=
DM' includes following commands
4 I*%ER! !o insert one or more number of Rows
7 %E'E-! !o display one or more rows
< >PD$!E >sed to alter the column (alues in a table
C DE'E!E >sed to delete one or more rows
Dt D'1+-+t+o- L-353' <DDL=
DD; includes following
commands
4 -RE$!E
-ommand used for creating tables
7 DE%-
-ommand used to (iew the table structure
< $'!ER
-ommand used for modifying table structure
C RE*$ME
used to change the name of the table
B DR0P
-ommand used for remo(ing an e1isting table
2 M.0 Q5 '&t+o- &
4 Define data5 database5 database management system5 database systemK
7 'ist any eight applications of D+M%
< :hat are the disad(antages of .eeping organi/ation information in a file processing systemK
C :hat are the ad(antages of using a D+M% (-entrali/ed control of data)K
B :ith the bloc. diagram5 discuss briefly the (arious le(els of data abstractionK
9 Define instance and schemaK
; Define the terms 4) physical schema 7) logical schema <)%ubschema
F :hat is conceptual schemaK
L Define data modelK
48 :hat is storage managerK
44 :hat are the components of storage managerK
47 :hat is the purpose of storage managerK
4< 'ist the data structures implemented by the storage manager
4C :hat is a data dictionaryK
4B :hat is an entity relationship modelK
49 :hat are attributesK 6i(e e1amples
4; :hat are the types of $ttributesK
4F :hat is relationshipK 6i(e e1amples
4L Define the terms
78 Define null (alues
74 Define the terms
77 :hat is meant by the degree of relationship setK
7< Define the terms
7C Define wea. and strong entity setsK
7B :hat does the cardinality ratio specifyK
79 E1plain the two types of participation constraint
7; Define the terms
7F :rite short notes on relational model
7L Define the term Domain
<8 %pecify with suitable e1amples5 the different types of .eys used in database management systems
<4 Define Data model
1@ M.0 Q5 '&t+o- &
1 E1plain D+M% %ystem $rchitecture
7 E1plain E-R Model in detail with suitable e1ample
< E1plain about (arious data models
C Draw an E R Diagram for +an.ing5 >ni(ersity5 -ompany5 $irlines5 $!M5 2ospital5 'ibrary5 %uper
mar.et5 Insurance -ompany
B E1plain in details about the (arious database languages
9 Discuss about (arious operations in Relational Databases
; Discuss about database users and administrators
2)!T !! (E;AT!3)A;
M3DE;
!he relational Model !he catalog- !ypes "eys - Relational $lgebra Domain Relational -alculus
!uple Relational -alculus - #undamental operations $dditional 0perations- %&' fundamentals -
Integrity !riggers - %ecurity $d(anced %&' features Embedded %&' Dynamic %&'- Missing
Information Views Introduction to Distributed Databases and -lient)%er(er Databases
&. T>E (E;AT!3)A; M3DE;
STRUCTURE OF RELATIONAL DATABASES"
$ relational database consists of a collection of t%!'&5 each of which is assigned a uniEue name
$ row in a table represents a relationship among a set of (alues
BASIC STRUCTURE
Each column header is attributes Each attribute allows a set of permitted (alues called domain of
that attribute
$ table of n-attributes must be a subset of
D1 D2 Dn.1
Dn
$ relation is a cartesian product of list of domains
Mathematically table is called as a .'!t+o- and rows in a table are called as t5*!'&.
!he tuples in a relation can be either &o.t'4 o. 5-&o.t'4
%e(eral attributes can ha(e &)' 4o)+- E.3." customerIname5 employeeIname
$ttributes can also be 4+&t+-,t. E.3." balance5 branchIname
$ttributes can ha(e null (alues incase if the (alue is 5-0-o/- o. 4o'& -ot '6+&t.
Database schema begins with upper case and database relation begins with lower case
$ccount-schema M (account-number5 branch-name5 balance)
account ($ccount-schema)
A,,o5-t T%!'
2. T>E CATA;3<
!he catalog is a place where all the schemas and the corresponding mappings are .ept
!he catalog contains detailed information also called as descriptor information or meta data
Descriptor information is essential for the system to perform its Dob properly
#or e1ample the authori/ation subsystem uses catalog information about users and security
constraints to grant or deny access to a particular user
!he catalog should be self describing
1. (E;AT!3)A; A;<E+(A
!he relational algebra is a procedural Euery language
It consists of a set of operations that ta.e one or two relations as input and produce a new relation as
their result
Fo.)! D'1+-+t+o-
$ basic e1pression in the relational algebra consists of either one of the following=
$ relation in the database
$ constant relation
'et E
"
and E
#
be relational-algebra e1pressionsH the following are all relational-algebra
e1pressions= E
4
E
7
E
4
E
7
E
4
1 E
7
p
(E
4
)5 P is a predicate on attributes in E
4
s
(E
4
)5 % is a list consisting of some of the attributes in E
4
1
(E
4
)5 1 is the new name for the result of E
4
O*'.t+o-& ,- %' 4+2+4'4 +-to
B&+, o*'.t+o-& o. F5-4)'-t! O*'.t+o-& 9%elect5 ProDect5 >nion5 rename5 set difference @
-artesian product
A44+t+o-! o*'.t+o-& that can be e1pressed in terms of basic operations-%et intersection5 *atural
Doin Di(ision and $ssignment
E6t'-4'4 o*'.t+o-&96enerali/ed proDection5 $ggregate operations and 0uter Doin
:.1. +AS!C 3%E(AT!3)S 3( ,2)DAME)TA; 3%E(AT!3)S
!he select5 proDect5 and rename operations are called unary o*'.t+o-&5 because they operate on one
relation
!he other three operations (union5 set difference5 cartesian product) operate on pairs of relations and
are5 therefore5 called binary o*'.t+o-&
!he basic or fundamental operations are as follows
4 %elect
7 ProDect
< >nion
C Rename
B %et difference
9 -artesian product
1. S'!',t O*'.t+o- <C=
!e select operation selects tuples that satisfy a gi(en predicate
S(-t6
C
D&'!',t ,o-4+t+o-E
<R=
Symbo' H is #sed to denote the se'ect ope"ato"
Predicate appears as a subscript to H and argument relation in paranthesis
E6)*!'
Co-&+4'. t7' !o- .'!t+o-
.#ery- H
branch-name I%e""y"id0e
(loan)
0utput relation is
%elect operation allows all comparisons using M5 IM5 N5 5 O5
It allows combination of ser(er predicates using connecti(es li.e and (J)5 or (K)5 and not (
)
Eg= 4 H
amountO4788
(loan)
7 H
branch-name I%e""y"id0e
J
amountO4788
(loan)
Ot7'. E6)*!'&
-onsider following +oo. relation
Boo0FI4 T+t!' A5t7o. P5%!+&7'. Y'. P.+,'
+884 D+M% "orth Mc6rawI2ill 7888 7B8
+887 -ompiler >lman 788C <B8
+88< 00MD Rambaugh 788< CB8
+88C PP' %abista 7888 B88
Fo!!o/+-3 .' t7' &o)' '6)*!'& o1 t7' &'!',t o*'.t+o-.
E6)*!' 1" Display boo.s published in the 7888
L#e"y &@ H
yearM7888
(+oo.)
!he output of Euery 4 is shown below
Boo0FI4 T+t!' A5t7o. P5%!+&7'. Y'. P.+,'
+884 D+M% "orth Mc6rawI2ill 7888 7B8
+88C PP' %abista 7888 B88
E6)*!' 2" Display all boo.s ha(ing price greater than <88
L#e"y 2@ H
priceO<88
(+oo.)
!he output of Euery 7 is shown below
Boo0FI4 T+t!' A5t7o. P5%!+&7'. Y'. P.+,'
+887 -ompiler >lman 788C <B8
+88< 00MD Rambaugh 788< CB8
+88C PP' %abista 7888 B88
E6)*!' :" %elect the tuples for all boo.s whose publishing year is 7888 or price is greater than <88
L#e"y 1@ H
(yearM7888) 0R (priceO<88)
(+oo.)
!he output of Euery < is shown
below
Boo0FI4 T+t!' A5t7o. P5%!+&7'. Y'. P.+,'
+884 D+M% "orth Mc6rawI2ill 7888 7B8
+887 -ompiler >lman 788C <B8
+88< 00MD Rambaugh 788< CB8
+88C PP' %abista 7888 B88
E6)*!' 4" %elect the tuples for all boo.s whose publishing year is 7888 and price is greater than <88
L#e"y 1@ H
(yearM7888) $*D (priceO<88)
(+oo.)
!he output of Euery C is shown below
Boo0FI4 T+t!' A5t7o. P5%!+&7'. Y'. P.+,'
+88C PP' %abista 7888 B88
2. P.o8',t o*'.t+o- <G=
!he proDect operation selects certain columns from a table while discarding others It remo(es any
duplicate tuples from the result relation
S(-t6
G
Dtt.+%5t'!+&tE
< R =
The symbo' M ApiB is #sed to denote the p"oDect ope"ation
$ttribute list to be proDected is specified as subscript of M and R denotes the relation
E.3." M
loan-number5 amount
(loan)
E6)*!'" !he following are the e1amples of proDect operation on +oo. relation
E6)*!' 1" Display all titles with author name
L#e"y &@ M
!itle5 $uthor
(+oo.)
!he output of Euery 4 is shown below
T+t!' A5t7o.
D+M% "orth
-ompiler >lman
00MD Rambaugh
PP' %abista
E6)*!' 2" Display all boo. titles with authors and price
L#e"y 2@ M
!itle5 $uthor5 Price
(
+oo. )
!he output of Euery 7 is shown
below
T+t!' A5t7o. P.+,'
D+M% "orth 7B8
-ompiler >lman <B8
00MD Rambaugh CB8
PP' %abista B88
Co)*o&+t+o- o1 &'!',t -4 *.o8',t o*'.t+o-&
!he relational operations select and proDect can be combined to form a complicated Euery
M
customer-name
AH
customer-city I>a""ison
(customer))
Input !able=
customer
0utput=
-ustomer-name
2ayes
E6)*!'" Display the titles of boo.s ha(ing price greater than <88
L#e"y@ M
!itle5(
H
priceO<88
(+oo.))
!he output of Euery 4 is shown below
T+t!'
-ompiler
00MD
PP'
:. R'-)' o*'.t+o- <H=
In relational algebra5 you can rename either the relation or the attributes or both !he general rename
operation can ta.e any of the following forms=
S(-t6
H
&<-'/ tt.+%5t' -)'&=
< R = renames both the relation and its attributes
H
&
< R = renames only the relation
H
<-'/ tt.+%5t' -)'&=
< R =renames only the attribute name
The symbo' CN5 A"hoB is #sed to denote the (E)AME ope"ato".
CS5 is the ne "e'ation
C(5 is o"i0ina' "e'ation.
E6)*!' 1" Renames both the relation and its attributes5 the second renames the relation only and the third
renames as follows
JN
!emp(+name5 $name5 Pyear5 +price)
( +oo. )
E6)*!' 2" 0nly the relation name is renamed
JN
!emp
(+oo.)
E6)*!' :" 0nly the attribute names are renamed
JN
(+name5 $name5 Pyear5 +price)
( +oo. )
4. U-+o- o*'.t+o- <U=
#or union operation (r > s) to be (alid two condition should be satisfied
4 Relation r and s should ha(e the same number of attributes
7 !he domain (alue of i
th
attribute of r and i
th
attribute of s must be the same for all i
S(-t6" Relation4 > Relation 7
E6)*!'" -onsider the two relations=
!o find the names of all customers with a loan in the ban.=
Mcustomer-name (!orrower$
!o find the names of all customers with an account in the ban.=
Mcustomer-name (depositor)
U-+o- of these two setsH that is5 !o find customer names that appear in either or both of the two relations
Mcustomer-name (!orrower$ % &customer-name (depositor)
!he result relation for this Euery=
5. S't D+11'.'-,' O*'.t+o- <9=
!o find tuples that is in one relation but is not in another !he two condition of union operation aso
apply for set difference
S(-t6" Relation4 9 Relation 7
E6)*!'" find all customers of the ban. who ha(e an account but not a loan
Mcustomer-name (depositor) ' Mcustomer-name (!orrower$
!he result relation for this Euery
@. C.t'&+-9P.o45,t O*'.t+o-<#=
-artesian product is also .nown as -R0%% PR0D>-! or -R0%% ,0I*%
-artesian product allows us to combine information from any 7 relation
S(-t6" Relation4 6 Relation 7
E6)*!'" -onsider following two relations publisherIinfo and +oo.Iinfo
P5%!+&7'.FI-1o
P5%!+&7'.F,o4' N)'
P8884 Mc6rawI2ill
P8887 P2I
P888< Pearson
Boo0FI-1o
Boo0FID T+t!'
+8884 D+M%
+8887 -ompiler
!he -artesian product of PublisherIInfo and +oo.IInfo is gi(en in fig
P5%!+&7'.FI-1o # Boo0FI-1o
P5%!+&7'.F,o4' N)' Boo0FID T+t!'
P8884 Mc6rawI2ill +8884 D+M%
P8887 P2I +8884 D+M%
P888< Pearson +8884 D+M%
P8884 Mc6rawI2ill +8887 -ompiler
P8887 P2I +8887 -ompiler
P888< Pearson +8887 -ompiler
4 %et intersection
7 *atural Doin
< Di(ision
C $ssignment
1. S't +-t'.&',t+o- O*'.t+o- < )
:.2. ADD!T!3)A; 3%E(AT!3)S
!he result of intersection operation is a relation that includes all tuples that are in both Relation4 and
Relation7
!he intersection operation is denoted by depositor borrower
S(-t6" Relation4 Relation 7
E6)*!'"
M
customer-name
(!orrower$ M
customer-name
(depositor)
!he result relation for this Euery=
2. Nt5.! 8o+- < =
%alary
EmpIcode %alary
E8884
E8887
E888<
E888C
7888
B888
;888
48888
!he natural Doin operation performs a selection on those attributes that appear in both relation
schemes and finally remo(es duplicate attributes
S(-t6" Relation4 Relation 7
E6)*!'" consider the 7 relations
Employee
EmpIcode EmpIname
E8884
E8887
E888<
E888C
2ari
0m
%mith
,ay
Q5'.("M
empIname5 salary
(employee salary)
!he output of Euery is=
EmpIname %alary
2ari
0m
%mith
,ay
7888
B888
;888
48888
:. D+2+&+o- o*'.t+o- <I=
Di*ision 3pe"ation is s#ited to O#e"ies that inc'#de the ph"ase C-o" a''5.
S(-t6" Relation4 I Relation 7
E6)*!'" -onsider three relations=
A,,o5-t R'!t+o- B.-,7 R'!t+o-
D'*o&+to. R'!t+o-
%uppose that we wish to find all customers who ha(e an account at all the branches located in +roo.lyn
St'* 1" :e can obtain all branches in +roo.lyn by the e1pression
r4 M M
!ranch-name
()
!ranch-city I+"oo/'yn
(!ranch))
!he result relation for this e1pression is shown in figure
St'* 2" :e can find all (customer-name, !ranch-name) pairs for which the customer has an account at a
branch by writing
r7 M M
customer-name, !ranch-name
(depositor account)
#igure shows the result relation for this e1pression
*ow5 we need to find customers who appear in r7 with every branch name in r4 !he operation that
pro(ides e1actly those customers is the di(ide operation
!hus5 the Euery is
M
customer-name, !ranch-name
(depositor account)
* M
!ranch-name
()
!ranch-city I+"oo/'yn
(!ranch))
!he result of this e1pression is a relation that has the schema (customer-name) and that contains the tuple
(,ohnson)
4. T7' A&&+3-)'-t O*'.t+o- < =
!he &&+3-)'-t operation wor.s li.e assignment in a programming language
E6)*!'"
Result of the e1pression to the right of the + is assigned to the relation (ariable on the left of the+
:ith the assignment operation5 a Euery can be written as a seEuential program consisting of a series
of assignments followed by an e1pression whose (alue is displayed as the result of the Euery
:.:. EPTE)DED (E;AT!3)A;EA;<E+(A 3%E(AT!3)S
4 6enerali/ed proDection
7 $ggregate operations
< 0uter Doin
1. G'-'.!+;'4 *.o8',t+o-
!he 3'-'.!+;'49*.o8',t+o- operation e1tends the proDection operation by allowing arithmetic
functions to be used in the proDection list
!he generali/ed proDection operation has the form
M,4, ,#,..., ,n(E)
:here E is any relational-algebra e1pression5 and each of ,4, ,7, . . . , ,n is an arithmetic
e1pression in(ol(ing constants and attributes in the schema of E
E6)*!'" %uppose we ha(e a relation credit-info5 as in #igure
Q5'.(" M
customer-name, (limit ' credit-!alance) & credit-availa!le
(credit-info)
R'&5!t of this Euery=
2. A33.'3t' F5-,t+o-&
A33.'3t' 15-,t+o-& ta.e a collection of (alues and return a single (alue as a result #ew $ggregate
#unction are5
4 $(g
7 Min
< Ma1
C %um
B -ount
1. A23" !he aggregate function 23 returns the a(erage of the (alues
E6)*!'" >se the pt-wors relation in #igure
%uppose that we want to find out the a(erage of salaries
G
avg (salary)(pt-wors)
!he symbol - is the 'ette" < in ca''i0"aphic -ontQ "ead it as ca''i0"aphic <.
R'&5!t"
S!.(
7897B
2. M+- -4 M6
M+-" Return the minimum (alues in a collection
M6" Return the Ma1imum (alues in a collection
E6)*!'"
!ranch-name
-
&5) (salary) & sum-salary
,
)6 (salary) & ma.-salary
(pt-wors)
R'&5!t"
!he attribute !ranch-name in the left-hand subscript of - indicates that the input relation pt-
wors must be di(ided into groups based on the (alue of !ranch-name
!he calculated sum is placed under the attribute name sum-salary and the ma1imum salary is
placed under the attribute ma1-salary
:. S5)"
!he aggregate function sum returns the total of the (alues
E6)*!'" %uppose that we want to find out the total sum of salaries
-
&5)(salary)(pt-wors)
!he symbol - is the 'ette" < in ca''i0"aphic -ontQ "ead it as ca''i0"aphic <.
R'&5!t"
S!.(
49B88
4. Co5-t"
Returns the number of the elements in the collection5
E6)*!'" -
,o5-t-4+&t+-,t(!ranch-name)
(pt-wors)
R'&5!t" /he result of this Euery is a single row containing the (alue <
:. O5t'. 8o+-
,oins are classified into three types namely=
4 Inner ,oin
7 0uter ,oin
< *atural ,oint
I--'. Jo+- < =
Inner ,oin returns the matching rows from the tables that are being Dointed
E1ample= -onsider the two relations
E6)*!'"
R'&5!t"
O5t'. Jo+-
!he o5t'.98o+- operation is an e1tension of the Doin operation to deal with missing information
0uter-join operations a(oid loss of information
0uter ,oins are classified into three types namely=
4 'eft 0uter ,oin
7 Right 0uter ,oin
< #ull 0uter ,oin
1. L'1t O5t'. Jo+- < =
!he !'1t o5t'. 8o+- ( ) ta.es all tuples in the left relation that did not match with any tuple in the
right relation5 pads the tuples with null (alues for all other attributes from the right relation5 and adds them
to the result of the natural Doin
E6)*!'"
R'&5!t"
2. R+37t O5t'. Jo+- < =
!he .+37t o5t'. 8o+- ( ) is symmetric with the left outer Doin= It pads tuples from the right relation
that did not match any from the left relation with nulls and adds them to the result of the natural Doin
E6)*!'"
R'&5!t"
:. F5!! O5t'. Jo+- < =
!he 15!! o5t'. 8o+-( ) does both of those operations5 padding tuples from the left relation that did
not match any from the right relation5 as well as tuples from the right relation that did not match any from
the left relation5 and adding them to the result of the Doin
E6)*!'"
R'&5!t"
.. (E;AT!3)A; CA;C2;2S
Relational -alculus is a formal Euery language where we can write one declarati(e e1pression to
specify a retrie(al reEuest and hence there is no description of how to retrie(e it
$ calculus e1pression specifies what is to be retrie(ed rather than how to retrie(e it
Relational -alculus is considered to be non procedural language
Relational -alculus can be di(ided into
4 !uple Relational -alculus
7 Domain Relational -alculus
/.0. T2%;E (E;AT!3)A; CA;C2;2S
!uple Relational -alculus is a nonprocedural Euery language
$ Euery in the !uple Relational -alculus is e1pressed as follows
Pt Q P (t ) R
It is the set of all tuples t such that predicate P is true for t
t r denotes that tuple t is in relation r
P is a formula similar to that of the predicate calculus
$ tuple (ariable is said to be a free varia!le unless it is Euantied by a or
t R loan J S s R customer(tSbranch-nameT M sSbranch-nameT)
t is a free (ariable !uple (ariable s is said to be a !ound (ariable
$ tuple-relational-calculus formula is built up out of atoms $n atom has one of the
following forms=
4 s r5 where s is a tuple (ariable and r is a relation
7 sS.T
uSyT5 where s and u are tuple (ariables5 . is an attribute on which s is defined5 y is
an attribute on which u is defined5 and is a comparison operator
< sS.T c5 where s is a tuple (ariable5 . is an attribute on which s is defined5 is a
comparison operator5 and c is a constant in the domain of attribute .
R5!'& to %5+!t 1o.)5!& 1.o) to)&
$n atom is a formula
If P4 is a formula5 then so are P4 and (P4)
If P4 and P7 are formulae5 then so are P4 K P75 P4 J P75 and P4 T P7
If P4(s) is a formula containing a free tuple (ariable s5 and r is a relation5 then
S s R r (P4(s)) and U s R r (P4(s)) are also
formulae
E?5+2!'-,' .'!t+o- +- T5*!' .'!t+o-! ,!,5!5&
P4 J P7 is eEui(alent to ( (P4) K
(P7))
U t R r (P4(t)) is eEui(alent to
t R r (P4(t))
P4 T P7 is eEui(alent to (P4) K P7
B-0+-3 E6)*!'
4 !ranch (!ranch1name, !ranch1city, assets )
7 customer (customer1name, customer1street, customer1city )
< account (account1num!er, !ranch1name, !alance )
C loan (loan1num!er, !ranch1name, amount )
B depositor (customer1name, account1num!er )
9 !orrower (customer1name, loan1num!er )
E6)*!' Q5'.+'&
4 #ind the loan1num!er, !ranch1name, and amount for loans of o(er A4788
Pt Q t loan t Samount T 4788R
7 #ind the loan number for each loan of an amount greater than A4788
Pt Q s loan (t Sloan1num!er T M s Sloan1num!er T s Samount T 4788)R
*otice that a relation on schema Sloan1num!er2 is implicitly defined by the Euery
< #in
d the names of all customers ha(ing a loan5 an account5 or both at the ban.
Pt Q s !orrower ( t Scustomer1name T M s Scustomer1name T) u depositor ( t Scustomer1name
T M u Scustomer1name T)
C #ind the names of all customers who ha(e a loan and an account at the ban.
Pt Q s !orrower ( t Scustomer1name T M s Scustomer1name T) u depositor ( t Scustomer1name
T M u Scustomer1nameT )
B #ind the names of all customers ha(ing a loan at the Perryridge branch
Pt Q s !orrower (t Scustomer1name T M s Scustomer1name T u loan (u S!ranch1name T M
%e""y"id0e u Sloan1num!er T M s Sloan1num!er T))R
S1't( o1 E6*.'&&+o-&
$ tuple relational calculus may generate an infinite relation
#or e1ample5 P t Q t loanR results in infinitely many tuples that are not in loan relation
!o guard against the problem5 a domain is defined for all tuple relational calculus formula P
It is denoted by dom(P) it denotes that P can ta.e (alue only in that domain
$n e1pression Pt Q P (t )R in the tuple relational calculus is safe if e(ery component of t appears in
one of the relations5 tuples5 or constants that appear in P
4.2. D3MA!) (E;AT!3)A; CA;C2;2S
Domain relational calculus is also a nonprocedural Euery language eEui(alent in power to the tuple
relational calculus
It ser(ers as the theoretical basis of widely used &uery +y E1ample (&+E)
language Domain relational calculus e1pression is of the form=
P .
4
, .
7
, 3, .
n
Q P (.
4
5 .
7
, 3, .
n
)R
.
4
5 .
7
, 3, .
n
represent domain (ariables
P represents a formula composed of atoms
$n atom in Domain relational calculus has one of the following form
4 4 .4, .7, . . . , .n 5 r, where r is a relation on n attributes and .4, .7, . . . , .n are domain
(ariables or domain constants
7 . y5 where . and y are domain (ariables and is a comparison operator
< . c5 where . is a domain (ariable5 is a comparison operator5 and c is a constant
R5!'& to %5+!t 1o.)5!& 1.o) to)&
$n atom is a formula
If P4 is a formula5 then so are P4 and (P4)
If P4 and P7 are formulae5 then so are P4 K P75 P4 J P75 and P4 T P7
If P4(.) is a formula in 15 where 1 is a free domain (ariable5 then
S . (P4(1)) and U . (P4(1)) are also
formulae
E6)*!' Q5'.+'&
4 #ind the loan1num!er, !ranch1name, and amount for loans of o(er A4788
P l5 !, a Q l5 !, a loan a O 4788R
7 #ind the names of all customers who ha(e a loan of o(er A4788
P c Q l, !, a ( c, l !orrower l, !, a loan a O 4788)R
< #ind the names of all customers who ha(e a loan from the Perryridge branch and the loan
amount=
P c, a Q l ( c, l !orrower ! ( l, !, a loan ! I %e""y"id0eBBV
P c, a Q l ( c, l !orrower l, 6 Perryridge7, a loan)R
S1't( o1 E6*.'&&+o-&
!he e1pression= P .
4
, .
7
, 3, .
n
Q P (.
4
5 .
7
, 3, .
n
)R is safe if all of the following hold=
4 $ll (alues that appear in tuples of the e1pression are (alues from dom (P$ (that is5 the (alues appear
either in P or in a tuple of a relation mentioned in P$
7 ,o" e*e"y the"e e?ists s#b-o"m#'a o- the -o"m . (P
4
(.$)5 the subformula is true if and only if there
is a (alue of . in dom (P
4
) such that P
4
(.$ is true
< ,o" e*e"y -o" a'' s#b-o"m#'a o- the -o"m 1 (P
4
(.$)5 the subformula is true if and only if P
4
(.$ is
true for all (alues . from dom (P
4
)
5.1. I-t.o45,t+o-
5. SL; ,2)DAME)TA;S
%&' is a standard common set used to communicate with the relational database
management systems
$ll tas.s related to relational data management-creating tables5 Euerying5 modifying5 and
granting access to users5 and so on
5.2. A42-t3'& o1 SQL
%&' is a high le(el language that pro(ides a greater degree of abstraction than procedural languages
%&' enables the end-users and systems personnel to deal with a number of database management
systems where it is a(ailable
$pplication written in %&' can be easily ported across systems
%&' specifies what is reEuired and not how it should be done
%&' was simple and easy to learn can handle comple1 situations
$ll %&' operations are performed at a set le(el
5.:. P.t& o1 SQL
!he %&' language has se(eral parts=
Dt94'1+-+t+o- !-353' (DD') !he %&' DD' pro(ides commands for defining relation
schemas5 deleting relations5 and modifying relation schemas
I-t'.,t+2' 4t9)-+*5!t+o- !-353' (DM') !he %&' DM' includes a Euery language based
on both the relational algebra and the tuple relational calculus It also includes commands to insert
tuples into5 delete tuples from5 and modify tuples in the database
V+'/ 4'1+-+t+o- !he %&' DD' includes commands for defining (iews
T.-&,t+o- ,o-t.o! %&' includes commands for specifying the beginning and ending of
transactions
E)%'44'4 SQL and 4(-)+, SQL Embedded and dynamic %&' define how %&' statements can
be embedded within general-purpose programming languages5 such as -5 -335 ,a(a5 P')I5 -0+0'5
Pascal5 and #0R!R$*
I-t'3.+t( !he %&' DD' includes commands for specifying integrity constraints that the data stored
in the database must satisfy >pdates that (iolate integrity constraints are disallowed
A5t7o.+;t+o- !he %&' DD' includes commands for specifying access rights to relations and
(iews
5.4. Do)+- T(*'& +- SQL
1. C7. <-=" #i1ed length character string5 with user-specified length n.
2. 2.,7.<-=" Variable length character strings5 with user-specified ma1imum length n.
:. +-t" Integer (a finite subset of the integers that is machine-dependent)
4. S)!!+-t" %mall integer (a machine-dependent subset of the integer domain type)
5. -5)'.+, <*A4=" fi1ed point number5 with user-specified precision of p digits5 with n digits to the
right of decimal point
@. R'!A 4o5%!' *.',+&+o-" #loating point and double-precision floating point numbers5 with
machine-dependent precision
>. 1!ot <-=" #loating point number5 with user-specified precision of at least n digits
K. Dt'" Dates5 containing a (C digit) year5 month and date
E6)*!'" date C2665-;-275
9. T+)'" !ime of day5 in hours5 minutes and seconds
E6)*!'" time C6G@66@165 time C6G@66@16.755
1L. T+)'&t)*" date plus time of day
E6)*!'" timestamp C2665-;-27 6G@66@16.755
11. I-t'.2!" period of time
E6)*!'" inte"*a' C&5
day
5.5. DATA DEFINITION LANGUAGE <DDL=
It is used to create a table5 alter the structure of a table and also drop the table
DDL Co))-4&
1. CREATE -ommand used for creating tables
S(-t6" ,.'t' t%!' Ntable nameO (columnname4 data type (si/e)5 -olumnname 7 data
type(si/e)55 columnname n data type(si/e))H
E6)*!'" create table customer (custIname (archar7 (4B)5 socialIsecurityIno
number(44)5custIstreet (archar7(;)5custIcity (archar7(48))H
2. DESC -ommand used to (iew the table structure
S(-t6" 4'&, Ntable nameOH
E6)*!'" desc customerH
:. ALTER -ommand used for modifying table structure
+= S(-t6" !t'. t%!' Ntable nameO )o4+1( (columnname data type (new si/e))H
E6)*!'" alter table customer modify (custIstreet (archar7 (48))H
++= S(-t6" !t'. t%!' Ntable nameO )o4+1( (columnname new data type (si/e))H
E6)*!'" alter table customer modify (socialIsecurityIno (archar7 (44==M
+++= S(-t6" !t'. t%!' Ntable nameO 44 (new columnname data type (si/e))H
E6)*!'" alter table customer add (accIno (archar7(B))H
+2= S(-t6" !t'. t%!'Ntable nameO 4.o* (column name)H
E6)*!'" alter table customer drop (accIno)H
4. RENAME used to change the name of the table
S(-t6" .'-)' N0ld table nameO to N*ew table nameOH
E6)*!'" rename cust to cust4H
5. DROP -ommand used for remo(ing an e1isting table
S(-t6" 4.o* t%!' Ntable nameOH
E6)*!'" drop table cust4H
5.@. DATA MANIPULATION LANGUAGE <DML=
Data Manipulation language commands let user to insert5 modify and delete the data from
database
DDL Co))-4&
1. INSERT !o insert one or more number of Rows
S(-t6 1" +-&'.t +-to Dt%!' -)'E 2!5'& ('ist of Data Values)
S(-t6 2" +-&'.t into Ntable nameO (column names) 2!5'& (list of data (alues)
Insert command using >ser interaction
S(-t6 :" +-&'.t into N!able nameO 2!5'& (@columnname45 Wco'#mnname2X)
2. SELECT !o display one or more rows
S(-t6 1" &'!',t N 1.o) Ntable nameOH
S(-t6 2" &'!',t columnname45 columnname 7 1.o) Ntable nameOH
S(-t6 :" &'!',t N 1.o) Ntable nameO /7'.' NconditionOH
E6)*!'"
a) #ind the names of all branches in the loan table
&'!',t branchIname 1.o) loanH
b) 'ist all account numbers made by brighton branch
&'!',t ,,F-o 1.o) account /7'.' branchIname M UbrightonUH
c) 'ist the customers who are li(ing in the city harrison
&'!',t custIname 1.o) ,5&to)'. /7'.' custIcity M UharrisonUH
:. UPDATE >sed to alter the column (alues in a table
S(-t6" 5*4t' Ntable nameO &'t columnInameMnewI(alue where NconditionOH
E6)*!'" 5*4t' the account table to replace the balance (alue B88 to CB8
Q5'.(" 5*4t' account &'t ba'anceI.56 he"e accFnoI5A-&6&5Q
4. DELETE >sed to delete one or more rows
S(-t6" 4'!'t' from Ntable nameO /7'.' NconditionOH
E6)*!'" 4'!'t' from borrower /7'.' c#stFnameI5Dac/son5Q
5.>. BASIC STRUCTURE OF SQL E#PRESSION
%&' e1pression consists of three clauses=
S'!',t" !he select clause corresponds to proDection operation of the relational algebra It is used to
list the attributes desired in the result of a Euery
F.o)" !he from clause corresponds to the -artesian product operation of the relational algebra It
lists the relations to be scanned in the e(aluation of the e1pression
B7'.'" !he where clause corresponds to the selection predicate of the relations that appear in the
form clause
G'-'.! 1o.) o1 SQL ?5'.(
S'!',t A&, A2XXXX., An
F.o) (&, (2XXXXX, (m
B7'.' P
:here5 $4-represent an attribute
R4-represent relation
P-is a predicate
E6)*!'"
,ind the names o- a'' b"anches in the loan "e'ation@
&'!',t !ranch-name 1.o) loan
&'!',t 4+&t+-,t !ranch-name 1.o) loan 89:istinct eyword eleminates duplicates98
&'!',t !! !ranch-name 1.o) loan 89:uplicates are not removed98
,ind a'' 'oan numbers for loans made at the Perryridge branch with loan amounts greater that Y&266.
&'!',t loan-num!er 1.o) loan /7'.' !ranch-name I 5%e""y"id0e5 -4 amount 5 4788
R'-)' O*'.t+o-
!he %&' allows renaming relations and attributes using the as clause=
Old-name & new-name
E6)*!'" #ind the name5 loan number and loan amount of all customersH rename the column name
loan1num!er as loan1id.
select customer1name ,!orrower.loan1num!er as loan1id,a mount from !orrower,loan where
!orrower.loan1num!er ; loan.loan1num!er
T5*!' V.+%!'&
!uple (ariables are defined in the from clause (ia the use of the as clause
E6)*!'" #ind the customer names and their loan numbers for all customers ha(ing a loan at some
branch
select customer1name, /.loan1num!er, <.amount from !orrower as /, loan as <
where /.loan1num!er ; <.loan1num!er
St.+-3 O*'.t+o-
%&' includes a string-matchin0 ope"ato" -o" compa"isons on cha"acte" st"in0s.The ope"ato"
'i/e
uses patterns that are described using two special characters=
o percent (V) !he V character matches any substring
o underscore ( I ) !he I character matches any character
E6)*!'"
5%e""yZ5 matches any st"in0 be0innin0 ith %e""y.
5Zid0eZ5 matches any st"in0 containin0 id0e as a s#bst"in0, -o" e?amp'e, 5%e""y"id0e5,
5(oc/
(id0e5, 5Mian#s +"id0e5, and 5(id0eay5.
5- - - 5 matches any st"in0 o- e?act'y th"ee cha"acte"s.
5 - - -Z5 matches any st"in0 o- at 'east th"ee cha"acte"s.
E6)*!'" S'!',t N -"om c#stome" he"e c#stome"Fname 'i/e 5DZ5Q
S'!',t N -"om c#stome" he"e c#stome"FSt"eet 'i/e 5FaZ5Q
%&' supports a (ariety of string operations such as
concatenation A#sin0 [[B
con(erting from upper to lower case (and (ice (ersa)
finding string length5 e1tracting substrings5 etc
O.4'.+-3 t7' D+&*!( o1 T5*!'&
'ist in alphabetic order the names of all customers ha(ing a loan in Perryridge branch
E6)*!' "select distinct customer1name from !orrower, loan where !orrower loan1num!er ;
loan.loan1num!er and !ranch1name ; UPerryridgeU order by customer1name
:e may specify desc for descending order or asc for ascending order5 for each attributeH ascending
order is the default
E6)*!'" order by customer1name desc
S't O*'.t+o-&
S't operators combine the results of two Eueries into a single one
1. U-+o- returns all distinct rows selected by either Euery
E6)*!'" #ind all customers ha(ing a loan5 an account or both at the ban.
Q5'.(" select custIname from depositor 5-+o- select custIname from borrowerH
2. U-+o- !! 9 returns all rows selected by either Euery
E6)*!'" #ind all customers ha(ing a loan and an account at the ban.
Q5'.(" select custIname from depositor union all select custIname from borrowerH
3. I-t'.&',t returns only rows that are common to both the &ueries
E6)*!'" #ind all customers who ha(e both a loan5 and an account at the ban.
Q5'.(" select custIname from depositor +-t'.&',t select custIname from borrowerH
4. M+-5& returns all distinct rows selected only by the first &uery and not by the second
E6)*!'" !o find all customers who ha(e an account but no loan at the ban.
Q5'.(" select custIname from depositor minus select custIname from borrowerH
A33.'3t' F5-,t+o-
!hese functions operate on the multiset of (alues of a column of a relation5 and return a (alue
<= AVG 9 !o find the a(erage of (alues
E6)*!'" #ind the a(erage of account balance from the account table
Q5'.(" select 23 (balance) from accountH
<%= SUM !o find the sum of (alues
E6)*!'" #ind the sum of account balance from the account table
Q5'.(" select &5) (balance) from accountH
<,= MA# Returns the ma1imum (alue
E6)*!'" #ind the Ma1imum (alue of account balance from the account table
Q5'.(" select )6 (balance) from accountH
<4= MIN 9 Returns the minimum (alue
E6)*!'" #ind the Minimum (alue of account balance from the account table
Q5'.(" select )+- (balance) from accountH
<'= COUNT Returns the number of rows in the column or table
E6)*!' 1" #ind the number rows in the customer table
Q5'.(" select ,o5-t <N= from customerH
E6)*!' 2" #ind the number of rows in the balance column of account table
Q5'.(" select ,o5-t <%!-,'= from accountH
<1= GROUP BY
A33.'3t' F5-,t+o-& G.o5* B(
E6)*!' 1" #ind the a(erage account balance at each branch
Q5'.("select branchInameA 23 (balance) from account 3.o5* %( branchInameH
<3= HAVING CLAUSE
A33.'3t' F5-,t+o-& H2+-3 C!5&'
E6)*!' 2" #ind the a(erage account balance at brighton branch
Q5'.(" select branchIname5 23 (balance) from account 3.o5* %( branchIname ha(ing
b"anchFnameI5b"i0hton5M
N5!! V!5'&
It is possible for tuples to ha(e a null (alue5 denoted by null5 for some of their attributes
=ull signifies an un.nown (alue or that a (alue does not e1ist
!he predicate is null can be used to chec. for null (alues
E6)*!'" #ind all loan number which appears in the loan relation with null (alues for
amount.
select loan1num!er from loan where amount is null
-4= !he result of true -4 unnown is unnown5 false -4 unnown is false5 while unnown -4 unnown
is unnown
o.= !he result of true o. unnown is true5 false o. unnown is unnown5 while unnown o. unnown is
unnown
-ot= !he result of -ot unnown is unnown
N'&t'4 S5%?5'.+'&
%&' pro(ides a mechanism for the nesting of subEueries
$ subEuery is a select-from-where e1pression that is nested within another Euery
$ common use of subEueries is to perform tests for set membership5 set comparisons5 and set
cardinality
E6)*!' 1" #ind all the information of customer who has an account number is $-484.
Q5'.(" &'!',t N from customer where custInameM(select custIname
from depositor where accInoMU$-484U)H
E6)*!' 2"#ind all customers who ha(e a loan from the ban.5 find their names $nd loan numbers.
Q5'.(" &'!',t custIname5 loanIno from borrower where loanIno in
(select loanIno from loan)H
1. S't )')%'.&7+*&
S'!',t N -"om c#stome" he"e c#stome"Fname
inAC>ays5,Jones5BQ
INE6)*!'"
NOT
INE6)*!'" S'!',t N -"om c#stome" he"e c#stome"Fname not inAC>ays5,Jones5BQ
2. S't ,o)*.+&o-&
%&' uses (arious comparison operators such as N5 NM5M5O5OM5NO5any5 all5
some5Osome5Oany etc to compare sets
E6)*!'& 1" S'!',t N from borrower where loanInumberNany(select loanInumber
-"om 'oan 2 he"e
b"anchFnameI5%e""y"id0e5BQ
E6)*!' 2" S'!',t loanIno from loan from amountNM<8888H
:. T'&t 1o. E)*t( R'!t+o-
E1ists is a test for non empty set
E6)*!'" %elect title from boo. where e1ists(select J from order where boo.boo.-
idMorderboo.Iid)H
%imilar to e1ists we can use not e1ists also
E6)*!'" %elect title from boo. where not e1ists(select J from order where boo.boo.-
idMorderboo.Iid)H
4. T'&t 1o. %&'-,' o1 45*!+,t' t5*!'&
!he >niEue construct tests whether a subEuery has any duplicate tuples in its result
E6)*!'" &'!',t /.customer-name 1.o) depositor & /
/7'.' 5-+?5' (&'!',t R.customer-name 1.o) account, depositor & R
/7'.' /.customer-name M R.customer-name -4
R.account-num!er M account.account-num!er -4
account.!ranch-name I 5%e""y"id0e5B
*ot >niEue construct is used for test the e1istence of duplicate tuples in the same manner
Co)*!'6 Q5'.+'&
-omple1 Eueries are often hard or impossible to write as a single %&' bloc.!here are two ways of
composing multiple %&' bloc.s to e1press a comple1 Euery
4 Deri(ed relations
7 /+t7 clause
1. D'.+2'4 R'!t+o-&
%&' allows a subEuery e1pression to be used in the 1.o) clause If we use such an
e1pression5 then we must gi(e the result relation a name5 and we can rename the attributes #or renaming &
clause is used
Fo. '6)*!'" ,ind the a*e"a0e acco#nt ba'ance o- those b"anches he"e the a*e"a0e acco#nt
ba'ance is
0"eate" than Y&266.
S'!',t !ranch-name, avg-!alance 1.o) (&'!',t !ranch-name5 23 (!alance) 1.o) account
3.o5* %( !ranch-name)& !ranch-avg (!ranch-name, avg-!alance) /7'.' avg-!alance 5 4788
2ere subEuery result is named as !ranch-avg with attributes of !ranch-name and avg-!alance.
2. /+t7 clause
!he /+t7 clause pro(ides a way of defining a temporary (iew5 whose definition is a(ailable
only to the Euery in which the /+t7 clause occurs
-onsider the following Euery5 which selects accounts with the ma1imum balanceH if there are
many accounts with the same ma1imum balance5 all of them are selected
/+t7 ma.-!alance (value) &
&'!',t )6(!alance)
1.o) account
&'!',t account-num!er
1.o) account5 ma.-!alance
/7'.' account.!alance M ma.-!alance.value
@. !)TE<(!T4
Integrity constraints ensures that changes made to the database by authori/ed users donot result in a
loss of data consistency
It is a mechanism used to pre(ent in(alid data entry into the table
Pre(ents accidental damages of database
T(*'&
4 Domain integrity -onstraints
7 Entity integrity -onstraints
< Referential integrity -onstraints
1. Do)+- +-t'3.+t( Co-&t.+-t&
$ Domain is a set of (alues that may be assigned to an attribute $ll (alues that appear in a column
of a relation (table) must be ta.en from the same domain
T(*'&
*ot *ull -onstraints
-hec. -onstraints
= NOT NULL It will not allow null (alues
S(-t6 " ,.'t' t%!' Ntable nameO(columnname data type (si/e) constraint constraintIname -ot
-5!!=M
E6)*!' " accountIno char(48) notnullH
%= CHEC$ 9 >se the CHEC$ constraint when you need to enforce integrity rules that can be e(aluated
based on a condition (logical e1pression)
S(-t6 " ,.'t' t%!' Ntable nameO(columnname data type (si/e) constraint constraintIname ,7',0
(chec.Icondition))H
E6)*!'" create table student (name char(4B) not null5student-id char(48)5 degreeIle(el char(4B)5
p"ima"y /eyAst#dentFidB, chec/Ade0"eeF'e*e'
inACbache'o"s5,5maste"5,5docto"ate5BBBQ
!he ,.'t' 4o)+- clause can be used to dene new domains #or e1ample5 the statements=
,.'t' 4o)+- :ollars -5)'.+,(4757)
,.'t' 4o)+- Pounds -5)'.+,(4757)
2. E-t+t( +-t'3.+t( Co-&t.+-t&
!he entity integrity constraints state that no primary .ey (alue can be null !his is because the
primary .ey (alue is used to identify indi(idual tuples in a relation
T(*'&
>niEue -onstraint
Primary .ey -onstraint
= UNIQUE $(oid duplicate (alues uniEue($
D4
5$
D7
,
XX,A
Dm
)
!he uniEue specification saya that attributes $
D4
5$
D7
,XX,A
Dm
form a candidate .ey !hese attributes
should ha(e distinct (alues
S(-t6 ",.'t' t%!' Ntable nameE<,o!5)--)' 4t t(*' <&+;'= ,o-&t.+-t
constraintIname 5-+?5'=M
%= Co)*o&+t' UNIQUE Multicolumn uniEue .ey is called composite uniEue .ey
S(-t6 " ,.'t' t%!' Ntable nameO(columnname4 data type (si/e)5 columnname7 data type
(si/e)5 constraint constraintIname 5-+?5' (columnname45 columnname7))H
,= PRIMARY $EY It will not allow null (alues and a(oid duplicate (alues
S(-t6 " ,.'t' t%!' Ntable nameO(columnname data type (si/e) constraint constraintIname
*.+).( 0'(=M
4= Co)*o&+t' PRIMARY $EY Multicolumn primary .ey is called composite primary .ey
S(-t6 " ,.'t' t%!' Dtable nameO(columnname4 data type (si/e)5 columnname7 data type
(si/e)5 constraint constraintIname *.+).( 0'( (columnname45 columnname7))H
:. REFERENTIAL INTEGRITY
Ensures that a (alue appears in one relation for a gi(en set of attributes also appears for a certain set
of attributes in another relation !his condition is called referential integrity
R'1'.'-,' 0'( <1o.'+3- 0'(= Its represent relationships between tables #oreign .ey is a column whose
(alues are deri(ed from the primary .ey of the same or some other table.
S(-t6" ,.'t' t%!' Ntable nameO(columnname data type (si/e) constraint constraintIname
.'1'.'-,'& parentItableIname)H
Fo.)! D'1+-+t+o-
'et r
4
(R
4
) and r
7
(R
7
) be relations with primary .eys >
4
and >
7
respecti(ely
!he subset of R
7
is a foreign ey referencing >
4
in relation r
4
5 if for e(ery t
7
in r
7
there must be a tuple t
4
in r
4
such that t
4
S>
4
T M t
7
S T
Referential integrity constraint also called subset dependency since its can be written as
(r
7
)
>4
(r
4
)
A&& '. t+o-&
$n assertion is a predicate e1pressing a condition that we wish the database always to satisfy
$n assertion in %&' ta.es the form
-reate assertion Nassertion-nameO chec. NpredicateO
:hen an assertion is made5 the system tests it for (alidity5 and tests it again on e(ery update that
may (iolate the assertion
$sserting for all G5P(G) is achie(ed in a round-robin fashion using not e1ists G such that not
P(G)
A&&'.t+o- E6)*!'
!he sum of all loan amounts for each branch must be less than the sum of all account balances at
the branch
,.'t' &&'.t+o- sum-constraint ,7',0 (-ot '6+&t& (&'!',t J 1.o) !ranch /7'.' (&'!',t
&5)(amount) 1.o) loan /7'.' loan.!ranch-name M !ranch.!ranch-name) 5M (&'!',t
&5)(!alance) 1.o) account /7'.' account.!ranch-name M !ranch.!ranch-name)))
>.T(!<<E(S
$ t.+33'. is a statement that is e1ecuted automatically by the system as a side effect of a
modification to the database
!o design a trigger mechanism5 we must=
%pecify the conditions under which the trigger is to be e1ecuted
%pecify the actions to be ta.en when the trigger e1ecutes
T.+33'. E6)*!'
%uppose that instead of allowing negati(e account balances5 the ban. deals with o(erdrafts by
setting the account balance to /ero
creating a loan in the amount of the o(erdraft
gi(ing this loan a loan number identical to the account number of the o(erdrawn account
!he condition for e1ecuting the trigger is an update to the account relation that results in a negati(e
!alance (alue
S(-t6"
C.'t' o. .'*!,' t.+33'.Dt.+33'.9-)'EO%'1o.'P1t'.QO+-&'.tP4'!'t'P5*4t'Qo- Dt%!'9
-)'ER1o. ',7 &tt')'-tP1o. ',7 .o/SR/7'- D,o-4+t+o-ESM
P.t& o1 t.+33'."
a !rigger statement (!he DM' statement li.e insert)delete)update It fires the trigger body)
b !rigger body
c !rigger restriction (optional)
T(*'& o1 t.+33'.&"
a +efore
b $fter
c #or each row
d #or each statement (default)
a +efore)after=
It specifies when the trigger boby should be fired
In case of before5 the trigger will be e1ecuted before e1ecuting the triggering statement
In case of after5 it will be e1ecuted after the triggering statement
b #or each row)statement=
It decides if the trigger body to be fired once for each row affected by the triggering statement or
only once for the statementb e1ecuted
+y default5 the trigger fires for each statement
D+&%!+-3 T.+33'.&"
S(-t6 "$lter trigger NtriggerInameO disableH
E6)*!' " $lter trigger salesItrigger disableH
%pecific triggers on a table can be disabled as follows
$lter table purchaseIdetails disable purchaseH
$ll triggers on a table can be disabled on a table as follows
S(-t6 "$lter table NtableInameO disable all triggersH
E6)*!' "$lter table salesIdetails disables all triggersH
E-%!+-3 t.+33'."
S(-t6 "$lter table NtableInameO enable triggerInameH
E6)*!' "$lter table purchaseIdetails enable purchaseH
!o Enable all triggers
S(-t6 "$lter table NtableInameO enable all triggersH
D.o**+-3 t.+33'.&"
S(-t6 "Drop trigger NtriggerInameOH
E6)*!' "Drop trigger purchaseH
T.+33'. E6)*!'"
,.'t' t.+33'. overdraft-trigger 1t'. 5*4t' o- account
.'1'.'-,+-3 -'/ .o/ & nrow 1o. ',7 .o/ /7'- nrow.!alance N 8
T.+33'.+-3 E2'-t& -4 A,t+o-& +- SQL
!riggering e(ent can be +-&'.t5 4'!'t' or 5*4t'
!riggers on update can be restricted to specific attributes
E.3. ,.'t' t.+33'. overdraft-trigger 1t'. 5*4t' o1 !alance o- account
Values of attributes before and after an update can be
referenced .'1'.'-,+-3 o!4 .o/ & = for deletes
and updates .'1'.'-,+-3 -'/ .o/ & " for
inserts and updates
!riggers can be acti(ated before an e(ent5 which can ser(e as e1tra constraints Eg con(ert blan.s
to null
Stt')'-t L'2'! T.+33'.&
Instead of e1ecuting a separate action for each affected row5 a single action can be e1ecuted for
all rows affected by a transaction
o >se 1o. ',7 &tt')'-t instead of 1o. ',7 .o/
o >se .'1'.'-,+-3 o!4 t%!' or .'1'.'-,+-3 -'/ t%!' to refer to temporary tables (called
transition tables) containing the affected rows
o -an be more efficient when dealing with %&' statements that update a large number of rows
B7'- Not To U&' T.+33'.&
!riggers were used earlier for tas.s such as
maintaining summary data (eg total salary of each department)
Replicating databases by recording changes to special relations (called ,7-3' or 4'!t
relations) and ha(ing a separate process that applies the changes o(er to a replica
!here are better ways of doing these now=
Databases today pro(ide built in materiali/ed (iew facilities to maintain summary data
Databases pro(ide built-in support for replication
Encapsulation facilities can be used instead of triggers in many cases
Define methods to update fields
-arry out actions as part of the update methods instead of
through a trigger
$. SEC2(!T4
%ecurity of data is important concept in D+M% because it is essential to safeguard the data against
any unwanted users
It is a protection from malicious attempts to steal or modify data
T7'.' .' 1+2' 4+11'.'-t !'2'!& o1 &',5.+t(
1. Dt%&' &(&t') !'2'!
$uthentication and authori/ation mechanism to allow specific users access only to reEuired data
2. O*'.t+-3
:. N't/o.0 !'2'!
Protection from in(alid logins
#ile-le(el access protection
%"otection -"om imp"ope" #se o- s#pe"#se" a#tho"ity.
Protection from improper use of pri(ileged machine instructions
Each site must ensure that it communicates with trusted sites
'in.s must be protected from theft or modification of messages
M',7-+&)& 5&'4
Identification protocol (password based)
-ryptography
4. P7(&+,! !'2'!
So!5t+o-
Protection of eEuipment from floods5power failure etc
Protection of dis.s from theft5erasure5physical damage etc
Protection of networ. and terminal cables from wire tapes5non-in(asi(e electronic
ea(esdropping5physical damage5 etc
Replication hardware-mirrored dis.s5dual busses etc
Multiple access paths between e(ery pair of de(ices
Physical security by loc.s5police etc
5. H5)- !'2'!
So!5t+o-
%oftware techniEues to detect physical security breaches
Protection from stolen passwords5sabotage5etc
A5t7o.+;t+o-
4 #reEuent change of passwords
7 2se o- non-0#essab'e passo"ds.
< 'og all in(alid access attempts
C Data audits
B -areful hiring practices
Fo.)& o1 5t7o.+;t+o- o- *.t& o1 t7' 4t%&'"
Read authori/ation - allows reading5 but not modification of data
Insert authori/ation - allows insertion of new data5 but not modification of e1isting data
>pdate authori/ation - allows modification5 but not deletion of data
Delete authori/ation - allows deletion of data
Fo.)& o1 5t7o.+;t+o- to )o4+1( t7' 4t%&' &,7')"
Inde1 authori/ation - allows creation and deletion of indices
Resources authori/ation - allows creation of new relations
$lteration authori/ation - allows addition or deletion of attributes in a relation
Drop authori/ation - allows deletion of relations
T7' 3.-t &tt')'-t is used to gi(e authori/ation
S(-t6" 3.-t Npre(ilege listO on Nrelation name or (iew nameO to Nuser)role listO
E6)*!' " 3.-t &'!',t o- ,,o5-t to 8o7-A ).(M )) this Euery grants database users Dohn and
mary with select authori/ation
3.-t 5*4t'<,,o5-t= o- !o- to 8o7-A ).(M
R'2o0' &tt')'-t" It gets bac. the granted pre(ilege
S(-t6" .'2o0' Npre(ilege listO on Nrelation name or (iew nameO from Nuser)role
listOSrestrictQcascadeT
E6)*!' " .'2o0' &'!',t o- %.-,7 1.o) 8o7-A ).(M
.'2o0' 5*4t'<,,o5-t= o- !o- 1.o) 8o7-A ).(M
Re(ocation of a pri(ilege from a user may cause other users also to lose that pri(ilegeH referred to as
cascading of the re(o.e
:e can pre(ent cascading by specifying restrict=
re(o.e select on
!ranch from %
"
, %
#
, %
?
restrict
:ith restrict5 the re(o.e command fails if cascading re(o.es are reEuired
Ro!'&
Roles permit common pri(ileges for a class of users can be specified Dust once by creating a
co""espondin0 "o'e
Pri(ileges can be granted to or re(o.ed from roles5 Dust li.e user
Roles can be assigned to users5 and e(en to other roles
o create role teller
create role manager
o grant select on
!ranch to teller
grant update (!alance) on account to teller
grant all pri(ileges on account to manager
grant teller to manager
grant teller to alice, !o!
grant manager to avi
A5t7o.+;t+o- -4 V+'/&
>sers can be gi(en authori/ation on (iews5 without being gi(en any authori/ation on the
relations used in the (iew definition
$bility of (iews to hide data ser(es both to simplify usage of the system and to enhance security
by allowing users access only to data they need for their Dob
$ combination or relational-le(el security and (iew-'e*e' sec#"ity can be #sed to 'imit a
#se"5s
access to precisely the data that user needs
G.-t+-3 o1 P.+2+!'3'&
!he passage of authori/ation from one user to another may be represented by an authori/ation
grant graph
!he nodes of this graph are the users
!he root of the graph is the database administrator
-onsider graph for update authori/ation on loan
$n edge %
i
%
D
indicates that user %
i
has granted update authori/ation on loan to %
j
A5t7o.+;t+o- G.-t G.*7
A5t7o.+;t+o- G.-t G.*7
Requirement" $ll edges in an authori/ation graph must be part of some path originating with
the database administrator
If D+$ re(o.es grant from %
4
=
o 6rant must be re(o.ed from %
C
since %
4
no longer has authori/ation
o 6rant must not be re(o.ed from %
B
since %
B
has another authori/ation path from D+$
through %
7
Must pre(ent cycles of grants with no path from the root=
o D+$ grants authori/ation to %
7
o %
;
grants authori/ation to %
<
o %
F
grants authori/ation to %
7
o D+$ re(o.es authori/ation from %
7
If the database administrator re(o.es authori/ation from %75 %7 retains authori/ation through %<5
If authori/ation is re(o.ed subseEuently from %<5 %< appears to retain authori/ation through %7
:hen the database administrator re(o.es authori/ation from %<5 the edges from%< to %7 and from
%7 to %< are no longer part of a path starting with the database administrator
!he edges between %7 and %< are deleted5 and the resulting authori/ation graph is
A54+t& T.+!&
$n audit trail is a log of all changes (inserts)deletes)updates) to the database along with
information such as which user performed the change5 and when the change was performed
>sed to trac. erroneous)fraudulent updates
-an be implemented using triggers5 but many database systems pro(ide direct support
L+)+tt+o-& o1 SQL A5t7o.+;t+o-
%&' does not support authori/ation at a tuple le(el
o Eg we cannot restrict students to see only (the tuples storing) their own grades
:ith the growth in :eb access to databases5 database accesses come primarily from application
ser(ers
o End users donUt ha(e database user ids5 they are all mapped to the same database user id
$ll end-users of an application (such as a web application) may be mapped to a single database
user
!he tas. of authori/ation in abo(e cases falls on the application program5 with no support from
%&'
o B'-'1+t" fine grained authori/ations5 such as to indi(idual tuples5 can be implemented by the
application
o D./%,0" $uthori/ation must be done in application code5 and may be dispersed all o(er
an application
o -hec.ing for absence of authori/ation loopholes becomes (ery difficult since it reEuires
reading large amounts of application code
E-,.(*t+o-
:ata Encryption <tandard (DE%) substitutes characters and rearranges their order on the basis of an
encryption .ey which is pro(ided to authori/ed users (ia a secure mechanism %cheme is no more secure
than the .ey transmission mechanism since the .ey has to be shared
$d(anced Encryption %tandard ($E%) is a new standard replacing DE%5 and is based on the
RiDndael algorithm5 but is also dependent on shared secret .eys
Pu!lic-ey encryption is based on each user ha(ing two .eys=
o public key publicly published .ey used to encrypt data5 but cannot be used to decrypt data
o private key -- .ey .nown only to indi(idual user5 and used to decrypt data
*eed not be transmitted to the site doing encryption
Encryption scheme is such that it is impossible or e1tremely hard to decrypt data gi(en only the
public .ey
!he R%$ public-.ey encryption scheme is based on the hardness of factoring a (ery large number
(488Us of digits) into its prime components
A5t7'-t+,t+o- <C7!!'-3' .'&*o-&' &(&t')=
Password based authentication is widely used5 but is susceptible to sniffing on a networ.
-hallenge-response systems a(oid transmission of passwords
o D+ sends a (randomly generated) challenge string to user
o >ser encrypts string and returns result
o D+ (erifies identity by decrypting result
o -an use public-.ey encryption system by D+ sendin0 a messa0e enc"ypted #sin0
#se"5s
public .ey5 and user decrypting and sending the message bac.
D+3+t! &+3-t5.'& are used to (erify authenticity of data
o Pri(ate .ey is used to sign data and the signed data is made public
o $ny one can read the data with public .ey but cannot generate data without pri(ate .ey
o Digital signatures also help ensure nonrepudiation= sender
cannot later claim to ha(e not created the data
D+3+t! C'.t+1+,t'&
Digital certificates are used to (erify authenticity of public .eys
Problem= when you communicate with a web site5 how do you .now if you are tal.ing with the
genuine web site or an imposterK
o %olution= use the public .ey of the web site
o Problem= how to (erify if the public .ey itself is genuineK
%olution=
o E(ery client (eg browser) has public .eys of a few root-le(el certification authorities
o $ site can get its name)>R' and public .ey signed by a certification authority= signed
document is called a certificate
o -lient can use public .ey of certification authority to (erify certificate
o Multiple le(els of certification authorities can e1ist Each certification authority
presents its own public-.ey certificate signed by a higher le(el authority5 and
>ses its pri(ate .ey to sign the certificate of other web sites)authorities
9. EM+EDDED SL;
Embedded %&' are %&' statements included in the programming language
!he %&' standard defines embeddings of %&' in a (ariety of programming languages such as
-5 ,a(a5 and -obol
$ language to which %&' Eueries are embedded is referred to as a 7o&t !-353'5 and the %&'
structures permitted in the host language comprise em!edded %&'
!he embedded %&' program should be preprocessed prior to compilation
!he preprocessor replaces embedded %&'reEuests with host language declarations and procedure
calls
!he resulting program is compiled by host language compiler
E#EC SQL statement is used to identify embedded %&' reEuest to the preprocessor
o EGE- %&' Nembedded %&' statement O E*DIEGE-
Not'" this (aries by language (for e1ample, the Ja*a embeddin0 #ses \ SL; ] X. VQ 5 - language
uses semicolon instead of E*DIEGE-)
E6)*!' Q5'.(
#rom within a host language5 find the names and cities of customers with more than the (ariable
amount dollars in some account
%pecify the Euery in %&' and declare a cursor for it
EGE- %&'
4',!.' c ,5.&o. 1o.
&'!',t depositor.customer1name, customer1city
1.o) depositor, customer, account
/7'.' depositor.customer1name ; customer.customer1name
-4 depositor account1num!er ; account.account1num!er
-4 account.!alance 5 @amount
E*DIEGE-
!he o*'- statement causes the Euery to be e(aluated
EGE- %&' o*'- c E*DIEGE-
!he 1't,7 statement causes the (alues of one tuple in the Euery result to be placed on host
language (ariables
EGE- %&' 1't,7 c +-to =cn, @cc E*DIEGE-
Repeated calls to 1't,7 get successi(e tuples in the Euery result
$ (ariable called %&'%!$!E in the %&' communication area (%&'-$) gets set to C626665 to
indicate no more data is a(ailable
!he ,!o&' statement causes the database system to delete the temporary relation that holds the
result of the Euery
EGE- %&' ,!o&' c E*DIEGE-
*ote= abo(e details (ary with language #or e1ample5 the ,a(a embedding defines ,a(a iterators to step
through result tuples
U*4t'& T7.o537 C5.&o.&
-an update tuples fetched by cursor by declaring that the cursor is for update
o 4',!.' c ,5.&o. 1o. &'!',t J 1.o) account
/7'.' !ranch1name I C%e""y"id0e5
1o. 5*4t'
!o update tuple at the current location of cursor c
5*4t' account &'t !alance ; !alance 3 488 /7'.' ,5..'-t o1 c
1L. D4)AM!C SL;
!he Dynamic %&' allows programs to construct and submit %&' Eueries at run time
Dynamic %&' can be e1ecuted immediately or can be used later
!wo principle Dynamic %&' statements are
4 PREP$RE
7 EGE->!E
SL;S32(CE I 5De'ete -"om acco#nt he"e amo#nt^&6666Q
EGE- %&' PREP$RE %&'PREPPED #R0M=%&'%0>R-EH
EGE- %&' EGE->!E %&'PREPPEDH
%&'%0>R-E specifies the programming language (ariable
%&'PREPPED identifies the %&' (ariables It holds the compiled (ersion of %&' statement
whose source form is gi(en in %&'%0>R-E
!he prepare statement ta.es the source statement and prepares it to produce an e1ecutable
(ersion5 which is stored in %&'PREPPED
EGE->!E statement e1ecutes the %&'PREPPED (ersion
EGE->!E IMMEDI$!E statement combines the functions of PREP$RE and EGE->!E in a
single operation
C!! L'2'! I-t'.1,'
!he %&' -all 'e(el Interface ASL;_C;!B is based on Mic"oso-t5s 3penso#"e Data+ase
Connecti*ity
(0D+-)
!hey allow the applications to be written from which the e1act %&' code is not .nown until run
time
!wo principle reason for using %&')-'I
Dynamic %&' is a source code statement Dynamic %&' reEuires some .ind of %&'
compiler to process the operations li.e PREP$RE5 EGE->!E %&')-'I does not reEuir any
special compiler instead it uses the host language compiler It is in obDect code form
%&')-'I is D+M% independent ie5 it allows creation of se(eral applications with different
D+M%
E6)*!' 1o. %&')-'I
st"cpy AsO'so#"ce, De'ete -"om acco#nt he"e amo#nt`&6666BQ
rc M %&'E1ecDirect(hstmt5(%&'-2$RJ)sElsource5%&'*!%)H
%trcpy is used to copy the source form of delete statement into sElsource (ariable
%&'E1ecDirect e1ecutes the %&' %tatement contained in sElsource anf assigns the return code
to the (ariable rc
T/o &t-4.4& ,o--',t& - SQL 4t%&' -4 *'.1o.)& ?5'.+'& -4 5*4t'&.
0pensoure Data+ase -onnecti(ity (0D+-) was initially de(eloped for - language and e1tended
to other languages li.e -335 -W amd Visual +asic
,a(a Data+ase -onnecti(ity (,D+-) is an application program interface foe Da(a language
!he users and applications connects to an %&' ser(er establishing a session5 e1ecutes a series of
atatements and finally disconnects the session
In addition to normal %&' commands5 a session can also contains commands to commit the
wor. carried out or rollbac. the wor. carried out in a session
11.9!E:S
$ View is an obDect that gi(es the user a logical (iew of data from an underlying tables or tables
It is not desirable for all users to see the entire logical model
%ecurity consideration may reEuire that certain data be hidden from users
$ny relation that is not part of the logical model5 but is made (isible to a user as a (irtual relation5
is called as (iew
V+'/& )( %' ,.'t'4 1o. t7' 1o!!o/+-3 .'&o-&"
4 !o pro(ide data security
7 &uery simplicity
< %tructure simplicity
C.'t+-3 o1 V+'/&
VIEB"9is an imaginary table
S(-t6" -reate (iew N(iew nameO(column alias name) as Euery with condition
Q5'.(" create (iew custall as (%elect custIname5 city from customer)H
A&&+3-+-3 N)'& to Co!5)-&
E6)*!'" create (iew custall (customername5 city) as (%elect custIname5 city from customer)H
S'!',t+-3 4t 1.o) 2+'/" Display the (iew
E6)*!'"select J from custallH
U*4t+o- o1 V+'/
Views can be used for data manipulation ie5 the user can perform insert5 >pdate5a nd the delete
operations on the (iew
!he (iews on which data manipulation can be done are called 5*4t%!' V+'/&5 the (iews that do
not allow data manipulation are called R'4o-!( V+'/&
D'&t.o(+-3 2+'/
$ (iew can be dropped by using the drop (iew command
S(-t6" 4.o* (iew (iewInameH
E6)*!'" drop (iew custallH
12.!)T(3D2CT!3) T3 D!ST(!+2TED DATA+ASES A)D
C;!E)T_SE(9E( DATA+ASES
2 M.0 Q5 '&t+o- &
4 Define- relational algebra
7 :hat is a %E'E-! operationK
< :hat is a PR0,E-! operationK
C :rite short notes on tuple relational calculus
B :rite short notes on domain relational calculus
9 Define Euery languageK
; :hat are the two different categories of Euery languagesK
F :rite short notes on %chema diagram
L :hich condition is called referential integrityK E1plain its basic concepts
48 :hat are the parts of %&' languageK
47 :hat are the categories of %&' commandK
4< :hat are the three classes of %&' e1pressionK8r E1plain the basic structure of an %&' e1pression
4C 6i(e the general form of %&' EueryK
4B :hat is the use of rename operationK
49 Define tuple (ariableK
4; 'ist the string operations supported by %&'K
4F 'ist the set operations of %&'K
4L :hat is the use of >nion and intersection operationK
78 :hat are aggregate functionsK $nd list the aggregate functions supported by %&'K
74 :hat is the use of group by clauseK
77 :hat is the use of sub EueriesK
7< :hat is (iew in %&'K 2ow is it definedK
7C :hat is the use of with clause in %&'K
7B 'ist the table modification commands in %&'K
79 'ist out the statements associated with a database transactionK
7; :hat is transactionK
7F 'ist the %&' domain !ypesK
7L :hat is the use of integrity constraintsK
<8 Mention the 7 forms of integrity constraints in ER modelK
<4 :hat is triggerK
<7 :hat are domain constraintsK
<< :hat are referential integrity constraintsK
<C :hat is assertionK Mention the forms a(ailable
<B 6i(e the synta1 of assertionK
<9 :hat is the need for triggersK
<; 'ist the reEuirements needed to design a trigger
<F 6i(e the forms of triggersK
<L :hat does database security refer toK
C8 'ist some security (iolations (or) name any forms of malicious access
C4 'ist the types of authori/ation
C7 :hat is authori/ation graphK
C< 'ist out (arious user authori/ation to modify the database schema
CC :hat are audit trailsK
CB Mention the (arious le(els in security measures
C9 *ame the (arious pri(ileges in %&'K
C; Mention the (arious user pri(ileges
CF 6i(e the limitations of %&' authori/ation
CL 6i(e some encryption techniEuesK
B8 :hat does authentication referK
B4 'ist some authentication techniEues
B7 :hat is embedded %&'K :hat are its ad(antagesK
1@ M.0 Q5 '&t+o- &
4 Discuss about (arious operations in Relational algebra (#undamental operations $dditional operation)
7 Discuss in detail about an Integrity5 !riggers and %ecurity
< E1plain Embedded and Dynamic %&'
C E1plain %tring 0perations and $ggregate functions used in %&'
B E1plain detail in domain relational calculus
9 E1plain detail in !uple relational calculus
; E1plain detail in distributed databases and client)ser(er databases
2)!T !!!
DATA+ASE DES!<)
#unctional Dependencies *on-loss Decomposition #unctional Dependencies #irst5 %econd5 !hird
*ormal #orms5 Dependency Preser(ation +oyce)-odd *ormal #orm- Multi-(alued Dependencies and
#ourth *ormal #orm ,oin Dependencies and #ifth *ormal #orm
1. !)T(3D2CT!3)
Relational database design reEuires a 0ood co''ection o- "e'ation schemas
P+t91!!& +- R'!t+o-! Dt%&' D'&+3-
$ bad design may lead to
Repetition of information
Inability to represent certain information
D'&+3- Go!&
a) $(oid redundant data
b) Ensure that relationships among attributes are represented
c) #acilitate the chec.ing of updates for (iolation of database integrity constraints
E6)*!'" -onsider the relation schema=
'ending-schemaM (branchIname5 branchIcity5 assets5c ustomerIname5 loanIno5 amount)
%.-,7F-)' %.-,7F,+t( &&'t& ,5&to)'.F-)' !o-F-o )o5-t
Downtown
Redwood
Porryride
Downtown
+roo.lyn
Palo $lto
2orsenec.
+roo.lyn
L85885888
745885888
4;5885888
L85885888
,ones
%mith
2ayes
,ac.son
'-4;
'-7<
'-4B
'-4C
4888
7888
4B88
<B88
2ere branch Downtown details are represented 7 times !his leads to a redundancy problem
Redundancy leads to
(a) :astage of space
(b) -omplicates updating5 introduces inconsistency
N5!! 2!5'&
(a) -annot store information about a branch if no loan e1ist
(b) -an use null (alues5 but they are difficult to handle
2. ,2)CT!3)A; DE%E)DE)C!ES
#unctional dependencies are constraints on the set of legal relations
!he functional dependency holds on R if and only if for any legal relations r(R)5 whene(er
any two tuples t
4
and t
7
of r agree on the attributes 5 they also agree on the attributes . !hat is5
t
4
S T M t
7
S T t
4
S T M t
7
S T
It reEuires that the (alue for a certain set of attributes determines uniEuely the (alue for another set
of attributes
In a gi(en relation R5 G and ? are attributes $ttributes ? is functionally dependent on attribute G if
each (alue of G determines e1actly one (alue of ?5 which is represented as
G O ?
i.e., P dete"mines 4 o" 4 is -#nctiona''y dependent on P
G O ? does not imply ? O G
#or e1ample5 in a student relation the *a'#e o- an att"ib#te Ma"/s is .nown then the (alue of
an
att"ib#te <"ade is dete"mined since
Mar.s O 6rade
T(*'&
(a) #ull functional dependency
(b) Partial functional dependency
(c) !ransiti(e functional dependency
<=F5!! 4'*'-4'-,+'&
In a relation R5 G and ? are attributes G functionally determines ? %ubset of G should not
functionally determine ?
In the abo(e e1ample mar.s is fully functionally dependent on studentIno and courseIno together
and not on subset of PstudentIno5 courseInoR
!his means mar.s cannot be determined either by studentIno or courseIno aloneIt can be
determined only using studentIno and courseIno together
2ence mar.s are fully functionally dependent on PstudentIno5 courseInoR
<%=P.t+! 4'*'-4'-,+'&
$ttribute ? is partially dependent on the attribute G only if it is dependent on a subset of attribute G
#or e1ample courseIname5 InstructerIname are partially dependent on composite attributes Pstudent-
no5courseInoR because courseIno alone defines courseIname5 InstructorIname
<,=T.-&+t+2' 4'*'-4'-,+'&
G5 ? and X are < attributes in the relation R
G O ?
? O X
G O X
#or e1ample5 grade depends on mar.s and in turn mar. depends on PstudentIno
courseInoR5 hence 6rade depends fully transiti(ely on PstudentIno @ courseInoR
U&' o1 F5-,t+o-! D'*'-4'-,+'&
:e use functional dependencies to=
o !est relations to see if they are legal under a gi(en set of functional dependencies
If a relation r is legal under a set , of functional dependencies5 we say that r satisfies
,.
o specify constraints on the set of legal relations
:e say that , holds on R if all legal relations on R satisfy the set of functional
dependencies ,.
2.1. CLOSURE OF A SET OF FUNCTIONAL DEPENDENCIES
6i(en a set of functional dependencies ,5 there are certain other functional dependencies that are
logically implied by ,
o #or e1ample= If A A and A C5 then we can infer that A -
!he set of all functional dependencies logically implied by , is the closure of ,
:e denote the closure of , by ,
B
.
:e can find all #
B
by applying A.)&t.o-3T& A6+o)&"
o R'1!'6+2+t( R5!'
If is a set of attributes and 5 then holds
o A53)'-tt+o- R5!'
If , then is a set of attributes5 then holds
o T.-&+t+2+t( R5!'
If holds and holds then holds
!hese rules are
o %ound (generate only functional dependencies that actually hold) and
o -omplete (generate all functional dependencies that hold)
In addition to these three basic rules there are three additional rules to simplify manual
computation of ,
3
o U-+o- R5!'
If holds and holds5 then holds
o D',o)*o&+t+o- R5!'
If holds5 then holds and holds
o P&'54ot.-&+t+2+t( R5!'
If holds and holds5 then holds
E6)*!'"
-onsider the schema R ; (A, A, C, -, C, D$
%et of functional dependency , ; P$ A
A C
C- C
C- D
A CE
some members of ,
3
o A C
+y transiti(ity from A A and A C then A C holds
o A- D
+y augmenting A C with 65 to get A- C- and then transiti(ity with C- D
we get A- D.
o C- CD
+y union rule of C- C and C- D, C- CD holds
!he left-hand and right-hand sides of a functional dependency are both subsets of R
P.o,'45.' 1o. Co)*5t+-3 F
U
" !o compute the closure of a set of functional dependencies #=
,
3
M ,
.'*'t
1o. ',7 functional dependency f in ,
3
apply refle1i(ity and augmentation rules on f
add the resulting functional dependencies to ,
3
1o. ',7 pair of functional dependencies f
4
and f
7
in ,
3
+1 f
4
and f
7
can be combined using transiti(ity
t7'- add the resulting functional dependency to ,
3
5-t+! ,
3
does not change any further
$ set of si/e n has 7
n
subsets5 there are a total of 7 F 7
n
M 7
n34
possible functional
dependencies5 where n is the number of attributes in R
Each iteration of the loop e1cept the last iteration adds at least one functional dependency to ,3
2.2. CLOSURE OF ATTRIBUTES SETS
$n attribute is functionally determined by if holds
6i(en a set of attributes 5 define the closure of (
3
) under , as the set of attributes that are
functionally determined by under ,
$lgorithm to compute
3
5 the closure of under ,
result =M aH
/7+!' (changes to result) 4o
1o. ',7 +- , 4o
%'3+-
'-4
+1 result t7'- result =M result
E6)*!' o1 Att.+%5t' S't C!o&5.'
R ; (A, A, C, -, C, D$
, ; PA A
A C
C- C
C- D
A CR
!o compute closure of A, (A-$
3
!he algorithm start with result M $6
4 result ; A-
7 A G A includes A in result %ince AG A is in , and A result5 so result@ ; result
A
< result ; AAC- (A C $
< result ; AAC-C (C- C and C- A-AC$
C result ; AAC-CD (C- D and C- A-ACC$
U&'& o1 Att.+%5t' C!o&5.'
!here are se(eral uses of the attribute closure algorithm=
!esting for super .ey=
o !o test if is a super .ey5 we compute
35
and chec. if
3
contains all attributes of R
!esting functional dependencies
o !o chec. if a functional dependency holds (or5 in other words5 is in ,
3
)5 Dust chec. if
3
H(%.+4 H&7Jo+-
Y >seful when memory si/ed are relati(ely large5 and the build input is bigger than memory
Y M+- 1't5.' o1 7(%.+4 7&7 8o+-"
=eep the first partiti&) &f the #i%d re%ati&) i) mem&ry.
CS1254 DATABASE MANAGEMENT
SYSTEMS
17
1
Y Eg :ith memory si/e of 7B bloc.s5 depositor can be partitioned into fi(e partitions5 each of si/e 78
bloc.s
Y D+2+&+o- o1 )')o.("
!he first partition occupies 78 bloc.s of memory
4 bloc. is used for input5 and 4 bloc. each for buffering the other C partitions
Y customer is similarly partitioned into fi(e partitions each of si/e F8
Y the first is used right away for probing5 instead of being written out
Y -ost of <(F8 3 <78) 3 78 3F8 M 4<88 bloc. transfers for
hybrid hash Doin5 instead of 4B88 with plain hash-Doin
Co)*!'6 Jo+-&
Y ,oin with a conDuncti(e condition=
(
& 2 ... n
3
Y Either use nested loops)bloc. nested loops5 or
Y -ompute the result of one of the simpler Doins r
i
s
final result comprises those tuples in the intermediate result that satisfy the remaining
conditions
&
. . .
i & i e&
. . .
n
Y ,oin with a disDuncti(e condition
(
& 2 ... n
3
Y Either use nested loops)bloc. nested loops5 or -ompute as the union of the records in
indi(idual Doins
A(
&
3B A(
2
3% . . . A(
n
3%
Ot7'. O*'.t+o-&
Y D5*!+,t' '!+)+-t+o- can be implemented (ia hashing or sorting
Y 0n sorting duplicates will come adDacent to each other5 and all but one set of duplicates can
be deleted
Y 2ashing is similar duplicates will come into the same buc.et
Y P.o8',t+o-"
Y Perform proDection on each tuple followed by duplicate elimination
Y A33.'3t+o- can be implemented in a manner similar to duplicate elimination
Y %orting or hashing can be used to bring tuples in the same group together5 and then the
aggregate functions can be applied on each group
CS1254 DATABASE MANAGEMENT
SYSTEMS
17
2
Y S't o*'.t+o-& ( 5 and )= can either use (ariant of merge-Doin after sorting5 or (ariant of hash-
Doin
r s=
o $dd tuples in s
i
to the hash inde1 if they are not already in it
o $t end of s
i
add the tuples in the hash inde1 to the result
r s=
o output tuples in s
i
to the result if they are already there in the hash inde1
r s@
o for each tuple in s
i
, if it is there in the hash inde15 delete it from the inde1
o $t end of s
i
add remaining tuples in the hash inde1 to the result
Y O5t'. 8o+- can be computed either as
Y $ Doin followed by addition of null-padded non-participating tuples
Y by modifying the Doin algorithms
Y Modifying merge Doin to compute r s
Y In r s5 non participating tuples are those in r
R
(r s)
Y Modify merge-Doin to compute r s@ During merging5 for e(ery tuple t
r
from r that do
not match any tuple in s, output t
r
padded with nulls
Y Right outer-Doin and full outer-Doin can be computed similarly
Y Modifying hash Doin to compute r s
Y If r is probe relation5 output non-matching r tuples padded with nulls
Y If r is build relation5 when probing .eep trac. of which r tuples matched s tuples $t end of
s
i
output non-matched r tuples padded with nulls
CS1254 DATABASE MANAGEMENT
SYSTEMS
17
3
4 Define Euery optimi/ation
7 :hat is an inde1K
< :hat are called Du.ebo1 systemsK
C :hat are the types of storage de(icesK
B :hat is called remapping of bad sectorsK
9 Define access time
; Define see. time
F Define a(erage see. time
L Define rotational latency time
48 Define a(erage latency time
44 :hat is meant by data-transfer rateK
47 :hat is meant by mean time to failureK
4< :hat is a bloc. and a bloc. numberK
4C :hat are called Dournaling file systemsK
4B :hat is the use of R$IDK
49 :hat is called mirroringK
4; :hat is called mean time to repairK
4F :hat is called bit-le(el stripingK
4L :hat is called bloc.-le(el stripingK
2 M . 0 Q 5 ' &t+o - &
78 :hat are the two main goals of parallelismK
74 :hat are the factors to be ta.en into account when choosing a R$ID le(elK
77 :hat is meant by software and hardware R$ID systemsK
7< Define hot swappingK
7C :hat are the ways in which the (ariable-length records arise in database systemsK
7B :hat is the use of a slotted-page structure and what is the information present in the headerK
79 :hat are the two types of bloc.s in the fi1ed length representationK Define them
7; :hat is .nown as heap file organi/ationK
7F :hat is .nown as seEuential file organi/ationK
7L :hat is hashing file organi/ationK
<8 :hat is .nown as clustering file organi/ationK
<4 :hat are the types of indicesK
<7 :hat are the techniEues to be e(aluated for both ordered inde1ing and hashingK
<< :hat is .nown as a search .eyK
<C :hat is a primary inde1K
<B :hat are called inde1-seEuential filesK
<9 :hat are the two types of indicesK
<; :hat are called multile(el indicesK
<F :hat is +-!reeK
<L :hat is a +3-!ree inde1K
C8 :hat is a hash inde1K
C4 :hat is called Euery processingK
C7 :hat are the steps in(ol(ed in Euery processingK
C< :hat is called an e(aluation primiti(eK
CC :hat is called a Euery e(aluation planK
CB :hat is called a Euery e1ecution engineK
C9 :hat are called as inde1 scansK
C; :hat is called as e1ternal sortingK
CF :hat is called as recursi(e partitioningK
CL :hat is called as an *-way mergeK
B8 :hat is .nown as fudge factorK
B4 2ow to choose the best e(aluation plan for &ueryK
1@ M.0 Q5 '&t+o- &
1. E1plain (arious hashing techniEues
7 E1plain R$ID
< E1plain the steps in &uery processing
C E1plain +3 !ree and +-tree
B a) E1plain the types of #ile 0rgani/ation
b) E1plain some basic algorithms used in selection operation5 %orting and ,oin operation
9 E1plain physical storage media with e1ample
"r evio us $ ear %nna &ni versit y 'u est io ns
+E)+!eeh DE6REE EG$MI*$!I0*5 M$?),>*E 788;
#ifth %emester
(Regulation 788C) -omputer
%cience and Engineering
-% 4<84 c D$!$+$%E M$*$6EME*! %?%!EM%
(-ommon to Information !echnology)
(-ommon to +E (Partc!ime) #ourth %emester Regulation 788B)
!ime = !hree hours Ma1imum 7 488 mar.s
$nswer $'' EuestionH P$R!
$c (48 17 M 78 nar.s)
4 'ist fi(e responsibilities of the D+ Manager
7 6i(e the limitations of E-R model 2ow do you o(ercome thisK
< Define Euery language 6i(e the classification of Euery language
C :hy it is necessary to decompose a relationK
B 6i(e any two um antages of sparse inde1 o(er dense inde1
9 *ame the different types of Doins supported in %&'
; :hat are the types of transparencies that a distributed database must supportK :(hyK
F :hat benefit is pro(ided by strict-two-phase loc.ingK :hat are the disad(antages resultK
L +riefly write the o(erall process of data warehousing
48 :hat is an acti(e databaseUK
P$R! + c (B 1 49 M F8 mar.s)
44 (a) (i) :hat are the types of .nowledge disco(ered during data miningK E1plain with suitable e1ample
(ii) 2ighlight the features of obDect oriented database (F)
0r
(b) (i) :hat is nested relationsK 6i(e e1ample (F)
(ii) E1plain the structure of GM' with suitable e1ample (F)
47 (a) (i) -ompare file system with database system (F)
(ii) E1plain the architecture of D+M% (F)
0r
(b) (i) :hat are the steps in(ol(ed in designing ' database applicationK E1plain with an application (48)
(ii) 'ist the possible types of relation that may e1ist between two entities 2ow would you resist that into
tables for a binary relationK (9)
4< (a) (i) :hat are the relational algebra operations supported in %&'K :rite the %&' statement for each
operation (F)
(ii) ,ustify the need for normali/ation with e1amples (F)
0r
(b) (i) :hat is normali/ationK E1plain I*#5 7*#5 <*# and +-*# with simple e1ample (F) [
(ii) :hat is #DK E1plain the role of #D in the process of normali/ation (F)
4C (a) (i) E1plain the security features pro(ided in commercial Euery languages (F)
(ii) :hat are the steps in(ol(ed in Euery processingK 2ow would you estimate the cost of the EueryK (F)
0r
(b) (i) E1plain the different properties of inde1es in detail (F)
(ii) E1plain (arious hashing techniEues5 (F)
4B (a) (i) E1plain the four important properties of transaction that a D+M% must ensure to maintain
database (F)
(ii) :hat is R$IDK 'ist the different le(els in R$ID technology and e1plain its features (F)
0r
(b) (i) :hat is concurrency controlK 2ow is it implemented in D+M%K E1plain (F)
(ii) E1plain (arious reco(ery techniEues during transaction in detail (F)
+E)+!ech DE6REE EG$MI*$!I0*5 *0VEM+ER)DE-EM+ER 7889
#irth %emester
-omputer %cience and Engineering
-% 4<84 c D$!$+$%E M$*$6EME*! %?%!EM%
(-ommon to Information !echnology and +E Partc!ime R 788B #ourth %emester)
(Regulation 788C)
!ime = !hree hours Ma1imum = 488 mar.s
$nswer $'' Euestions P$R!
$ c (48 1 7 M 78 mar.s)
4 -ompare database systems with tile systems
7 6i(e the distinction between primary .ey -andidate .ey5 and super .ey
< :rite a %&' statement to find the names and loan numbers of all customers who ha(e a loan at -hennai
branch
C :hat is multi(alued dependency K
5. <i*e the meas#"es o-the O*.JiC* o- a dis/.
9 :hat are the two types o\ udered indicesK
; 'ist out the $-ID properties
F :hat is %hadow Du giagK
' L -ompare D+M% ersus obDectcoriented D+M%
48 :hat is data warehousingK
P$R! + c (B 1 49 M F8 mar.s)
44 (a[) (ii) Describe the system structure of a database system (47)
(ii) 'ist out the functions of a D+$ (C)
0r
(b) (i) Illustrate the issues to be considered while de(eloping an ER-diagram (F)
(ii) -onsider the relational database
employee(empname street5 city)
wor.s(einpname companyname5 salary)
company(cornpanyname5 city)
rnanages(ernpname5 managername)
6i(e an e1pression in the relational algebra for each reEuest=
(4) #ind the names of all employees who wor. for #irst +an. -orporation
(7) #ind the names5 street addresses5 and cities of residence of all employees who wor. for #irst +an.
-orporation and earn more than 788888 per annum
(<) #ind the names of all employees in this database who li(e in the same city as the company for which
they wor.
(C) #ind the names of all the employees who earn more than e(ery employees of %mall +an. -orporation (C
17 M F)
47 (a) (i) Discuss about triggers 2ow do triggers offer a powerful mechanism for dealing with the changes
to a database with suitable e1ampleK (48)
(ii) :hat are nested EueriesK E1plain with e1ample (9)
0r
(b) (i) :hat is normali/ationK 6i(e the (arious normal forms of relational schema and define a relation
which is in +-*# and e1plain with suitable e1ample (47)
(ii) -ompare +-*# re ]s]4s <*# (C)
4< (a) (i) Describe 'ent R$ID le(els (48)
(ii) E1pla[= (liy allocations of records to bloc.s affects database system perl uinance significantly (9)
0r
(b) (i) Describe the structure of +t tree and gi(e the algorithm for search in the +3 tree with e1ample (47)
(ii) 6i(e the comparison between ordered inde1ing and hashing (C)
4C (a) (i) E1plain the different forms of %eriali/ability (48)
(ii) :hat are different types of schedules are acceptable for reco(erabilityK (9)
0r
(b) (i) Discuss on twocphase loc.ing protocol and tin4cstampcbased protocol (47)
(ii) :rite short notes on logcbased reco(ery (C)
4B (a) (i) Discuss in detail about the obDect relational databases and its ad(antages (F)
(ii) Illustrate the issues to implement distributed databases (F)
0r
(b) (i) 6i(e the basic structure of GM' and its document schema (F)
(ii) :hat are the two important classes of data mining problemsK E1plain about rule disco(ery using those
classes (F)
+E)+!ech DE6REE EG$MI*$!I0*5 *0VEM+ER)DE-EM+ER 788;
!hird %emester
-omputer %cience and Engineering
-% 7<C c D$!$+$%E M$*$6EME*! %?%!EM%
!ime = !hree hours Ma1imum = 488 mar.s
$nswer $'' Euestions P$R!
$ c (48 1 7 M 78 mar.s)
4 :hat is physical data independence and why is it importantK
7 Define the concept of aggregation 6i(e two e1amples of where this concept is useful
< %tate the (arious operators used in relational algebra
C :hat is the need for triggers in %&'K %tate its usage
5. :hat is o"de"ed inde?j <i*e +T.1k.iC;'l.
9 Define tri(ial functional Dependencies
; :hat are the steps in(si( ei in Euery processing
F Distinguish between time stamp based protocols and loc. based protocol
L -ompare 0'!P and 0'$P
48 :hat are d(tn Il agmentatiorisK %tate the (arious fragmentations with e1ample
CS1254 DATABASE MANAGEMENT
SYSTEMS
18
0
P$R! + c (B 1 49 M F8 mar.s)
44 (a) (i) Differentiate between hierarchical5 networ.5 relational model with e1ample (F)
(ii) E1plain clearly the steps in(ol(ed in database de(elopment process while building an applicationK (F)
0r
(b) (i) :hat are the main differences between a file-processing system and a D+M%K %tate the
disad(antages of D+M% (F)
(ii) E1plain the distinction among the terms primary .ey5 foreign .ey and super .ey with a suitable e1ample
(F)
47 (a) (i) :hat are the (arious aggregate operators does the %&' support 6i(e a suitable e1ample for each
aggregate operator (F)
(ii) ,ustify the need for static %&' and dynamic %&' -onsider the relation Employee (empno name5 age5
salary) :rite a embedded %&' statement in - language to retrie(e all the employee record whose salary is
between 485888 to 78888 (F)
0r
(b) -onsider the employee-company relation :rite %&' statement for the following Eueries (C 1 C M 49)
Employee-company relation =
employees(personIname5 street5 city)
wor.s(personIname5 con]ipanyIname5 salary)
company(c8mpanyIname5 city)
manages(personIname5 managerIname)
(i) #ind all employees in the database wl o li(e in the same cities as the companies for which they wor.
(ii) Modify the database so that da(id now li(es in Mumbai
(iii) #ind all employees who are under the mana0e"
CDohn
l(i() 6i(e all mangers in the database a 48V percent raise
4< (a) (i) Draw the ER diagram 4 for the abo(e gi(en EmployeeIcompany relation (F)
(ii) :hat is the difference between primary inde1 and secondary inde1K (F)
0r
(b) %tate the goal of decomposition)normali/ationK E1plain the different le(el of normali/ation with
e1ample
CS1254 DATABASE MANAGEMENT
SYSTEMS
18
1
4C (a) (i) :hat are the different drawbac.s in concurrent usage of databaseK (F)
(ii):hat is the difference between implicit and e1plicit loc.ingK E1plain in detail with e1ample (F)
0r
(b) (i) 2ow do D+M% bac. out the changes made to database if a system failure occurs during the middle of
transaction (F)
(ii) 'ist the $-ID properties E1plain the usefulness of each (F)
4B (a) (i) E1plain two important classes of data mining problems in detail with e1ample (F)
(ii) E1plain the feature of distributed database system 'ist out some application of distributed database
system (F)
0r
(b) (i) -ompare 0bDect-0riented (ersus 0bDect-Relational database %tate with suitable e1ample (F)
(ii) Describe the (arious component of data warehouse and e1plain the multidimensional data model with
e1ample (F)