use Yummys
go
--drop table Brand
--drop table Flavor
--drop table xrefFlavorBrand
create table Brand
(
BrandID int identity(1,1) primary key
,BrandName varchar(50)
,BrandLocation varchar(50)
)
insert into Brand (BrandName, BrandLocation) values ('BlueBunny', 'San Francisco')
insert into Brand (BrandName, BrandLocation) values ('PurpleMonkey', 'Detroit')
insert into Brand (BrandName, BrandLocation) values ('PinkHippo', 'Malibu')
insert into Brand (BrandName, BrandLocation) values ('GreenRabbit', 'Tucson')
insert into Brand (BrandName, BrandLocation) values ('RainbowLamb', 'Minneapolis')
select *
from Brand
create table flavor
(
Flavor_ID int identity (1,1) PRIMARY KEY,
flavor_name varchar (40),
descraption varchar (100)
)
insert into flavor
(flavor_name, descraption)
values
('choclate', 'classic choclate')
insert into flavor
(flavor_name, descraption)
values
('Vanilla', 'Plain Vanilla')
insert into flavor
(flavor_name, descraption)
Values
('Neopolatin', '1/3 Choclate, 1/3 Vanilla. 1/3 Strawberry')
insert into flavor
(flavor_name, descraption)
Values
('Coffee', 'Fresh Cround Coffee Flavor')
insert into flavor
(flavor_name, descraption)
Values
('Sardine', 'Self-Explanatory')
select *
from flavor
create table xrefFlavorBrand
(
xrefID int identity (1,1) primary key
, BrandID int
, FlavorID int
)
Insert into xrefFlavorBrand (BrandID, FlavorID) values (1,1)
Insert into xrefFlavorBrand (BrandID, FlavorID) values (2,2)
Insert into xrefFlavorBrand (BrandID, FlavorID) values (3,3)
Insert into xrefFlavorBrand (BrandID, FlavorID) values (4,4)
insert into xrefFlavorBrand (BrandID, FlavorID) values (5,5)
select *
from xrefFlavorBrand
select FL.*, xFB.BrandID, B.BrandName
from flavor FL
inner join xrefFlavorBrand xFB
on FL.Flavor_ID = xFB.xrefID
inner join Brand B
on xFB.BrandID = B.BrandID
where FL.flavor_name = 'Coffee'
Friday, February 4, 2011
Assignment
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment