Part 1: SQL/Database work Scenario Development of a relational database system for a food producing company FoodRU is a Leicester-based food producing company. The company wants to keep details regarding both past and present employees and their assignment to shifts over time. At present, there are three defined shift patterns; the morning shift starts at 6am and finishes at 2pm, the day shift starts at 9am and finishes at 5pm, and the evening shift starts at 4pm and finishes at 12am (midnight). However, management have already indicated that they may need to add further shift patterns in the future (e.g., by adding a night shift to the existing ones so that the company can meet a high user demand for their foods). They therefore require shift details to be stored within a separate Shift table, with attributes that allow the storage of a shift name with its associated start and finish times (use the 24 hour clock for these times).
Past and present employee details are to be kept in the same Employee table, and the details to be kept are the employee’s unique 6 digit reference number, the first name, surname and any other names (if there are any) of the employee, the employee’s gender, contact address and contact telephone, the date on which the employee started his/her employment at the company and the date on which the employee finished his/her employment at the company (should s/he be a past employee).
Details regarding staff assignments to shifts include the date that an employee was allocated to work a particular shift, and the date that s/he was taken off the shift (if not still assigned to it). Employees can be assigned to different shifts over time and even to the same shift over different time periods, although they cannot be assigned to more than one shift at any one time. A new employee may not yet be assigned to a shift. Tasks: 1. Provide the table specifications for the THREE tables that are required by FoodRU to store employee, shift and assignment details.
That is, for each of the three tables, you should provide, in a suitable presentation format, the name of the table and a specification of each its attributes to include: • Attribute name • Attribute brief description as to its meaning • a description of the attribute’s data type/integrity (e.g., date field, character field of length 20, number field <= 10, etc. – you can use the Oracle data types within these descriptions if you want to) • An indication as to whether the attribute is a primary key attribute and/or foreign key attribute • An indication as to whether the attribute can or cannot take null values Make sure your design specifies the appropriate links between the three tables. Remember to write down any additional integrity you need to enforce either at a specific table level or across two or more tables, if this is required.

Also, remember to write down any justifications for the data types/integrity or for any other design features that you have introduced, and/or any assumptions that you have made at any time during your design. 2. Create the THREE tables you have designed in Question 1. above, and populate the tables with some example data (at least 5 employees (some past and some current), appropriate shift details, and at least one shift allocation for most (but not all) of the employees). For the Employee table ONLY, provide a series of tests and their results so that you can be confident that the table was set up properly. This involves testing any entity integrity, referential integrity and other data validation constraints using appropriate SQL statements.
Print out the test and its results, and annotate to specify the intention of each test. 3. Create and justify THREE queries that you think FoodRU would like to use. Make sure that your queries, in total, show you are able to use the following facilities in Oracle SQL*Plus: o Selection of particular table columns o Selection of particular table rows o Inner Join of at least 2 tables o Use of a sorting/ordering facility o Use of DISTINCT o A condition using “[removed]’, IS NULL, IS NOT NULL, or similar. None of your queries should output an empty table!
You are required to submit: • The completed table specifications for the required three tables. These should be written using an appropriate text editor. • All the CREATE TABLE and INSERT INTO Oracle SQL*Plus statements used to create the three tables and to populate them with suitable data, together with a printout of each of the Oracle tables (i.e., the extension of each table) that you have created and populated. • The series of tests, and their results and annotations, for the Employee table ONLY. • A printout of the three queries you devised, showing both the SQL code and the query result. You should provide a brief explanation of what you expect each query to achieve and why you think this query is relevant to FoodRU.
