0% found this document useful (0 votes)
90 views7 pages

Exam 2

This document contains an exam with questions on SQL, database design, changing relationships between tables, and data warehousing. It includes sample tables to use for SQL queries and exercises on modifying relationships between tables and completing SQL code. The final question asks to summarize and integrate the main points of three articles related to implementing information systems.

Uploaded by

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

Exam 2

This document contains an exam with questions on SQL, database design, changing relationships between tables, and data warehousing. It includes sample tables to use for SQL queries and exercises on modifying relationships between tables and completing SQL code. The final question asks to summarize and integrate the main points of three articles related to implementing information systems.

Uploaded by

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

BAD 64082

Spring 2006
Exam 2
1. SQL DML (20 points)
Using the tables on page 2, show what the output would be after each of the following SQL scripts are
executed
1.

select cust_num, company


from customers
where cust_rep in (select empl_num
from salesreps
where manager in (select mgr
from offices
where mgr < 106));

2.

select company, credit_limit, name, region


from customers, salesreps, offices
where cust_rep = empl_num
and manager = mgr
and cust_rep <= 105;

3. select substr(name,1,1), count(credit_limit), sum(credit_limit)


from customers, salesreps
where cust_rep = empl_num
and cust_rep >= 105
group by substr(name,1,1);

4. create view tempview as


select company, cust_rep, credit_limit
from customers where cust_rep in
(select empl_num from salesreps
where age < 50);
select cust_rep, sum(credit_limit)
from tempview
group by cust_rep
having cust_rep < 105;

BAD 64082
Spring 2006
Exam 2
CUSTOMERS table
CUST_NUM
COMPANY
2111 JCP Inc.
2102 First Corp.
2103 Acme Mfg.
2123 Carter and Sons
2107 Ace International
2115 Smithson Corp.
2101 Jones Mfg.

CUST_REP
103
101
105
102
110
101
106

CREDIT_LIMIT
50000
65000
50000
40000
35000
20000
65000

SALESREPS table
EMPL_NUM
NAME
AGE REP_OFFICE TITLE HIRE_DATE MANAGER QUOTA SALES
105 Bill Adams
37
13 Sales Rep12-FEB-88
104 350000 367911
102 Sue Smith
48
21 Sales Rep10-DEC-86
108 350000 474050
106 Sam Clark
52
11 VP Sales 14-JUN-88
275000 299912
101 Dan Roberts 45
12 Sales Rep20-OCT-86
104 300000 305673

OFFICES table
OFFICE

CITY
22 Denver
11 New York
12 Chicago
13 Atlanta

REGION
Western
Eastern
Eastern
Eastern

MGR
108
106
104
105

TARGET
300000
575000
800000
350000

SALES
186042
692637
735042
367911

2. SQL DDL (20 points)

BAD 64082
Spring 2006
Exam 2
Using the ER Diagram and Relation Descriptions shown below, define the tables to Oracle with SQL
DDL. Ensure that each tables primary keys, foreign keys, data constraints and referential integrity
constraints are correct.
ENTITY-RELATIONSHIP DIAGRAM
STUDENT
SID

Name

Address

Phone
APARTMENT
APTID
Address

City

State

Zip

AC

Rent

STUD_APT_INT
SID

APTID

Received

Timely

RELATION DESCRIPTIONS
STUDENT (SID, Name, Address, Phone)
Name is required
APARTMENT (APTID, Address, City, State, Zip, AC, Rent)
Rent must accept decimal values
STUD_APT_INT (SID, APTID, Received, Timely)
SID must first exist in STUDENT.SID
APTID must first exist in APARTMENT.APTID
Received must accept date values (for date that payment was received)
Timely must be either Y or N

3. CHANGING CARDINALITY (20 points)

BAD 64082
Spring 2006
Exam 2
Shown below are the ER diagram and relation descriptions for two tables in a 1:1 relationship.
Product

1:1

Vendor

Relation Descriptions:
Product (PRODUCTID, Name, Warehouse, VENDORID)
RI Constraint: Product.VendorID must first exist as Vendor.VendorID
Vendor (VENDORID, Name, Address)
You can assume that the Product and Vendor tables have been created and loaded with data.

Now, the company would like to allow multiple vendors to supply the same product. Therefore, the
above 1:1 relationship must be converted into a 1:N relationship, as shown below:
Product

1:N

Vendor

The next page (page 5) lists the steps required to make the above transformation, along with the SQL code
that executes each step. However, the SQL code is incomplete, in that blank spaces (denoted as
_____________) appear where the tables name should appear.
Using the above information, and what you know about placing foreign keys, insert statements and alter
statements, complete the SQL code by filling in each blank space with the appropriate table name.

1. Make backups of each table

BAD 64082
Spring 2006
Exam 2
CREATE TABLE __________________ (
VENDORID
INTEGER,
NAME
VARCHAR2(50),
ADDRESS
VARCHAR2(50),
CONSTRAINT VENDOR_BKUP_PK PRIMARY KEY(VENDORID));
CREATE TABLE __________________ (
PRODUCTID
CHAR(1),
NAME
VARCHAR2(50),
WAREHOUSE
VARCHAR2(50),
VENDORID
INTEGER,
CONSTRAINT PRODUCT_BKUP_PK PRIMARY KEY(PRODUCTID),
FOREIGN KEY (VENDORID) REFERENCES __________________(VENDORID));

2. Populate the backup tables with data from Product and Vendor tables.
INSERT INTO __________________ (VENDORID, NAME, ADDRESS)
SELECT VENDORID, NAME, ADDRESS FROM __________________;
INSERT INTO __________________ (PRODUCTID, NAME, WAREHOUSE, VENDORID)
SELECT PRODUCTID, NAME, WAREHOUSE, VENDORID FROM __________________;

3. Drop the field that was the foreign key from old 1:1 relationship
ALTER TABLE __________________
DROP COLUMN VENDORID;

4. Add the field that will become the foreign key for new 1:N relationship
ALTER TABLE __________________
ADD PRODUCTID CHAR(1);

5. Add the foreign key constraint to the appropriate table in the new 1:N relationship
ALTER TABLE __________________
ADD CONSTRAINT VENDORFK FOREIGN KEY (PRODUCTID)
REFERENCES __________________ (PRODUCTID);

4. SHORT ANSWER (20 points)

BAD 64082
Spring 2006
Exam 2
Explain recovery via rollback / roll-forward, recovery via reprocessing, what is required for rollback /
roll-forward, and why it is preferable to reprocessing.

Terms associated with data warehousing include data marts, ETL process and star schema. Define a data
warehouse and how it differs from a data mart. Briefly explain the ETL process and the components of a
star schema.

5. INTEGRATIVE QUESTION (20 points)

BAD 64082
Spring 2006
Exam 2
The nine student articles discussed in class covered a wide range of issues relevant to corporate
information systems. These nine student articles can be grouped in a number of ways, but three
topics that seem to emerge are security, data mining/knowledge management, and issues
germane to implementing information systems.
The three final class articles by Johnson, Rigby & Ledingham, and Watson & Haley covered data
warehousing and customer relationship management. These three articles focus on issues that
influence the success (or failure) of these larger corporate systems.
You are a consultant who has been hired to advise a company on the issues involved in
implementing a large information system that contains a relational database system. You may
choose your area of expertise, so you can advise this company on any topic you choose.
However, your response must summarize and integrate the main points from two of the student
articles and one of the final class articles.
Your response should have the following structure:
1. Introduction: What is the problem you are covering and why is it important?
2. Summarize main points of article one
3. Summarize main points of article two
4. Summarize main points of article three
5. Integrate the main points of the three articles you chose. How do they pertain to the
problem you are covering?
6. Conclusion

You might also like