Page 59 - DCAP402_DCAO204_DATABASE MANAGEMENT SYSTEM_MANAGING DATABASE
P. 59

Database Management Systems/Managing Database




                    Notes          Query (b): List the number of employee in the company
                                   Solution:
                                   SELECT COUNT (*)
                                   FROM Employee E.
                                   Query (c): List the number of employees who are working on project number 44
                                   Solution:
                                          SELECT   COUNT(*)
                                          FROM     Employee E, Department D

                                          WHERE    E.DNo = D.DNo AND
                                          D.PNo = 44.
                                   Query (d): Find the name and age of the eldest employee

                                   Solution:
                                          SELECT   E.ename, E.age
                                          FROM     Employee E

                                          WHERE    E.age = (SELECT MAX(E2.age)
                                          FROM employees E2)
                                   (OR)

                                   The above query can also be written as
                                          SELECT   E.ename, E.age
                                          FROM     Employee E

                                          WHERE    (SELECT MAX (E2.age)
                                          FROM Employees E2 = E.age). Values




                                      Task       Discuss UNION operations.

                                   3.11 Null Values

                                   Null means nothing. Null values are those values which are assigned to an attribute if its value
                                   is unknown or is not applicable. Null values are used by DBMS when the user does not know the
                                   type information to be entered for a particular field, so the user doesn’t enter any data and DBMS
                                   assigns that field a NULL value. A NULL value does not represent a zero or spaces it just means
                                   the absence of value for  that field  and this  value can  be inserted  later. For  example in  the
                                   employee table it is not necessary that all the employees should have a phone number, so for the
                                   employer who does not have one yet, a NULL value can be assigned for that. When we insert a
                                   tuple (124, ‘Kelly’, 6, NULL, 26, NULL) in employer table then for the attribute e.sal and phone
                                   NULL values are assigned. Assignment of NULL value simply indicates that the value is not
                                   known or is inapplicable for that attribute. A field which is not declared as NOT NULL can have
                                   NULL values. But this inclusion of special type of value may result in the complications of other
                                   operations. NULL  values are used to deal with  the exceptional data or  the data that is  not




          52                                LOVELY PROFESSIONAL UNIVERSITY
   54   55   56   57   58   59   60   61   62   63   64