Monday 7 October 2013

07. Consider the following table structures.


  Refer the preceding table structures for the following requirements:
1. Create the Category table in the NarrowFabrics database. Enforce the following data integrity
rules while creating the table:
The CategoryId should be the primary key.
The Category attribute should be unique but not the primary key.
The Description attribute can allow storage of NULL values.
2. Create the ProductBrand table in the NarrowFabrics database. Enforce the following data
integrity rules while creating the table:
The BrandId should be the primary key.
The BrandName should be unique but not the primary key.
3. Create the NewProduct table with the following data integrity rules in the NarrowFabrics
database:
The ProductId should be the primary key.
The Qoh of the product should be between 0 and 200.
The Photo and ProductImgPath attributes can allow storage of NULL values.
The ProductName and ProductDescription attributes should not allow NULL values.
The values of the CategoryId attribute should be present in the Category table.
4. Modify the NewProduct table to enforce the following data integrity rule in the NarrowFabrics
database:
The values entered in the BrandId attribute should be present in the ProductBrand table.





















 
 create table category
(
categoryID char(3) constraint pkategoryID primary key,
category char(20) constraint unqCategory unique,
Description varchar(100)Null
)






create table ProductBrand
(
BrandID char (3) constraint pkBrandID primary key,
BrandName char(20) constraint unqBrandName Unique,
)






create table New Product
(
ProductID char(6)Constraint pkProductID primary key,
ProductName varchar(20) not null,
ProductDescription varchar(200) not null,
categoryID char(3)constraint fkCategoryID
foreign key references Category(categoryID),
ProductRate money,
BrandID char(3),
photo image Null,
Qoh smallint constraint chkQoh check (Qoh Between 0 and 200),
productImgPath vatchar(40)Null
)

No comments:

Post a Comment