Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

I Gaurav Patel, 000898120, certify that this material is my original work.

No
other person's work has been used without suitable acknowledgment and I have not
made my work available to anyone else.

Inset error:
------------
Violation of PRIMARY KEY constraint 'PK_Sales_Table'. Cannot insert duplicate key
in object 'dbo.Sales_Table'. The duplicate key value is (133).

Delete Error:
-------------
The DELETE statement conflicted with the REFERENCE constraint
"FK_Sales_Table_Master_Table". The conflict occurred in database
"Dukar_Car_Washing_Center",table "dbo.Sales_Table",column 'customer_id'.

SELECT 1 - Show the tables exist


Database Table
-------------------- --------------------
Dukar_Car_Washing_Ce Master_Table
Dukar_Car_Washing_Ce Sales_Table

(2 rows affected)

SELECT 2 - Show that the tables have the correct columns


Table Column Pos Type Length
-------------------- -------------------- ----------- --------------------
-----------
Master_Table customer_id 1 int NULL
Master_Table service_descreption 2 varchar 25
Master_Table service_type 3 char 1
Master_Table one_time_rate 4 money NULL
Master_Table sales_YTD 5 money NULL
Sales_Table sales_id 1 int NULL
Sales_Table sales_date 2 date NULL
Sales_Table amount 3 money NULL
Sales_Table customer_id 4 int NULL

(9 rows affected)

SELECT 3 - Show that all the constraints (PK, CK and FK) were set up properly
Table Column Constraint Type
Constraint_Details
--------------- -------------------- -----------------------------------
-----------
---------------------------------------------------------------------------
Master_Table customer_id PK_Master_Table PRIMARY
KEY Master_Table(customer_id)
Master_Table service_type CK_Master_Table_service_type CHECK
([service_type]='W' OR [service_type]='C' OR [service_type]='A')
Master_Table one_time_rate CK_Master_Table_one_time_rate CHECK
([one_time_rate]>=(0))
Sales_Table sales_id PK_Sales_Table PRIMARY
KEY Sales_Table(sales_id)
Sales_Table customer_id FK_Sales_Table_Master_Table FOREIGN
KEY Sales_Table(customer_id)

(5 rows affected)
SELECT 4 - Show the Master table data
customer_id service_descreption service_type one_time_rate sales_YTD
----------- ------------------------- ------------ ---------------------
---------------------
111 changing_brakes C 80.00 320.00
122 changing_spark_plugs C 100.00 300.00
133 car_washing_outside W 75.00 225.00
144 changing_headlight C 120.00 240.00
155 wheel_alignment A 210.00 630.00

(5 rows affected)

SELECT 5 - Show the Sales table data


sales_id sales_date amount customer_id
----------- ---------- --------------------- -----------
132 2023-07-01 100.00 122
133 2023-07-05 75.00 133
134 2023-07-08 80.00 111
135 2023-07-15 210.00 155
136 2023-07-19 100.00 122
137 2023-07-24 80.00 111
138 2023-08-05 210.00 155
139 2023-08-16 75.00 133
140 2023-08-20 120.00 144
141 2023-08-24 80.00 111
142 2023-09-02 210.00 155
143 2023-09-03 120.00 144
144 2023-09-15 80.00 111
145 2023-09-18 75.00 133
146 2023-09-20 75.00 133

(15 rows affected)

Completion time: 2023-09-29T19:37:29.7556916-04:00

You might also like