Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

 find this sql command for my database

– Find the top 2 brands by dollar-amount sold in the past year.
– Find the top 2 brands by unit sales in the past year.
– Show sales trends for various brands over the past 3 years, by year, month, week.
Then break these data out by gender of the buyer and then by income range.
– Find the number of models in different body styles (group by number of door, etc.)

database:

 

create table Brand

(id int not null primary key,

name  varchar(50) not null)

 

create table Model

(id int not null primary key,

number_doors int not null,

number_wheels int not null,

vehicle_type char(50) not null,

engine_capacity int not null,

brandid int foreign key references Brand (id))

 

create table Choice

(id int not null primary key,

color char(10),

engine_type char(20))

 

create table Model_Option

(modelid int foreign key references Model (id),

optionid int foreign key references Choice (id),

primary key (modelid, optionid))

 

create table Vehicle

(vin int not null primary key,

modelid int foreign key references Model (id),

makeid int foreign key references Brand (id),

optionid int foreign key references Choice (id))

 

create table Dealer

(id int not null primary key,

location char(50) not null)

 

create table Dealer_Model

(dealerid int foreign key references Dealer (id),

modelid int foreign key references Model (id))

 

create table Customer

(id int not null primary key,

address varchar(100) not null,

phone char(20),

gender char(5),

annual_income int)

 

create table Sales

(id int not null primary key,

customerid int foreign key references Customer (id),

vehicleid int foreign key references Vehicle (vin),

dealerid int foreign key references Dealer (id))

 

create table Supplier

(id int not null primary key,

location char(50) not null)

 

create table Supplier_Model

(supplier_id int foreign key references Supplier (id),

modelid int foreign key references Model (id))

create table Sales.
(id int not null primary key,
customerid int foreign key references Customer (id),
vehicleid int foreign key references Vehicle (vin),
dealerid int foreign key references Dealer (id))
create table Supplier
(id int not null primary key,
location char(50) not null)
create table Supplier_Model
(supplier_id int foreign key references Supplier (id),
modelid int foreign key references Model (id))
Transcribed Image Text:create table Sales. (id int not null primary key, customerid int foreign key references Customer (id), vehicleid int foreign key references Vehicle (vin), dealerid int foreign key references Dealer (id)) create table Supplier (id int not null primary key, location char(50) not null) create table Supplier_Model (supplier_id int foreign key references Supplier (id), modelid int foreign key references Model (id))
create table Brand
(id int not null primary key,
name varchar(50) not null)
create table Model
(id int not null primary key,
number_doors int not null,
number_wheels
int not null,
vehicle_type char(50) not null,
engine capacity int not null,
brandid int foreign key references Brand (id))
create table Choice
(id int not null primary key,
color char(10),
engine_type char(20))
create table Model_Option
(modelid int foreign key references Model (id),
optionid int foreign key references Choice (id),
primary key (modelid, optionid))
create table Vehicle
(vin int not null primary key,
modelid int foreign key references Model (id),
makeid int foreign key references Brand (id),
optionid int foreign key references Choice (id))
create table Dealer
(id int not null primary key,
location char(50) not null)
create table Dealer_Model
(dealerid int foreign key references Dealer (id),
modelid int foreign key references Model (id))
create table Customer
(id int not null primary key,
address varchar(100) not null,
phone char(20),
gender char(5),
annual income int)
Transcribed Image Text:create table Brand (id int not null primary key, name varchar(50) not null) create table Model (id int not null primary key, number_doors int not null, number_wheels int not null, vehicle_type char(50) not null, engine capacity int not null, brandid int foreign key references Brand (id)) create table Choice (id int not null primary key, color char(10), engine_type char(20)) create table Model_Option (modelid int foreign key references Model (id), optionid int foreign key references Choice (id), primary key (modelid, optionid)) create table Vehicle (vin int not null primary key, modelid int foreign key references Model (id), makeid int foreign key references Brand (id), optionid int foreign key references Choice (id)) create table Dealer (id int not null primary key, location char(50) not null) create table Dealer_Model (dealerid int foreign key references Dealer (id), modelid int foreign key references Model (id)) create table Customer (id int not null primary key, address varchar(100) not null, phone char(20), gender char(5), annual income int)
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Fundamentals of Big Data Analytics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education