Sie sind auf Seite 1von 5

ASSIGNMENT

Part I

Create all the tables and insert the rows as shown on the following pages.
Show all work. This part is worth 10% of the project grade.

Part II

Answer the nine questions listed below, using these tables and SQL. For each

question, please provide the following:


1.

question in English

2.

the SQL code that answers it

3.

the results from the question

If the question requires a SELECT then the result from the SELECT is a temporary table
that you need to print out. If the question is an UPDATE, INSERT or DELETE then you need to
print out the affected tables both before and after the operation. There is one question where you
must use views since I specifically ask for it. However, you may use views in any question where
you think that they would be helpful to you. Each question is 10% of the project grade.

TABLES
E - EMPLOYEE

C - CUSTOMER

ENO

employee number(unique PK)

CNO

customer number(unique PK)

ENAME

name of employee

CNAME

name of customer

ASSETS

net worth of customer

SALARY salary of employee($)


POSITION employee's job(P (for president),

VP (for vice president), SLA (for senior loan officer) and JLA (for junior loan officer))

CL CUSTOMER LOAN
A - ACCOUNT

CNO - customer number

ANO

- account number(unique PK)

LNO - loan number

CNO

- customer number(FK-C)

TYPE

- type of account(savings-S current-C) EL EMPLOYEE LOAN

BALANCE

- current amount

ENO - employee number INTEREST

RATE - percent interest(0+)

LNO - loan number

TOTAL INTEREST - sum of YTD interest


sum of the interest earned in this account for the current calendar year (Jan 1 to Dec 31). It is
expressed as a currency amount

L LOAN
LNO - loan number(unique PK)

AT ACCOUNT TRANSACTION

START DATE - date loan


began(YYYYMMDD)

TNO

- transaction number(unique PK)

END DATE - date loan ends

ADATE

- date of transaction(YYYYMMDD)

TYPE - type of loan


P for personal loan, A for automobile loan, C
for commercial loan, M for mortgage loan or
E for education loan

ANO

- account number

INITIAL Amount - amount of loan

AMOUNT - amount of transaction

INTEREST RATE - percent of loan

TYPE

PAID TO DATE

- W or D or I or C

- total loan
amount paid

LT LOAN TRANSACTION
TNO

- transaction number

LOAN ACTIVE
(unique PK)

- YES or NO

LDATE

- date of transaction

LNO

- loan number

AMOUNT

- amount of transaction

EQUIVALENT DOMAINS
The following columns all share the same domains:
TABLE
COLUMN

C
CNO

A
CNO

CL
CNO

The following columns all share the same domains:


TABLE
COLUMN

A
ANO

AT
ANO

The following columns all share the same domains:


TABLE
COLUMN

L
LNO

EL
LNO

CL
LNO

LT
LNO

The following columns all share the same domains:


TABLE
COLUMN

AT
AMOUNT

A
BALANCE

L
PAID TO
DATE

LT
AMOUNT

Questions
1.

Find the name and number of all customers with assets less than 2 million dollars who
have never taken a loan for more than 100,000 dollars.

2.

For each customer, give me the name and number of each customer and the average
balance of all their accounts if they have at least 3 accounts.

3.

Find the name and number of all employees who have never created a loan for a
customer.

4.

Find all employee names and numbers who have the letter "W" or w in their name but
its not the first or last letter and does not have the lower case letter "d" in their name and
has a position of JLA.

5.

Find the name and number of all customers who have taken out loans with no known
END DATE.

6.

Find the name and number of all customers whose total balances in all their accounts
exceeds their asset value.

7.

For each type of loan, what is the total of initial amounts and the average of paid to date
as long as each type has at least 3 such loans.

8.

Find all customer names and numbers who have both checking and savings accounts.

9.

We have a new little customer with the name of DUNSTON and a CNO of C55.
DUNSTON has assets of 500,000. DUNSTON has opened a checking account with
account number A60 with an opening balance of $500. He also opened a savings account
with an account number of A77 with an opening balance of $2000. He also assumed all
existing loan from customer C5. Use the appropriate INSERTs, DELETEs and
UPDATEs.

Das könnte Ihnen auch gefallen