Posted - 04/29/2013 : 20:02:34
| Hi, can someone help me solve these problems. Thank you in advance
Create a database named PRACTICE that you will then use for all remaining problems.
Create the tables and appropriate constraints based on the following ER diagram. Use appropriate data types. Note that the size column should only accept S, M, or L. In addition the price column should have values greater than zero. All columns in both tables are required.
Insert 3 rows in the Category table. The db is for a small shoe store, so use appropriate data for the description (“Children” “Men”, “Women”,)
Insert 3 Product records for each category in the product table. Use whatever data you see as appropriate.
Use one statement to increase the price of all products in the Children category by 35%.
Use one statement to delete all products for the Children category.
Create and execute a view named PRACTICE_VIEW that shows all columns from both tables. Use an inner join.
Create a database trigger named PRACTICE_TRIGGER that prevents a user from deleting a Product record on Tuesdays. Display an appropriate error message. Make sure to show that the trigger is working properly.
Create a stored procedure named SP_ PRACTICE that will be used to insert records into the Product table. Make sure to show that the procedure is working properly.
This is what I have so far:
CREATE DATABASE PRACTICE
CREATE TABLE Catgeory
(cID int NOT NULL IDENTITY PRIMARY KEY,
ItemDescription varchar(50) NOT NULL)
CREATE TABLE Product
(pID int NOT NULL IDENTITY PRIMARY KEY,
ItemDescription varchar(25) NOT NULL,
cID int REFERENCES Catgeory(cID) NOT NULL,
Price MONEY NOT NULL,
Size varchar(25) NOT NULL)
drop table product
ALTER TABLE Catgeory
ADD Men varchar(15) NOT NULL,
Women varchar(15) NOT NULL,
Children varchar(15) NOT NULL
VALUES ( 10,'DRESS', 10, 15, 'L'),
(11, 'SHOES', 11, 45, 'M'),
(12,'JACKET', 12, 75, 'M')