Managing Interprise Data

profileDaisey
ManaginginterpriseDataSQL.docx

2. (35 points)

A college football association has a database to record various data about their teams, players and affiliated university.

The following relational model presents the relationship between the tables:

We have the following information about the attributes:

Team:

- TeamID is an integer and is the Primary Key of the Team table

- TeamName is a chain of no more than 30 characters

- City is a chain of no more than 25 characters

- State is a chain of 2 characters

- Win is an integer

- Loss is an integer

Player:

- PlayerID is an integer and is the Primary Key of the Player table

- PlayerName is a chain of no more than 50 characters

- Age is an integer - Position is a chain of no more than 15 characters

- TeamID is an integer and is a foreign key of the Player table

- CollegeID is an integer and is a foreign key of the Player table

College:

- CollegeID is an integer and is the Primary Key of the College table

- CollegeName is a chain of no more than 30 characters

- City is a chain of no more than 25 characters

- State is a chain of 2 characters

a. Using the previous information above the SQL statement creating the Player table. (Keep in mind

that values are required for primary keys (5 pts)

b. Write a SQL statement that add the following entry in the College table (5 pts):

- CollegeID: 1478

- CollegeName: Gator College

- City: San Francisco

- State: CA

c. Write a SQL statement that change the College Name of the previous entry (in b.) from Gator College to Gator University. Your statement should make sure that only this entry is changed. (5 pts)

d. Assume the following sample of data :

Team

TeamID

TeamName

City

State

Win

Loss

1001

Wildcats

Los Angeles

CA

10

3

1002

Hawks

San Francisco

CA

8

5

1003

Renegades

San Jose

CA

4

9

1004

Gators

San Francisco

CA

3

10

Player

PlayerID

TeamID

CollegeID

PlayerName

Age

Position

101

1001

1080

Julio Peters

23

WR

102

1003

1080

Lance Randolph

29

QB

103

1003

2001

Timothy Haas

27

TE

115

1002

1478

Joey Daniel

32

LB

106

1004

1479

Hobert Golden

25

FB

110

1001

1478

Hunter Padilla

21

QB

College

CollegeID

CollegeName

City

State

1478

Gator University

San Francisco

CA

1479

Hogwart College

San Francisco

CA

1080

Stark College

Los Angeles

CA

2001

Data University

Portland

OR

Using the previous tables, write the SQL queries that perform the following actions.

Based on the data above, the output of each query is displayed below the question.

· List the name of all the teams with more wins than losses (5 pts)

Your output should be:

· List the player ID and player name of all the players between 25 and 30 years old (5 pts)

Your output should be:

· List the player name, age, position and college name for all the Quarterbacks (QB) coming from Stark College and all the linebackers (LB) coming from Gator University. (5 pts)

Your output should be:

· Using join queries, list the player name, team name , college name and city for all players playing for team located in the same city and state as their college. (5 pts)

Your output should be :

3. (20 pts)

Victoria Ephanor manages a small product distribution company. Because the business is growing fast, she recognizes that it is time to manage the vast information pool to help guide the accelerating growth. Ephanor, who is familiar with spreadsheet software, currently employs a sales force of four people. She asks you to develop a data warehouse application prototype that will enable her to study sales figures by year, region, salesperson, and product.

Using the data supplied in the following table, answer the following questions:

Year

Region

Agent

Product

Value

2016

East

Carlos

Erasers

50

2016

East

Tere

Erasers

12

2016

North

Carlos

Widgets

120

2016

North

Carlos

Widgets

30

2016

South

Victor

Balls

145

2016

South

Victor

Balls

34

2016

West

Mary

Pencils

56

2017

East

Carlos

Pencils

45

2017

East

Victor

Balls

55

2017

North

Mary

Pencils

60

2017

North

Victor

Erasers

20

2017

South

Carlos

Widgets

30

2017

South

Mary

Widgets

75

2017

South

Tere

Erasers

90

2017

West

Carlos

Widgets

25

2017

West

Tere

Balls

100

a. Identify the appropriate fact table components (attributes). (5 pts)

b. Identify the appropriate dimension tables and appropriate attributes for each. (5 pts)

(Deriving attributes may require some creativity)

c. Draw a star schema diagram for this data warehouse. (10 pts) (Use crows foot natation method and can use hand or lucid chard for diagram)