0% found this document useful (0 votes)
26 views2 pages

SQL HomeWORK

The document contains SQL commands to create tables for two different databases. The first section creates three tables for a bakery database to store customer, product, and order information. The second section creates tables for a video rental database to store information on categories, customers, formats, and rentals including joins between the tables.

Uploaded by

Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

SQL HomeWORK

The document contains SQL commands to create tables for two different databases. The first section creates three tables for a bakery database to store customer, product, and order information. The second section creates tables for a video rental database to store information on categories, customers, formats, and rentals including joins between the tables.

Uploaded by

Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

use osb_username

go
create table BakeryCustomer(
CustomerID bigint identity not null,
CustomerName varchar(50) not null,
CustomerPhone varchar(50) null,
Constraint PK_bakerycustomer_customerid
primary key clustered(customerID)
)
create table BakeryProduct(
ProductID bigint identity not null,
ProductDescription varchar(50) not null,
ProductPrice varchar(50) not null,
Constraint PK_bakeryProduct_ProductID
)
create table BakeryOrder(
OrderID bigint identity not null,
ProductID bigint identity not null,
CustomerID bigint identity not null,
OrderDate Datetime null,
OrderDeliveryDate datetime not null,
OrderQuantity int not null,
constarint PK_BakeryOrder_OrderID_ProductID_CustomerID
primary key clustered(OrderID, ProductID, CUstomerID),
constraint FK_BakeryCustomer_CustomerID
foreign key (CustomerID) references
BakeryCustomer (CustomerID),
contraint FK_BakeryProduct_ProductID
Foreign key (productID) references BakeryProduct (ProcductID)
go
---------------------------------------------------------------------------------------------------create table VideoCategory(
CategoryID bigint identity not null,
CategoryDescription varchar(50) not null,
Constraint PK_VideoCategory_CategoryID
primary key clustered(CategoryID)
)
create table VideoCustomer(
CustomerID bigint identity not null,
CustomerLastName varchar(50) not null,
CustomerFirstName varchar(50) not null,
CustomerAddress varchar(50) not null,
CustomerCity varchar(50) null,
CustomerState varchar(2) null,
CustomerZipCode varchar(15) null,
constraint PK_VideoCustomer_CustomerID Primary Key
clustered(customerID)
)
create table VideoFormat(
FormatID bigint identity not null,
FormatDescription varchar(30) not null,
constraint PK_VideoFormat_FormatID Primary Key
clustered(FormatID)
)
create table VideoRental(
VideoID bigint identity not null,
VideoDateOut smalldatetime not null,
VideoDateDue smalldatetime not null,

VideoDateIn smalldatetime not null,


VideoDeliveryStatus varchar(10) not null,
VideoLateFee smallmoney null,
CustomerID bigint not null
TitleID bigint not null,
constraint PK_VideoRental_RentalID Primary Key
clustered(customerID)
references
)

You might also like