Professional Documents
Culture Documents
Lab 3
Lab 3
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'.
(2 rows affected)
(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)