0% found this document useful (0 votes)
153 views9 pages

Database Structure for Bicycle Sales

The document creates and populates a SQL database with tables to store information about customers, bicycles, bicycle models, and bicycle services. The customer table stores customer details and relationships. The bicycle and bicycle model tables store bicycle properties and their relationships. The service table tracks bicycle services. Data is inserted into these tables, and queries are provided to select data from the tables based on joins and filters.

Uploaded by

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

Database Structure for Bicycle Sales

The document creates and populates a SQL database with tables to store information about customers, bicycles, bicycle models, and bicycle services. The customer table stores customer details and relationships. The bicycle and bicycle model tables store bicycle properties and their relationships. The service table tracks bicycle services. Data is inserted into these tables, and queries are provided to select data from the tables based on joins and filters.

Uploaded by

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

Create database bike;

Use bike;

Create table customer(

Cust_ID varchar(3) primary key,

Email_ID varchar(30) not null,

Name varchar(15) not null,

Phone numeric(10) not null,

RID varchar(3));

Alter table customer

Add constraint p foreign key(RID) references customer(Cust_ID);

Create table Bicycle_Model(

Model_no varchar(3) primary key,

Manufacturer varchar(10) not null,

Style varchar(8) not null);


Create table Bicycle(

Bicycle_ID varchar(3) primary key,

Date_purchase date not null,

Color varchar(8) not null,

Cust_ID varchar(3),

Model_no varchar(3),

Foreign key(Cust_ID) references customer(Cust_ID),

Foreign key(Model_no) references Bicycle_Model(Model_no));

Create table service(

Start_date date primary key,

Bicycle_ID varchar(3),

Foreign key(Bicycle_ID) references Bicycle(Bicycle_ID),

End_date date not null);

Insert into customer

Values("A1","vithanalasatish2004@[Link]","Satish",7995497800,"A1");

Insert into customer

Values("B1","vithanalasatish200@[Link]","Nikhil",6564751234,"B1");

Insert into customer


Values("C1","vithanalasatish20@[Link]","Ramya",5428532152,"C1");

Insert into customer

Values("D1","vithanalasatish2@[Link]","Nithin",6300150250,"D1");

Insert into customer

Values("E1","vithanalasatish@[Link]","Shashank",2321548120,"E1");

Select * from customer;

Insert into Bicycle_Model

Values("A2","Hero","S1");

Insert into Bicycle_Model

Values("B2","Jawa","S2");
Insert into Bicycle_Model

Values("C2","Yamaha","S3");

Insert into Bicycle_Model

Values("D2","Ducati","S4");

Insert into Bicycle_Model

Values("E2","Triumph","S5");

Select * from Bicycle_Model;

Insert into Bicycle


Values("V1","2022-10-11","White","A1","A2");

Insert into Bicycle

Values("V2","2022-10-11","Red","B1","B2");

Insert into Bicycle

Values("V3","2000-01-11","Green","C1","C2");

Insert into Bicycle

Values("V4","2000-01-11","Gray","D1","D2");

Insert into Bicycle

Values("V5","2000-01-11","Black","E1","E2");

Select * from Bicycle;


Insert into service

Values("2022-10-11","V1","2022-10-15");

Insert into service

Values("2022-11-11","V2","2022-10-15");

Insert into service

Values("2000-05-11","V3","2001-06-11");

Insert into service

Values("2000-06-11","V4","2002-06-11");

Insert into service

Values("2000-07-11","V5","2003-06-11");
Select * from service;

B) Select name from customer c join bicycle b on c.cust_id=b.cust_id join

Bicycle_model bm on bm.model_no=b.model_no where manufacturer="Hero";


C)

Select Bicycle_ID from Bicycle b, customer c

Where c.Cust_ID=b.Cust_ID AND RID="C1";

D)

Select manufacturer from Bicycle_Model bm,Bicycle b

Where b.Model_No=bm.Model_No AND color="Red";

E)

Select Model_No from Bicycle b, Service s

Where b.Bicycle_ID=s.Bicycle_ID;

You might also like