Advanced Database Lab Questions
Advanced Database Lab Questions
b) Write a query to delete employees who have not worked (assume workHours = 0 or an extended table).
b) Use this type in a Customer table with the fields: (CustomerID, Name, Address address_type).
b) Create a table Car that inherits from Vehicle and has an extra column NumDoors.
3. Triggers (PostgreSQL)
Q6. Write a trigger that automatically updates the LastUpdated timestamp of a Product table when any row is updated.
a) Create the Product table with fields: (ProductID, Name, Price, LastUpdated).
a) Write a PL/pgSQL function get_employee_salary(emp_id INT) that returns the salary of the employee with the given
ID.
Write a PL/pgSQL function factorial(n INTEGER) that calculates and returns the factorial of a number using a loop.
- Create a Student table using a composite type for contact_info (email TEXT, phone TEXT).
- Create a trigger that checks if email is NULL on insert and raises an exception.