SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Server 2008_Exercises
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

zspeed01
Starting Member

6 Posts

Posted - 04/29/2013 :  20:02:34  Show Profile  Reply with Quote
Hi, can someone help me solve these problems. Thank you in advance

#1
Create a database named PRACTICE that you will then use for all remaining problems.

#2
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.

Catgeory Product



C


#3
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”,)

#4
Insert 3 Product records for each category in the product table. Use whatever data you see as appropriate.

#5
Use one statement to increase the price of all products in the Children category by 35%.


#6
Use one statement to delete all products for the Children category.

#7
Create and execute a view named PRACTICE_VIEW that shows all columns from both tables. Use an inner join.

#8
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.

#9
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

USE PRACTICE

--2-
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

--3--
ALTER TABLE Catgeory
ADD Men varchar(15) NOT NULL,
Women varchar(15) NOT NULL,
Children varchar(15) NOT NULL

--4--
INSERT Product
VALUES ( 10,'DRESS', 10, 15, 'L'),
(11, 'SHOES', 11, 45, 'M'),
(12,'JACKET', 12, 75, 'M')

russell
Pyro-ma-ni-yak

USA
5071 Posts

Posted - 04/29/2013 :  20:29:15  Show Profile  Visit russell's Homepage  Reply with Quote
For #3, you want to use an INSERT statement (DML) not an ALTER TABLE (DDL).
Go to Top of Page

zspeed01
Starting Member

6 Posts

Posted - 04/29/2013 :  23:05:34  Show Profile  Reply with Quote
I corrected it...Thanks for your help
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 04/30/2013 :  04:38:30  Show Profile  Reply with Quote
#5 requires UPDATE,#6 delete ,#7 CREATE VIEW and join
#8 CREATE TRIGGER and RAISERROR
#9 CREATE PROC and EXEC

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000