diff --git a/UsedCars/UsedCars.xml b/UsedCars/UsedCars.xml index 992ca11..f654a49 100644 --- a/UsedCars/UsedCars.xml +++ b/UsedCars/UsedCars.xml @@ -78,6 +78,8 @@

As noted above, Happy Joe’s has about one hundred employees. The usual details such as name, address and phone number will be recorded. Employees must be at least 16 years old at the time they are first hired.

+ +

Note that Service, Sales and Other are all subtypes of Staff, and therefore use the same primary key as Staff.

@@ -153,7 +155,7 @@ -

Hourly_Rate must meet minimum wage requirements: at least 10.40 for those aged 16 or 17, and at least 13.00 for those 18 or older. Total_Hours is measured to the nearest quarter hour and must be in the range 0–3500 (= 40 hours per week 52 weeks per year, plus a generous allowance for overtime).

+

Hourly_Rate must meet minimum wage requirements: at least 11.00 for “starting out” workers, and at least 13.50 for adults. Total_Hours is measured to the nearest quarter hour and must be in the range 0–3500 (= 40 hours per week 52 weeks per year, plus a generous allowance for overtime).

@@ -230,13 +232,13 @@ * Salary - Total annual salary (see below) + Gross annual salary (see below) -

Salary must meet minimum wage requirements: at least 21632 (= 10.40 40 hours per week 52 weeks per year) for those aged 16 or 17, and at least 27040 for those 18 or older.

+

Salary must meet minimum wage requirements: at least 22880 (= 11.00 40 hours per week 52 weeks per year) for “starting out” workers, and at least 27040 for those 18 or older.

@@ -310,20 +312,20 @@ * - Total_Earnings - Total earnings to date this year, 0.00 + Gross_Earnings + Gross earnings to date this year, 0.00 -

Some sales staff are paid on commission (up to 30 of the value of each sale), while others are paid a flat rate per sale that varies depending on the type of car sold (e.g., 100 for a Toyota Corolla vs.500 for a BMW M3; these rates are stored in Car—see ). If the salesrep is paid on commission then On_Commission is true and Commission_Rate must be greater than zero. If the salesrep is paid on flat rate then On_Commission is false and Commission_Rate must be zero.

+

Some sales staff are paid on commission (up to 30 of the value of each sale), while others are paid a flat rate per sale that varies depending on the type of car sold (e.g., 100 for a Toyota Corolla vs.500 for a BMW M3; these rates are stored in Car—see ). If the salesrep is paid on commission then On_Commission is “true” and Commission_Rate must be greater than zero. If the salesrep is paid on flat rate then On_Commission is “false” and Commission_Rate must be zero.

-

Total_Earnings stores the total amount earned by a salesrep to date in the current financial year (1 April to 31 March). For salesreps who are on commission, this total is calculated from Commission_RateSale.Amount. For salesreps who are not on commission, the total is calculated from Car.Flat_Rate (via Sale—see and ).

+

Gross_Earnings stores the gross amount (i.e., before tax) earned by a salesrep to date in the current financial year (1 April to 31 March). For salesreps who are on commission, this is the sum to date of Commission_RateSale.Amount. For salesreps who are not on commission, this is sum to date of Car.Flat_Rate (via Sale—see and ).

-

SalesStaffID, OnCommission, CommissionRate, TotalEarnings (foreign keys: StaffID Staff)

+

SalesStaffID, OnCommission, CommissionRate, GrossEarnings (foreign keys: StaffID Staff)

CREATE TABLE Sales @@ -334,9 +336,9 @@ Commission_Rate NUMBER(3,2) NOT NULL CONSTRAINT Sales_Valid_Commission_Rate CHECK ( Commission_Rate BETWEEN 0.00 AND 0.30 ), - Total_Earnings NUMBER(8,2) NOT NULL - CONSTRAINT Sales_Valid_Total_Earnings - CHECK ( Total_Earnings >= 0.00 ), + Gross_Earnings NUMBER(8,2) NOT NULL + CONSTRAINT Sales_Valid_Gross_Earnings + CHECK ( Gross_Earnings >= 0.00 ), -- CONSTRAINT Sales_Check_Commission CHECK ( ( ( On_Commission = 'N' ) AND ( Commission_Rate = 0 ) ) @@ -348,7 +350,7 @@ ); -

Similar to Service_Staff above. We also accepted Other_Staff as a table name. Note that the paragraph above about Total_Earnings describes the process of how it is calculated, not a constraint on its possible values, so implementing this as a constraint is incorrect.

+

Similar to Service_Staff above. We also accepted Other_Staff as a table name. Note that the paragraph above about Gross_Earnings describes the process of how it is calculated, not a constraint on its possible values, so implementing this as a constraint is incorrect.

@@ -490,7 +492,7 @@ * Year - Year of manufacture, no earlier than 1980 + Year of manufacture, no earlier than 1995 * @@ -500,7 +502,7 @@ * Odometer - Current odometer reading, 0.0–999999.9 + Current odometer reading, 0.0–999999.9 * @@ -526,7 +528,7 @@ -

Happy Joe’s sell only modern cars, and so will not purchase anything manufactured before 1980. The value of Flat_Rate is determined by how frequently each particular type of car is sold (this information is not stored in the database); the “easier” it is to sell a car, the lower the value of Flat_Rate. All cars have a value for Flat_Rate because we do not know in advance whether they will be sold by a salesrep on commission or on flat rate. The value of Flat_Rate is independent of the sale price, which is why it is stored here rather than in Sale.

+

Happy Joe’s sell only modern cars, and so will not purchase anything manufactured before 1995. The value of Flat_Rate is determined by how frequently each particular type of car is sold (this information is not stored in the database); the “easier” it is to sell a car, the lower the value of Flat_Rate. All cars have a value for Flat_Rate because we do not know in advance whether they will be sold by a salesrep on commission or on flat rate. The value of Flat_Rate is independent of the sale price, which is why it is stored here rather than in Sale.

@@ -539,7 +541,7 @@ Make VARCHAR2(20) NOT NULL, Model VARCHAR2(30) NOT NULL, Year NUMBER(4) NOT NULL - CONSTRAINT Car_Valid_Year CHECK ( Year >= 1980 ), + CONSTRAINT Car_Valid_Year CHECK ( Year >= 1995 ), Colour VARCHAR2(20) NOT NULL, Odometer NUMBER(7,1) NOT NULL CONSTRAINT Car_Valid_Odometer @@ -568,7 +570,7 @@
- The <tt>Feature</tt> entity + The <tt>Feature</tt> and <tt>Car<underscore />Feature</tt> entities @@ -577,6 +579,9 @@ + + Feature + @@ -600,6 +605,8 @@

Cars may have any number of optional features, such as air conditioning, side airbags, body kit, iPod integration, cruise control, etc.

+

Car_Feature is an associative entity that exists only to link cars with features. It has no additional attributes of its own.

+

FeatureFeatureCode, Description

@@ -661,14 +668,24 @@ 1 character warranty code (see below)
- * - Duration - In months (see below) + o + Max_Age + Of car in years (see below) - * + o + Max_KM + Of car in kilometres (see below) + + + o + Duration + Of warranty in months (see below) + + + o Distance - In kilometres (see below) + Of warranty in kilometres (see below) * @@ -756,7 +773,7 @@
-

Purchases are for a single car only (i.e., no bulk purchases). Trade-ins are effectively treated as a special type of purchase (see Sale below).

+

Purchases are for a single car only (i.e., no bulk purchases). Trade-ins are effectively treated as a special type of purchase (see ).

@@ -873,7 +890,9 @@
- + + +