Page 92 - DCAP402_DCAO204_DATABASE MANAGEMENT SYSTEM_MANAGING DATABASE
P. 92

Unit 6: Relational Language and Database Design




          Objectives                                                                            Notes

          After studying this unit, you will be able to:
              Discuss relational calculus, tuple and domain relational calculus

              Explain entity relationship model
              Know the constraints
              Describe E-R diagrams and extended ER features

          Introduction

          Relational tables can be considered as sets. The rows of the tables can be considered as elements
          of the set. Operations that can be performed on sets can be done on relational tables. Relational
          Data operators are used to retrieve the required data from relational tables. Data is retrieved
          using queries and the queries are formulated using various data operators.
          To be able to use a database to store data, it should be designed in an efficient manner. The first
          step in designing a database is data modeling. Data modeling enables a database designer to
          create a model that represents the way in which information is likely to be organized in the
          database. There are two major methodologies used to create a data model: the Entity-Relationship
          (ER) approach  and the Object Model. This unit mainly focuses on data  modeling using  the
          Entity-Relationship  approach.  The  basic  techniques  described  here  are  applicable  to  the
          development of relational database applications.

          6.1 Relational Calculus

          Relational calculus is an alternative to relational algebra. In contrast to the algebra, which is
          procedural, the calculus is nonprocedural, or declarative, in that it allows us to describe the set
          of answers without being explicit about how they should be computed. Relational calculus has
          had a bid influence on the design of commercial query languages such as SQL and, especially,
          Query-by-Example (QBE).

          The variant of the calculus that we present in detail is called the tuple relational calculus (TRC),
          variables in  TRC take on tuples  as values. In another variant, called the domain  relational
          calculus (DRC), the variables range over field values. TRC has had more of an influence on SQL,
          while DRC has strongly influenced QBE.
          6.2 Tuple Relational Calculus


          A tuple variable is a variable that takes on tuples of a particular relation schema as values. That
          is, every value assigned to a given tuple variable has the same number and type of _elds. A tuple
          relational calculus query has the form {T | p (T)}, where T is a tuple variable and p(T) denotes a
          formula that describes T; we will shortly define formulas and queries rigorously. The result of
          this query is the set of all tuples t for which the formula p(T) evaluates to true with T = t. The
          language for writing formulas p(T) is thus at the heart of TRC and is essentially a simple subset
          of first-order logic. As a simple example, consider the following query.


                 Example: Find all sailors with a rating above 7.
                         { S | S   Sailors   S. rating > 7}





                                           LOVELY PROFESSIONAL UNIVERSITY                                   85
   87   88   89   90   91   92   93   94   95   96   97