Database Key Concepts Explained
Database Key Concepts Explained
DotoboseNormolizqtion
5.1 KEY'-                                                W Thereis only oneprimarylceyin a table.But there
A key is that data item that exclusively identifies a                            keys.
                                                           canbemultiplecandidate
record. For example, Account-number,Product-code,
Employee_numberand Customer-numberare used as
key fields becausethey specifically identify a record
stored in a database.                                    5.1.4 CompositeKey
                                                         In many cases,aE we design a database,we will
5.1.1SuperKey                                            have tablesthat will use more than one column as
A. Super Key for hn entity is a set of one or more       part of the primary key. Theseare called Composite
attributes whose combined value uniquely identi-         Keysor (concatenatedkeys).In other words, when a
fies the entity in the entity set. For example, for an   record cannot be uniquely identified by a single
entity set Employees, the set of attributes              field, in such casesa compositekey is used.A com-
lemp-name, address) can be considered to be a            posite key is a group of fields that are combined
super kep if we assume that there are no fwo             togetherto uniquely identify a record.
employees with the same emp-name as well as the
sameaddress.                                             5.1.5 SecondoryKey
5.1.2 Primory
            Key                                          A Secondary   Key is an attribute or combination of
Theprimary key uhiquely identifies eachrecordin a        attributesthat may not be a candidatekey but clas-
tablg and must never be the same for two records.        sifiesthe entity set on a particular characteristic.For
For example,emp_codecan be primary key for the           example, the entity set EIvIPLOYEEhaving the
entity set Employees.                                    attribute Department,which identifies by its value
  The primary key should be chosensuch that its          which means all instances of EMPLOYEE who
attributes are never or very rarely changed. For         belongto a given department.
mstance,the addressfield of a personshould not be           More than one employeemay belong to a depart-
part of the primary key, sinceit is likely to change.    ment, so the Departmentattribute is not a candidate
Emp_code,on the other hand, is not changed,till he       key for the entity set EMPLOYEE,since it cannot
is working in the organization.                          uniquely identify an individual employee. How-
                                                         ever, the Departmentattribute does identify all
@ Theprimary kty of a relationcan be said to be a        employeesbelonging to a given department.     Hence,
                                                         it canbe consideredas a secondarykey.
  minimalsuperkey.
                                                         5.1.6 Forgign Key
5.1.3 CondidoteKey                                       In a relation, thg column whose data values corre-
A CandidateKey is an attribute o4 set of attributes      spond to the values of a key column in anotherrela-
that uniquely identifies a record. These attributes or   tion is called a ForeignKey.The supp_codekey is a
combinations of attributes are called candidate keys.    ForeignKey as seenin Figure 5.1.
ln such a case, one of the candidate key is chosen to
                                                         @   ly1a relational database,theforeign key of a relation
be a primary key.The remaining candidate keys are
called Alternate keas.                                       may bethe primary key of anotherrelation.
50                                                       Introductionto Dotobose Monogement System!
                                                       Employee                                Item
                                                       name                                    number
                                       2l 130680Anand K               Downtown    Hardware     TRIO     Router
                                                                                               sAl      Saw
                                                                                               PT6      Drill
                                                                                               A B 1 6 Lawnmover
                                       30142101 Zadoo S              Dadeland     Home       TTI        Humidfier
                                                                                  appliances
                                                                                               D S I O Dishwasher
                                       41984620 Balwant              Cutter point Auto parts   MCl6 Snow tire
                                                                                               AC146 Alternator
                                                                                               BBIOO Battery
                                       6t2w12l Bhagwan Fashionspot Men's                       HSl0     Suit
                                                                                  clothing
           SalesD€rson
                     Data File
                                                                                 5.5 FUNCTIONAT
                                                                                             DEPENDENCIES
                                                                                 Functional dependencies play an important role in
                                                                                 differentiating good dar:abase design from not to
            2l l 30680      TRIO        Router
                                                                                 good database design. Frunctional dependencies ere
            21130680        SAI         Saw
                                                                                 the consequence of the interrelationships amonl]
            2l 130680       Pr6         Drill
            21130680
                                                                                 attributes of an entity rcpre$ented by a relation.
                            AB16        Lawnmover |      245.@
            30142r01       Trl          Humidfier I      I14.00
                                                                                 Alternatively, it may be due to the relationsl"rip
            3014210r        DSI$                                                 between entities that are also represented by a rela-
            4l tr84{i2!i        I r!
                            !v1,.-:                                              tion. Given a relation R, atrl..ibuteY of R is function-
            +1e84620       4.C146                                                ally dependent on attribute X of R if and only if each
            4t984620       Bg loc                                                X-value in R is associatecl with it precisely one
            6t2o.l"72l     HSl0                                                  Y-value in R.
     For example,considerthe following relation EMP:          Join dependencyis a constraint, similar to a Func-
                                                              tional Dependencyor a Multivalued Dependency.            It
           ENAME        PNAME        DNAME                    is satisfiedif and oruv if f irc relation concernedis the
           Rajan           X         Ganesh                   join of certain nurnber i:f projectiuns.And therefore,
           Ramesh          Y         Dinesh                   sucha constraintis caliecta join dependency.
           Ram             X         Babu                       We now considera specialclassof join Cependen-
           Arjun           Y         Baskar
                                                              cieswhich help to capru]redata dependencieslpres-
      A tuple in this EMP r,elation repreqentsthe fact        ent in a hierarchicaldata structure.Fr:r exarnplie,     in
    that an employer whose name is ENAME works on             the N{.JRS*HOMEdal"abrse shorr.n in t'..ig*re$.9"
    the project whose name is PNAME and has a                 data has an inherertt hiErarchis:ai       ,rr:galtizaei.rrr,
                                                                                                                       it
    dependentwhose narne is DNAME. An employee                implies that informatiron regartiing lvardru;and
    may work on severalprojectsand may have several           patients currently admitlcd tn "r rvarti depenclil.iiy
l,crtoboseNormolizotion                                                                                      55
         NORMAIFORM(2NF)
5.6 SECOND
                                                                 NORMATFORM(3NF)
                                                         5.7 TH|RD
A table is in the SecondNormalForm tf all its non-key
ields are fully dependent on the whole key. This         A table is sa-idto be in the Third Normal Form, if all
-xeans that each field in a table, must depend upon      the non-key fields of the table are independent of all
rhe entire key. Those that do not depend upon the        other non-key fields of the table.
;ombination key, are moved to another table on             In Figure 5.10 we can observe that there is further
rvhosekey they depend on. Structureswhich do not         room for improvement. In the salespersondata file,
contain combination keys are automatically in the        the attribute "Store branch" is tagged to the primary
-cond normal form.                                       key "Employee#" while the attribute "Department"
EC
                                                                      rn+rndg6tisn
                                                                      il ilt\    to DotoboseMonogementSyst
J9
                                                  Data File
                                        Salesperson
                                 /
                                     Employee#
                                                 /
                                                     Item #     Saleprice(Rs.)
                                                                                           r'Item #    Item description
                                           Item File
                                 Salesperson                                               ltem File
 which is a non-key attribute is related to "Store                 (b) Goes.to the employee data file to look up the
 branch," which is another non-key attribute. Mak-                     store branch to which the sales person is
 ing "Store branch" a key attribute requires isolating                 assigned.
 "Department" along with "Storebranch" and placing                 (c) Accumulates each galesperson'ssalesin a speci-
 them in a new table as shown in Figure 5.1L.                          fied field in the store branch file.
    Note that, after completing the third normaliza-                 This procedure is repeated for each salespersonin
 tion, we can store branch information independent                 the file" Figure 5.12 illustrates the processing cycle
 of the salespersonsin the branch. We can also make                for salesperson21L30680.
 changes in the "Department" without having to
 upciate the record of the emPloyee in it. In this                   us 4 rcIationis in thethird normalform if it is in sec-
 respect, normalization simplifies relationships and                    ond normslform and no non-primeattributeis
 provides logical links between files without losing                    functionally dependent on other non-prime
 information.                                                           attributes.
    One inherent problem with normalization is data
 rtdundancy. For store branch, the system goes
 tlrrough three steps:                                               5.8 BCNF(BOYCE-CODD
                                                                                       NORMALFORM)
 (a) Computes total sales for each salesperson from
      the salespersonitem file.                                      Boyce-CoddNormal Form (BCNF) was proposed as
                                                                                                              57
lc':cose Normolizotion
Saleprice(Rs.)
                                             Item File
                                   Salesperson
                                                     Downtown         DowntownHardware
                                                     Dadeland         Dadeland Homeappliances
                                                     Cufierpoint     Cutterpoint Autoparts
                                                     Fashion
                                                           spot      Fashion
                                                                           spot Men'sclothing
                             Salesperson
                                      DataFile
                               Y
                                Employee
                                          Y
                                      # Item#     Salepdce(Rs,)
                                                                              rItem#    Ihm description
                                2l 130680 TRIO           35.00-l               TRIO Router
                                                             I
                                21130680 s A l           re.00
                                                             I)                sAl      Saw
                               2t130680 P r 6            2r.00
                                                             |                 PT6      Drill
                                                               I
                               21130680 ABI6            245,N
                                                            )                  A B I 6 Lawnmover
                               30142101 T T I           I t4.00                T't I    Humidfier
                               30tarcl     DSl0         262.N                  DSt0 Dishwasher
                               4t984620 MCl6             85.00                 MCl6 Snowtire
                               41984620 ACl46            65.00                 AC146Alternator
                               41984620 BBIOO            49.50                 BBIOOBatlery
                               6lm472l HSl0             215.N                  HSl0 Suit
                              Salesperson
                                      ltemFile                               ItemFile
    Table 5.1 The GRADE relation                               Fourth Normal Form eliminates casesin which the
Name        Student# Course Grade                            composite key of a record type contains two or more
James       23714539    353    A                             data items that are independent, multivalued facts
Neelam      427Lrc9A    329    A                             of an entity.
Iames       237'14539   328 in prog                            The fields are independent if there are no combi-
l,lohan     38815183    456    C                             nations that are logically related.
i.tiip      37116259    293     B
i;-eepraf
                                                               In the example given in Figure 5.13, skill and lan-
            82317293    491    C
f.}eepak    823L7293    353 in prog                          guages are multivalued (many different skills and
farnes      23714539    491    c                             many different languages), but there is no logical
ikj         11011978    353   A+                             dependency between a language and a skill.
Vikas       $9LA827     379 in prog                            To put it in Fourth Normal Form, the data mustbe
                                                             separated by creating two separate tables.
DotoboseNormolizotion                                                                                          59
n-nnormalized Data:                                        In the 2NF the element depending. upon the whole
-;;t-no                                                    key and partial key are separated and formed into
                                                           new data structure'
l;,:i_name                                                                                          2
:.: jr
]:.l.er_no                                                      *Cust-no                       *I{em no Ddsc Rate
                                                                                   Qty
]:er-date
le-i_date
-:t::-.-no
                                                                                    2
                                                                           ."i*" *t*,."10*
-<:!
i;:e
                                                                  2
Step2                                                                            *Order-no Order-date Deli-date
                                                           .."[*;rder-no
l:.e First Normal Form (1NF) is any data structure
-^,:irout repeating groups. So to achieve First
                                                                        2
                                                           5.I4 CASESTUDY
\:':mal Form, remove all repeating grouPs. In this
:uinple, Item-no, Desc,Rate,Qty etc. repeats with          Normalize the following data of personal employees
=:ch customer.                                             table to 3NF using appropriate relations' Note that
                                                                                     *'
lhe primary key from the original structure is to be       key fields are denoted bY
:r,-rrght into repeating grouP structure' Also the key     Unnormalized Data
::e-l from the new structure (repeating group) is to
                                                               PersonalEmPloYeeTable
:e found out. The new structure is named with
                                                           * Emp-code      EmPloYeecode
 ::rropriate name.
                         L                                  Dept-code      DePartmentcode
                  I
                                                            Mgr-code       Manager code
                    IL
                 *Itbm-no                                   Course-code Coursecode
       tust-no            Desc RateQtY
                           1                                Course-title Coursetitle
      =                                                    Solution
 5l:st-no Cust-nameAddr Order-noOrder-datJDe[-date
                                                           Step 1
                                                           the first stage of normalization is to remove all
 @ Notethat* denotes
                   keyfieldfor an entity.
                                                           repeating groups. So there are two tables;employee
                                                           table and training table, with the key field
 -:r the first file structure Cust-no is the main key or   Emp-code appearing in each.
 i^,e primary key and ltem-no is the partial or
                                                            First Normal Form (1NF)
 =e.-ondarykey.
 Step3                                                       Employeetable Trainingtable
                                                            * Emp-code       *EmP-code
 li.e Second Normal Form (2NF) is a data structure                           *Course-code
                                                             Dept-code
 -: n'hich all non-key data elements are fully func-
                                                             Mgr-code         Course-title
 :rnally dependent on the primary key' If a relation
 *. 1NF then we can go for its 2NF. In the 2NF we           Step 2
 .ook for Functional Dependence. For exarrtpLe,Desc         In Second Normal Form (2NF) we have to remove
 :: item is dependent on ltem-no, Rate is dependent         partial key dependencies. This is done by examining
  :n ltem_no.                                               lhore tecotds possessinga compound key (i.e. a key
 Similarly, Cust-name is dependent on Cusf-no, cus-         comprising more than one item) and checking to see
 :Jmer Addr is dependent on Cust-name and so on'            whether each data field in the record relates to the
 '-\-e                                                      whole key. If the field relates to only part of the key,
       group such functionally dependent attributes
 :nd achieve 2NF.                                           it is removed with its key to form another table. In
62                                                         introductionto Dqtobose Monogement Systems
the above example Course title relates only to           3. The relation is said to be in           when every
Course_code, so it is removed ' with its key to form        non-key attribute is fully functionally dependent
another table as Course table.                              on the primary key.
Second Normal form (2NF)                                 4. -is           stricker than 3NF.
                                                         5. Every relation  in BCNF is also in -.
Employeetable Training table Coursetable
*Emp-code     *Emp-code      *Course-code                6. \A/henall non-key attributes are dependent on the
 Dept-code    *Course-code    Course-title                  kev attribute. it is called           dependencv.
Mgr_code
                                                         7. A functional dependency is denoted by
                                                                        between two sets of attributes x and y.
Step 3                                                   8. When one non-key attribute depends on other
                                                            non-key attribute, it is called a -         depen-
in Third Normal Form (3NF) involves examining
each record to see whether any items are mutually           dency.
dependent. In this example, Dept_code and Mgr
                                                         Answer
-code are mutually dependent because the manager
of each department will always be the same. Thus         1. Normalization     2. 1NF          3. 2NF
new table department is being created for depart-        4. BCNF              5. 3NF          6. Full
ments, the key being Dept-code. Now data is com-                                                 functional
pletely norrnalized.                                     7. x-+y              8. Transitive
Third Normal Forrn (3NF)
                                                                              EXERCISE
 Employeetable         Training table
*Emp-code              *Emp-code                                   Note: Answer all questions.
Dept-code              *Course-code
                                                          1. Define Normalization and why is it done?
                                                          2. Explain Third Normal Form (3NF) with an
 Department table      Course table
*Dept-code            *Course-code                           example.
Mgr-code               Course-title                       3. With the help of an example, what do you
                                                             understand by Boyce Codd Normal Form.
                                                             How does it differ from Third Normal Form.
REVIEW
     OUESTIONS
            WITHANSWERS                                   4. Write short note on:
                                                             (a) Denormalization
Fillintheblonks                                              (b) Fourth Normal Form.
1.--          is the processof grouping the data             (c) TransitiveDependency
  item elernentsin the tuple representingentities            (d) MultivaluedDependencies
  and their relationships.                                5. Explain Partial Dependency with an example.
2. When a table has no repeating groups, it is said to    6. What is join dependencies? Explain with an
   be in                                                     example.
)otobase Normqlizotion                                                                                                          63
                                                 :
                                               T(FST PAPERJ,B
Inlroduclionto DotaboseMoncgementSyslems
      a. To identify uniquely an entity in the entity     3.4 Virtual tables              d. Primary key
          set                                                                                values
      b. To make the key most powerful for faster         3.5 Weak entity set             e. User views
         retrieval
                                                          3.6 Fourth normal form          f. Inheritance
      c. To increaseeffectivenessof databaseaccess
      d. None of the above                                3.7 Referential                 g. Domain calculus
 1.17 A table is in 2NF if it is in 1NF and if                constraints
      a. No column that is not a part of the primary     3.8 QBE                          h. SUM
         key is dependent on only a portion of the       3.9 Update anomaly               i. Foreignkey
         alternatekey                                    3.10 Union rule                  j. First normal form
      b. No column that is not a part of the primary                                      k. Secondnormal
         key is dependent on only a portion of the                                           form
         primary key                                                                      l. QUEL
     c. No column that is not a part of the primary
         key is dependent on only a portion of the        4. Fillin the blonksout of the foilowing:
         foreign key                                          a. aggregation b. primary key     c. Relational
     d. None of the above                                     d. attributes e. record           f. schema
                                                                                  replication
 2. SeleclTRUE or FATSE
                      in the foflowing                       g. root           h. foreign key     i. Normaliza-
    slotemenls                                                                                       tion
 2,1 A weak entify set has a primary key.                    j. BCNF          k. subschema        L data
 2,2 Every weak entity set can be converted into a                                                   dictionary
                                                        4.1 A view of the database that appears to an
      strong entity set by adding appropriate attrib-
      utes.                                                  application program is known as
 2.3 A candidate key can be a subset of a super key,    4.2 If relation is in _,           it is in 3 NF also.
 2.4 Many-to-many relationship between two enti-        4.3 _            represents relationship between the
      ties can be representedby two DBTG sets.              tables.
 2.5 In a relational database, the foreign key of a     4.4 -is                the name given to the process
     relation would be the primary key of an                of simplifying the relationship among data ele-
     another relation.                                      ments in a record.
 2.6 Boyce-Codd Normal Form is also in Third nor-       4.5 Complex entities can be constructed using the
     mal form.                                                            operation.
 2,7 The subschema must contain all the descrip-        4.5 In a relational data model the columns of a
     tion of certain data that are in the scheme.           table are called
 2.8 Codd gave 12 rules for any RDBMS to be             4.7 In a hierarchical database,modeling of many-
     acceptedas a full fledged RDBMS.                       to:many relations is achieved by --.
2.9 Aggregation operation is used to construct          4.8 h a hierarchical database,a hashing function is
     complex entities.                                      used to locate
2.10 An E-R model uses doubly outlined rectangle        4.9 E-R model is used to describe
     to represent weak entity set.                          model.
                                                        4.10 .---         containsthe structureof the data-
3. Motchwords/phroses
                    in the two columns                       base.
3.1 Specialization             a. Functional depen-
                                  dency
3.2 Aggregation function       b. Multivalued
                                                        PARTil (DESCR|PT|VH  QUESTTONS
                                  dependency            to be answeredin 2 Hours)
3.3 Entity integrity           c. Doubly   outlined     Q. 1 What do you mean bv integrity and Referential
                                  box                        Integrity? Explain with example.
Jotcbose Normolizotion                                                                                          65
                       ANSWERSTO (DESCRIPTIVE
                                            QUESTIONS)
Ans.1         Entitylntegrity:
              if an attribute of a table is prime attribute (unique identifier), it can not acceptnull values, i.e.,
              no component of a primary key values may be null.
              Referenliollntegrity:
                                                                                        will also
              To ensurethat J valuewhich appearsin onerelationfor a givensetof attributes
              appear for certain set of attribuies in another relation. This condition is called as referential
              integrity,
Ans.2                 File ProcessingApproach                           Database ProcessingApproach
         (a) Redundancy in defining and storing data                 In the database approach a single reposi-
             which results in wastage of storagespace.               tory of data is maintained that is defined
                                                                     once and then can be accessedby many
                                                                     users.
         (b) Data definition is typically part of the                DBMS software can access diverse data-
              application programs themselves and                    basesby extracting the databasedefinition
              hence file-processing software can access              from the system catalog and then using
              only specific database files.                          this definition.
          (c) The structure of data files is embedded in             DBMS access-programs are written inde-
              the accessprogralns, so any changes to the             pendent of any specific files. The structure
              structure of a file may require changing all           of data-files is stored in DBMS catalog
              programs that accessthis file.                         separately from the access-program.This
                                                                     property is known as program data inde-
                                                                     pendence.
         (d) Does not support multiple views of same                 Supports the multiple view of same data.
             data.
         (e) Data for rnuitiple application may not be               A multi-user DBMS allows multiple users
             integrated and is maintained in individual              to accessthe database at the same time. So
             files.                                                  the data for multiple operations is inte-
                                                                     grated and maintained in a single central
                                                                     database.
06                                                    Introductionto Dotobos
Ans.3 Normalization is a Processof simplifying the        DBA has following role to PlaY:
      relationships between data elements in a            (a) Administering the primary source, data-
      record.                                                  base and the secondary source, of DBMS
      Normalization is carried out for the follow-             is the responsibility of the database
      ing four reasons:                                        administrator (DBA).
      (a) To structure the data between tables so         (b) Designs the database security system to
           that data maintenanceis simplified'                 guard against unauthorized use by allo-
      (b) To permit simple retrieval of data in                cating password to each user.
           responsequery and report requests'             (c) Co-ordinates working of individuals
      (c) To simplify the maintenance of data                  making      file modifications, policy
            through updates, insertion and dele-               changesand improvements to database.
            tions.                                        (d) He protects databases from physical
       (d) To reduce the need to restructure or re-            harm by supervising the creation of
            organise data when new application                 backup copies and establishingfall back
            requirements arise'                                 procedures.
Ans.4 The person who is responsible for the oPeral         (e) Acts as a file designer and databasecon-
       tion and maintenance of DBMS is called                   sultant to other users in the organiza-
       Databaseadministrator.                                   tion.
                                             lt
                                         ,4ft'nAPrER
                                                   6
                         Relotioncll
                                  Algebrosnd
                          RelotionqlCslculus
6.I RELATIONAL
            ALGEBRA                                      amount is say more than Rs 7000/- by writing the
ic:::ronal algebrausesa procedural query language        foilowing:
 n*:-;h is a collection of operations to rrtanipulate    oBalar,.e,
                                                                  7ggg(Deposit)
-:lJrurRS.It consists of a set
                               of such operations that    In general, H'e allow cornparisonsusing relational
:i-q<inc or more relations as input and produce a       operators (.=, *, 1, 1, ), ) ) in a selection predicate.
-E1\-:elation as their result.
                                                        Futhermore, we can comhine severalpredicatesintcr
                                                        a larger predicate by using the logical connectioir
6.2 RELATIONAL           ATGEBRAIC     OPERATIONSnamely AND (a), OR (v) and NOT (.-) operators.
ic-::ional algebraic operations can be divided into       Consider another example. Suppose we r,vant
::";-; set-oriented operatiofis like union, difference, tuples which contain the faculty name "Pooja"who
Lr:=:>ection, cartesian product and relational-         teachesRDBMS, from relation (tabie) Teach,then we
:r.=:.ted operatir:ns like join, selection, projection, may write the query as follows:
:-' :sion etc. We shall understand various opera-
-- ..--.of relational algebra                           o N"me = ,,pooja,,r
                                                                         Courss= "RpgNag,'(Teach)
                              one by one.
     Emp-No Emp_name
      101     Rita                                       IEF lr/efg that there are only two emplayeeswho are
      103     Ritu
      104     Setu
                                                             workingon projectI'1,andalsoonproject12.
      105     Isha
      106     Leela
      '1,07                                              CrossProduct(Caileslon Product)
              Neena
      l'1,2   Seema                                      Crossor Cartesianproductis denotedby X x Y and
ks-onol Algebroond RelotionolColculus                                                                         6S
                                                         EquiJoin
                                                         Whentwo tablesarejoinedtogetherusingequality
          106   Leela                                    of valuesin oneor morecolumns,theymakeanEqui
          707   Neena                                    ioin.
  lhe operation X x Y gives the resulting combina-       B       ln equijoin, thecomparisonoperator= is only used.
r.crs as follows:                                                Theresult of an equijoin will alwayshapeoneor
                                                                 morepairsof attributesthat haaeidenticalaaluesin
                                                                 eaerytuple.
    Emp_No Emp_name            Project
         101    Rita            AXlO
         101    Rita            AX11                     Theto(o).loin
         103    Ritu            AXlO                    A generaljoin condition is of the form:
         103    Ritu            AX11                    <Condition>AND <Condition>AND....AND
         104    Setu            AXlO                    <Condition>
         104    Setu            AX11                      where eachCondition is of the form A; 0 8,, Here,
         106    Leela           AXlO                    A, is an attribute of relation X. B' is an attribute of
         106    Leela           AX11                    relation Y. Here A; and B, have ihe same domain.
         107    Neena           AXlO                    The greek letter 0 (theta) is one of the comparison
         107    Neena           AX11                    operators(=, 1, 3, ), 2, *). A join operationwith such
                                                        a general join condition is called a Thetaioin. By
                                                        theta join, tupXeswhose join attributes are null do
@ Notethat abouecommands          will giaeall combina- not appearin the result.
     tions of employe,es working on projectAX1.0and
     alsoonproject4XL1.                                  Natural Join
                                                        Lr the nafural join also, the comparisonoperatoris
                                                        always the equality operator =, but only the equi
6,2.4 DifferenlTypesof Joins                            join contains two identical columns from the rela-
lte  join operator  (><), allows to combine   two rela- tion being joined. It is of coursealways possibleto
::ns to form a single new relation. The tuples from     eliminate one of those two columns via the Proiect
:.€ operand relations that participate in the           operation(n). ,An equi join with one of the two iden-
;,:eration and contribute to the result are related.    tical columns eliminated is called a natural join.
lle join operation allows the processing of relation-   Thus, natural join will also give a new table that
;,r-rpsexisting between the operand relations.          doesnot have any duplicate columns.
r, r n
                                                                                  to Dotobose Monogemenf Systems
                                                                      IntrorCuciion
    he condition supr,oyEE(t) specifies that the           such tuple. The conditions Erffrl-oyee(r) and
 $nges relation of table variable f is employee. Each      DeBartment (d) indicate tire range relations for t,
 l'*'-:loyee tuple f that specifies the condition          and d. The condition:
 : " -:-tri,ARY
              > 5500 will be retrieved.                               d.Dept_Nam€      ='rReEearch"
  lhe above query retrieves all attributes values for      is a selection condition and corresponds to a
*:::r selected EMPLOYEE tuple f. To retrieve only          SELECT operation in the relationai aigebra. The
';ne of the attributes, we write:                          condition:
  {r.Ertl)_Nams, I"SAIJARY I EMPLOYEE(L) and,                        d.Dept_Code = t.Dept_-Code
        T . SAIJARY > 55OO }
                                                           is a join condition and serves a similar purpose to
   - r-LlS   construct is equivalent to following   SQL    the join operation.
  .q.E.ECT T.ErF_rram€,
                                                           W Theonlyfree tupleuarinbles      in n relational
                                                                                                          calculus
                        T. sala4/
  rROM EMPIJOYEE T                                           expression      shouldbe thosethat appenrto theleft of
  XEERE T.SAXTARY > 55OO                                     t h e b a(rl ) .
Erample7
lle tuple relational calculus query to retrieve the        6"4.5 SofeExpressions
;:e of joining and designation of the employee             Whenever we use universal quantifier (V), existen-
-r{rosename is "RAJ" is given by:
                                                           tial quantifier (!) or negation (-) of predicatesin a
  ir.Doj,        r.Desig    I wnlorrE(t)    and            calculus expression, we must make sure that the
    t.ErD_Nane        E trPlJ'n)                           resulting expressionassuressorneresults"
   ln fuple relational calculus, we first specify the        A safe expression in a relational calculus is one
:riuested attributes for each selected tupie f. Then       that is guaranteed to yield a finite number of tuples
,,.e specify the condition for selecting a tuple fol-      as its resulf otherwise the expression is called
,:if ing the bar ( | ) - namely that t be a tuple of the   unsafe.
:\iPLOYEE relation.                                          For exarnple,the expression:
                                                                        {t lnot (EMPT.OYEE     (t) ) }
6.4.4 Formuloin TupleRelafionolColculus                      is unsafe becauseit yields all tuples in a universe
i tormula (condition) is made up of one or more            that are not EMPLOYEE tupies, which are numer-
;:--'rrsconnected via logical operators (and,'or and       ous.
----:tanddefined recursively as follows:                     We can define safe expressionsmore precisely by
 : Every atom is a formula.                                introducing the concept of the domain of a tuple
 :' If Fr and F, are formulas, then so are (F, and Fr),    relational calculus expression.
     (F, or Fr),not (F) andnot (F).
                                                           GF Domain is the set of aII aaluesthat eitherappearas
   ln addition, two special symbols called quantifiers
::n also appear in formulas; these are the universal           constantaaluesin the expressionor exist in any
:'.rnatifier(V) and the existential quantifier (3).            tableof the relationsreferencedin the expression.
Suer'esUsingthe Existentiol
                         Quqntifier                          The domain of {t lnot (EMPLOYEE(I))}is the set of
j rt/e want to retrieve the Emp_Name and                   all attributes' values appearing in some tuple of ther
                                                           EMPLOYEE relation.
-np_Code of all employees who work for the
                                                             An expression is said to be safe if all values in its
 S.esenrch"
         Department, then the construct:
                                                           result are from the domain of the expression.Notice
iE,.ErE)_Name, t.HIq)_Code I EI'IPLOYEE(t) AI{D
 -d) DEPARTMENT(d) and Dept_narre = "Research"             that the result of {t lnot (EMPLOYEE (t)i is unsafe,
a.od d.Dept_Code = t.Dept_Code)                            since it will, in general include tuples from outside
r the above query, t is the only free variable. It is      employee relation.
ren bound successivelyto each tuple that specifies
:he conditions given in the query, and the attributes^     6.4.6 Quontifiersin SQI
E'p_Narn€ and nnp_Code are retrieved for each              The EXISTS function in SQL is similar to the exis-
l-
TEST PAPER 6
                   to DotoboseMonogementSyslems
        Introducfion
PARTt (OBJECTIVE       to be answeredin 60 Minutes)
               QUESTIONS
 l. Multiplechoice                                            b. Primary entity         d. Secondaryentiby
                                                         1.10 Which one of the following is an example of
1.1 If DI, D2,... Dn are domains in a relational
                                                              hierarchical database?
     model then the relatiein is a table which is a
                                                              a. Oracle                 c. DBII
     subsetof
                                                              b. Ingress                d. SYSTEM2OOO
     a. {D1", D2,.....Dn}      c. D1 u D2 u Dn
                                                         1.1L Which of the following in not a valid unary
     b. Dl x D2   x... Dn      d. Maximum {D1,D2 .'.
                                                              operation in the relational algebra?
                                  Dnl
'1...2                                                        a. Select                 c. Project
     If.E1 and E2 are relational algebra expressions,
                                                              b. Min                    d. Rename
     then n'hich of the fr:llowing is NOT a relationai
                                                         1.L2 rLelationalAlgebra is
     algebraexpression?                                                                                  query
                                                              a. Data definition Lan- c. Procedural
     a.E1uE2                   c. E1-E2
                                                                 guage                     language
     b. EI/82                  d. E1 x E2
                                                              b. Meta language          d. Non procedural lan-
L.3 Functional deperrdenciesare a generalisation                                           guaSe
     of
                                                         1.1"3Which one of the following is a binary opera-
     a. Key dependencies c. Database dependen-
                                                              tion?
                                  cres
                                                              a. Project                c. Rename
     b. Relational depen- d. None of these
                                                              b. Select                 d. None of these
         dencies
                                                         1.L4 Which clause from the following corresponds
1.4 The operation of a relation X, produces Y, such
                                                              to the projection operation of the relational
     that Y contains onlv selected attributes of X'
                                                              algebra?
     Such an operation is
                                                              a. From                   c. Where
     a. Projection             c. Union
                                                              b. Select                 d. None of these
     b. Intersection           d. Difference
                                                         L.15 Which one of tire clattse is useful in defining
1.5 The table generated on compilation of data
                                                              that notion of tuple variables?
     stored in language (DDL) are stored in                                             c. From
                                                              a. As
      a. Data abstraction      c. Data file
                                                              b. By                     d. None of these
     b. Data Dictionary        d. Meta data
                                                         1.15 The   intersect operation
 1.6 The following entities / attributes in a rela-
                                                              a. Automatically eliminates duplicates
      tional databaseshould not have null values
                                                              b. Automatically eliminates duplicates, if we
      a. Keys                  c. Variables
                                                                  provide all clausewith intersect.
      b. Iteiations            d. All of these
                                                              c. Never eliminates duplicates
 1.7 A view of databasettrat appears to an applica-
                                                              d. None of the ah.'r-e
      tion program is known as
      a. Report                c. Subschema
                                                          2. Select TRUEor FALSEin ihe following
      b. Structure             d. Scheme
                                                             slolements
 1.8 The first network databaseis
      a. Ingress               c. DBTGCodasyl             2.L The universal quantifier in relational caiculus
      b. DatabaseI             d. SAP                         can be implemented using the NOT EXISTS
 1.9 If entity X is existence-dependenton entity Y            constrttctin SQL.
      then X is said to be -                              2.2 For any two relations q and r
      a. Subordinateentify c. Dominant entiW                               q l l r = q l l ( ql l 4
                     ond RelotionolColcu,us
2..3 Any equi-join can be expressed using natural         3.10 Rows                  j. Storageorganization
     join and renaming operators.                                                    k. Foreignkeys
2,4 In a relational databasekeys are not allowed to
                                                                                     I. EXIST
     have null values.                                                                  Userviews
2.5 Complex entities can be constructed using
                                                          4. Fillin the blonksout of the following:
     aggregationrelationshiP.
2.6 If two sets of functional dependenciesF and G             a. Projection  b. Selection c.3
     are equivalent, then either F is a subset of G or        d. Cardinality e. Duplicate f. Superkey
     G is a subset of F.                                      g. Foreign key h. Subordinatei. Keys
                                                                                entity
2.7 Projection of relation X, produces a relation Y
                                                              j. Attributes  k.*            l. Meta data
     such that Y contains only selectedattributes of
                                                              m. Three       n. division    o. cartesian
     X.
                                                                                            product
2.8 The functional dependenciesX -+ Y and YZ -+               p. union       q. composite r. integrity
     W, imply the functional dependency XZ -s W.                                               constraints
2.9 JOIN createsa new databasefile by joining two             s. weak entity t. specializa- u. partitioning
     or more databasefiles.                                      set             tion
2.10 Only two files can be linked for a single SET            v.3            w. from
     RELATION command,
                                                          4.1 In the relational data model, the columns of a
2.11 Tuple relational calculus is declarative and             table are called
     procedural oriented language.                        4.2 The primary k"y index does not allow
2.L2 Selection, projection, union, difference, inter-                    data in a field.
      section and cartesian product operations for-       4.3              of relation X, produces a relation Y
      mulate a complete set of relational algebra.            such that Y contains only selectedattributes of
2.13 Domain relational calculus restricted to safe            X.
      domain expressionsin equivalent in expressive       4.4 In a relational data base --              are not
      power to the basic relational algebra.                  allowed to have null values.
2.14 ER diagram functions performed by a system.          4.5 The primary key of a relation is a minimal
2.15 Relational Calculus employs procedural way
      of stating queries.                                 4.5 In a relational database a referential integrity
2.16 QBE is based on the tuple relational calculus.           constraint is specified with the help of
l.17 Multiply is a relational algebra operation.
                                                          4.7 ANSI / SPARC report defined -             lev-
2.18 Equi-join is a natural join with duplicate col-
      umns eliminated.                                         els of architecture in a database.
                                                          4.8 The number of entities to which another entity
                    in two columns
 3. Motchwords/phroses                                         can be associated via a relationship set is
                                                               expressedas -              .
3.1    Key                  a. Attributes
                                                          4.9 If an entity X is existence-dependenton'entitv
3.2    ]oin                 b. Externalmodel
                                                               Y, then X is said to be ---.
3.3    View                 c. Singularset
                                                          4.1.0Data about data is normally termed as
3.4    Foreign key          d. NOT EXISTS
 3.5 Universal               e . Minimal set of attrib-   4.11 -              primitive set of operations is
     quantifiers                 utes that uniquely            needed to express division operation of rela-
                                 identifies a row              tional algebra.
 3.6   PhysicalModel         f. Natural join              4.12 The                operationis suitedto queries
 3.7   Network data model bo ' Joins table                     that include the phase "for all"'
 3.8   Null               h. Tuples                       4.13 The                operation allows to combine
 3.9   Virtual table       i. Referential integrity            information from any fwo relations.
I    76                                                                     Introductionto Dotobore Monoge.ent Syrt.
     4.14 A relation that is not part of logical model but           Q.4 \Alhatdo you mean by normalization?What
          is made visible to a user as a virtual relation is               are its advantagesand disadvantages.
          calleda(n) _,
                                                                     Q.5 Considerthe following relations
     4.15 A key consisting of more than one column is
                                                                          PROJECT(ProjectNo,Project_Name,Chiefl
          calleda(n) _.
                                                                          EMPLOYEE(EmpNo,EmpName)
     4;1,6A foreign key creates a(n) -...-             rela-              ASSIGNED(ProjectNo, EmpNo)
          tionship between two associatedentities.
                                                                          (a) GetEmpNoof employeesworking on proj-
     4.17 An entity set that does not have sufficient
                                                                                ectProj302.
          attributes to form a primary key is known as                    (b) Get details of employeesworking on proj-
                                                                                ectProj302.
    4.18 The processof designing sub grouping within                      (c) Obtain details of employeesworking on
         an entity set is _.                                                    the DBMSproject.
    4.19 The                  of a query consists of the             a. 5 If X        ure two relationsasshownbelow:
         tuples, which may assigned to the free vari-                          ""1I
         ablesof the well-formed formula.                                          abc                         bca
                                                                                   dca                         cdf
    4.20 -               primitive set of operations is
                                                                                   bfe                         bfe
         needed to express division operation of rela-
         tional algebra.                                                              X                          Y
    4.21The                  clause by itself defines a car-                 Find:
         tesianproduct of the relations in the clause.                       (a) XUY                            (c) XnY
                                                                             (b) x-Y                            (d)XxY
                           ANSWERSTO (DESCR|PT|VE
                                                QUESTTONS)
    Ans.1           (a)       0 couise=,'DBMS,,
                                              (Teach)
                    (b)       nr.z(o Course
                                          =,,DBMS,(Teach))
                              n is the projection operation symbol and the subscripts indicates the positions of
                              the attributes (columns) of the operand (table).
                                              OT
                              finame, addres, (O Co,rrr" = "DBMS" $each))
           bro ond RelotionolColculus
                                  ABC                             BCD
                                  bce                             ddf
                                  fgh                             ghk
                                  add                             ghi
                                  ace                             cmk
                                              ABCD
         R><S                                  fo      hk
                                               ^f ob   hi
                                               ad      df
Ans.4     Normalization is the processof reducting the redundancy <lfdata in a relational database
          Adaantages
          (a)       Normalization reduces the unnecessary redundant data.
          (b)       Data integrity is easily maintained within the database.
          (c)       Norrnalization makes databaseand application design processesmuch more flex-
                    ible.
          Disadaantages
          The disadvantage of normalization is that it produces so many tables with small number of
          columns and these columns have to be joined using their primary key or foreign key, rela-
          tionships in order to put the information back together so we can use it. For example, a query
          may be to retrieve a data from multiple normalized tables. This can result in complicated table
          joins.
Ans. 5    (a)                        = ,pr{o;302,
                    rs,,pNo(oprojecrNo         (ASSIGNED))
          (b)      EMPLOYEExnE-pNo(oproject#=,pRoJ302,(ASSIGNED))
          (c)      EMPLOYEE x EE*pN'(ASSIGNEDx (rrproiectNo(oprolect_Name=,DBMS,(PROIECT))))
                                                                                                            l
Relotionol ebro ond RelqtionolColculus
            (c)
                    XnY   =                bfe
            (d)
                                         abcbca
                                         abccdf
                                         abcbfe
                                         dcabca
                  XxY =                  dcacdf
                                         dcabfe
                                         bfebca
                                         bfecdf
                                         bfebfe