2 - Al Akhawayn University

advertisement
Al Akhawayn University
School of Science and Engineering
CSC 3326 Database Systems
Individual Homework assignment 2
(Deadline 27th Feb, 12:30, only paper version, NO EMAIL)
Question 1 (7pt/30)
a. Is the order of creating tables important? Why? (1PT)
b. When should you prefer to use the data type varchar instead of char and vs.? (1PT)
c. What are business rules, why are they crucial and give an example? (1 PT)
d. How are M:N relationships handled in the development of an E-R diagram? (1PT)
e. Which data types will you assign for the following and why? Please give also the
length:








(2 PT)
ZIP
Birthday
Production year of a car
CIN Number
Part number where 95% of these parts contains in the last position a letter.
Company name where the name varies from 10 und 50 positions.
Euro currency rate (to Moroccan DH).
Fax number
f. You want a table listing for P_DESCRIPT, P_INDATE, P_PRICE, V_CODE from the
PRODUCT table where P_INDATE is after January 10, 2001 and the P_PRICE is more than
$75.00, and V_CODE = 24288. Write the command sequence to obtain the wanted results.
(1PT)
Question 2 (10/30)
1.
(5 PT)
The Hudson Engineering Group (HEG) has contacted you to create a conceptual model whose
application will meet the expected database requirements for its training program. The
HEG administrator gives you the following description of the training group's operating
environment:
The HEG has 12 instructors and can handle up to 30 trainees per class. HEG offers five
"advanced technology" courses, each of which may generate several classes. If a class has
fewer than 10 trainees in it, it will be canceled. It is, therefore, possible for a course not to
generate any classes during a session. Each class is taught by one instructor. Each
instructor may teach up to two classes or may be assigned to do research. Each trainee may
take up to two classes per session.
Given this information, do the following:
a. Draw the E-R diagram for HEG. (3PT)
b. Describe the relationship between instructor and course in terms of connectivity,
cardinality, and existence dependence. (2PT)
2. Given the dependency diagram shown below: (5PT)
C1
C2
C3
C4
C5
a. Identify and discuss each of the indicated dependencies.
(1PT)
b. Create a database whose tables are at least in 2NF, showing the dependency diagrams
for each table.
(2)
c. Create a database whose tables are at least in 3NF, showing the dependency diagrams
for each table.
(2)
Question 3 (6/30)
True/False
Indicate whether the sentence or statement is true or false.
1. The Chen model is especially useful to illustrate some of the conceptual elements of database
design.
2. The physical model operates at the highest level of abstraction.
3. Cardinality expresses the specific number of entity occurrences associated with an occurrence
of a related model.
4. REATE DOMAIN DISCOUNT_RATE AS NUMBER (5,2) CHECK (VALUE IN (SELECT
DISCOUNT FROM DISCOUNTBL));
You can draw domain values from other tables by including the SELECT statement in the
CHECK clause.
5. Since computers identify all characters by their numeric codes, mathematical operators can not
be used to place restrictions on character-based attributes.
6. The conditional LIKE must be used in conjunction with wildcard characters.
Question 4 (7/30)
Multiple Choice
Identify the letter of the choice that best completes the statement or answers the question.
1. Which of the following could be defined as a field in a database?
a.
b.
c.
d.
d.
Customer_Name
Address
Phone_Number
ZIP CODE
all of the above
2. When creating a table, what happens when you do not assign a field as primary key?
a.
b.
c.
d.
The table will not have a primary or foreign key.
The program will select one of your fields as primary key.
The table will not have a primary key but it will have a foreign key.
The program will create an ID field and assign it as primary key.
3. The SQL command that lets you save your work to disk, is
a.
b.
c.
d.
e.
insert.
select.
commit.
update.
rollback.
4. The SQL command that enables you to make changes in the data is
a.
b.
c.
d.
e.
insert.
select.
commit.
update.
rollback.
5. To remove the value 2238/QPD from the product table you must use the following command
a.
b.
c.
d.
DELETE FROM PRODUCT WHERE P_CODE = '2238/QPD';
REMOVE FROM PRODUCT WHERE P_CODE = '2238/QPD';
ERASE FROM PRODUCT WHERE P_CODE = '2238/QPD';
ROLLBACK FROM PRODUCT
WHERE P_CODE = '2238/QPD';
6. To select a character-based attribute ( 1558-QW1) from the product table you would write your
query command
a.
b.
SELECT P_CODE, P_DESCRIPT, P_ONHAND, P_MIN, P_PRICE
FROM PRODUCT
WHERE P-CODE = '1558-QW1'
SELECT P_CODE, P_DESCRIPT, P_ONHAND, P_MIN, P_PRICE
FROM PRODUCT
WHERE P-CODE = "1558-QW1"
c.
d.
SELECT P_CODE, P_DESCRIPT, P_ONHAND, P_MIN, P_PRICE
FROM PRODUCT
WHERE P-CODE = (1558-QW1)
SELECT P_CODE, P_DESCRIPT, P_ONHAND, P_MIN, P_PRICE
FROM PRODUCT
WHERE P-CODE = {1558-QW1}
7. The basic SQL aggregate function that gives the number or rows containing not null values for the
given column is
a.
b.
c.
d.
e.
COUNT
MIN
MAX
SUM
AVG
Download