CSE2DBF 2021 Assignment 2 :House2Home Franchise Application Database System


Implement the following tasks.
Download the file H2HSchema.sql from the LMS site and run it. This file contains all the CREATE and INSERT statements you will need for this assignment.

NOTE: YOU DO NOT NEED TO INSERT MORE DATA INTO THE TABLES.
The list of tables available for this assignment is the following:
STORE (StoreID, StoreAddress, WeekDaysHours, WeekendHours)
ACCOUNT (AccountNo., AccountName, Balance)
DEPARTMENT (DepartmentID, DepartmentTitle, NoOfEmployees, AccountNo, StoreID, FranchiseTeamID)
WEEKLY_SALES_REPORT (ReportID, StartDate, EndDate, SaleAmount, ComRate, ComAmount, BrandID, BName, BSaleAmount, TypeID, TName,
TSaleAmount, EmployeeID, Ename, ESaleAmount, EBonus, DepartmentID)
FRANCHISE_APP (AppNumber, AppDate, DecisionDate, Status, DepartmentID, TeamID)
EMPLOYEE (EmployeeID, Name, Phone, Email, Address, Gender, DOB, JoiningDate, CentralOrLocalEmployment, EFTPOSID, CANumber,
DepartmentID)
CASUAL_EMPLOYEE (EmployeeID, HourlyRate)
PART_TIME_EMPLOYEE (EmployeeID, WeeklyHours, Salary)
FULL_TIME_EMPLOYEE (EmployeeID, LeaveDays, Salary, MemberID)
TEAM_MEMBER (MemberID)
SHAREHOLDER (S.H.ID, Name, Phone, Email, Address, NoOfShares, MemberID)
TEAM (TeamID, TeamName, TeamLeaderID)
MEMBERSHIP (MemberID, TeamID, PercentageOfShare)
NOTE: PK is printed underlined and FK is printed italic in italics.

Task 1: Using the tables provided above, provide SQL statements for the following queries.
a. Show the store information along with its departments for all stores that opens the latest during weekend.
b. Show the name and address of all team members for store S001.
c. List the franchise application details for each department of H2H along with the department id and title. Include the departments that have not received any application yet.
d. Show the team information and number of members for all successful franchise application.
e. Show the details of the franchise application that took the longest time to reach a decision.
f. List the team member details (including shareholder and employee details such as id, name, phone and email) for all the team members who are part of a franchise team of a successful application. For each of the members, also include the date on which their franchise application was granted.
g. Show the top 4 employees (name, salary earned) that have earned the highest salary from January 2017 – December 2017. Assume that all casual employees work 12 hours per week and there are 45 working weeks a year.

Task 2: Provide the implementation of the following stored procedures and function. For submission, please include both the PL/SQL code and an execute procedure/SQL statement to demonstrate the functionality.

a. Write a procedure that takes two dates as input (a duration) and updates the commission amount of every weekly report for which the start date falls under this duration. The commission amount is the result of multiplication of sale amount and commission rate (%). The procedure also generates an output in the following format for every affected row: The commission amount for report has been updated to dollars, which is % of the total sale amount of dollars.

b. Write a function that takes an employee id and a month-year (date of ‘MON-YYYY’ format) and returns the total bonus amount the employee have earned by making exceptional sales during that month. If the employee was not awarded a bonus for that month, the function should return zero. For the execution of the function, write a simple SQL query that lists down all the employees and their total bonus amount earned for the month of April 2018. Hint: Although we did not maintain referential integrity constraint between EMPLOYEE and WEEKLY_SALES_REPORT, you can safely assume that the employee listed as the best performing employee in a sales report is a valid employee, who is present in the employee table.

Task 3: Provide the implementation of the following triggers. For submission, please include both the PL/SQL code and a DML statement (insert, update or delete) to demonstrate the trigger functionality.
a. A trigger that prevents a full-time employee from applying for a franchise if he/she has less than 10 years of experience as an employee of H2H.
b. A trigger that automatically backs-up a weekly sales report when it is deleted. To preserve the data, the trigger stores the deleted report into a backup table: BackupReport (ReportID, StartDate, EndDate, SaleAmount)

Leave a Reply

Your email address will not be published. Required fields are marked *



  • IMPORTANT: This is a pre-booking project. All answers will be E-Mailed to you within 12 hours of purchase.
  • CONTACT US: Write to info@libraay.com for any further queries