BCSE302P - Database Management Lab
Lab Assessment - 3
     Submitted by - Kanha Khantaal
        Reg. No. - 22BCE2099
                             DBMS DA - 2
                      Codes, Reasoning and Output
Table Declaration -
VALUE INSERTIONS –
Adding Constraints –
  1. For Employee Table –
2. For Department Table –
3. For Department Location –
4. For Project Table –
5. For Works_on Table –
6. For Dependent Table –
1. Insert ('Robert', 'F', 'Scott', '943775543', '21-JUN-42', '2365
   Newcastle Rd, Bellaire, TX', M, 58000, '888665555', 1 ) into
   EMPLOYEE.
     Reason – here M must be in ‘M’ in form of char but in question it
     is declared as a variable
                                                        Correct Code
2. Insert ( '677678989', null, '40.0' ) into WORKS_ON.
  Reason – value '677678989' in the e_ssn column does not match any
  existing ssn in the referenced table e2099
3. Insert ( '453453453', 'John', M, '12-DEC-60', 'SPOUSE' ) into
   DEPENDENT
  Reason – Since here M must be in Character format, since in query it
  is not in ‘M’ format therefore it will throw ERROR
                  Correct Code
                                         Correct Code
4. Delete the WORKS_ON tuples with ESSN= '333445555'
5. Modify the MGRSSN and MGRSTARTDATE of the
   DEPARTMENT tuple with DNUMBER=5 to '123456789' and
   '01-OCT-88', respectively.
1. Add Foreign Keys using Alter Table [if not done earlier]
   ALREADY DONE IN THE STARTING
2. Drop Foreign key defined on SuperSSN and add it using
   Alter table command
3. Make name of Project as Unique and sex of employee as
   not null
4. Make Address as a new type containing door no, street,
   city, State, Continent
5. Make salary of employee to accept real values
                                      DBMS DA-3
                                 Codes with output
1. Find the employee names having salary greater than Rs.25000.
2. Find the employee names whose salary lies in the range between 30000 and 70000.
3. Find the employees who have no supervisor.
4. Display the bdate of all employee s in the format ‘DDthMonthYYYY’.
5. Display the employee names whose bdate is on or before 1978.
6. Display the employee names having ‘salt lake’ in their address
   **but if typed Salt Lake
7. Display the department name that starts with ’M’.
8. Display the department names’ that ends with ‘E’.
9. Display the names of all the employees having supervisor with any of the following SSN
   554433221, 333445555.
10. Display all the department names in upper case and lower case
11. Display the first four characters and last four of the department names using ltrim and rtrim.
12. Display the substring of the Address (starting from 5th position to 11 th position) of all
    employees
13. Display the Mgrstartdate on adding three months to it.
14. Display the age of all the employees rounded to two digits
15. Find the last day and next day of the month in which each manager has joined.
16. Print a substring from the string ‘Harini’.
17. Replace the string ‘ni’ from ‘Harini’ by ‘sh’.
18. Print the length of all the department names.
19. Print the system date in the format 25 th May 2007.
20. Display the date after 10 months from current date.
21. Display the next occurrence of Friday in this month.
22. Convert SSN of employee to Number format and display.
23. Display the project location padded with **** on left side.
24. Remove the word ‘Project’ from the project name and display it.
25. Select the SSN of the employee whose dependent name is either Michael or Abner.