Sie sind auf Seite 1von 14

CST363 online – Database – CSU Monterey Bay – Spring 2017a – Final Exam

CST 363 Final Exam


Multiple Choice. Indicate the single best answer. (3 points each)

1. Another term for IS-A relationships is


a. Subtype entities
b. Related entities
c. HAS-A relationship
d. 1:1 relationship

Ans. a

2. Students enroll in one or more courses each semester. This is an example of


a. HAS-A relationship between entities STUDENT and COURSE.
b. IS-A relationship between entities STUDENT and COURSE.
c. A relationship with maximum cardinality of 1.
d. Weak entities.

Ans. a

3. To retrieve data records in a certain order


a. Physically store the records in order
b. Use a linked list so that each record contains a pointer to the next record in order
c. Use a B tree index
d. Use a hash index
e. All of the above are correct.
f. All of A, B and C are correct.

Ans. f

4. A column can be defined with the NULL attribute to indicate


a. a data value is missing
b. the attribute is not applicable to this entity.
c. a default value should be inserted by the DBMS.
d. A and B
e. A, B and C.

Ans. a

5. Dirty read is
a. Re-reading data that was previously changed by the program.
b. Reading data that been committed by another request but the DBMS has not had time
to write the data to the hard drive yet.
c. Reading data that was modified by another program but then the program decided to
undo the modification.

Ans. c

Page 1 of 14
CST363 online – Database – CSU Monterey Bay – Spring 2017a – Final Exam

6. Nonrepeatable read is
a. Reading data and then later in the same transaction finds that the record has changed.
b. Two requests read the same record and get different values.
c. A request reads a record and then commits. It later reads the record again and finds
that it has changed.

Ans. a

7. The names of the ANSI isolation levels, in order from least to most restrictive are
a. dirty read, non repeatable read, phantom read
b. serializable, repeatable read, read committed
c. read committed, repeatable read, serializable
d. autocomit, read comit, repeatable read, serializable

Ans. c

8. The payroll department accidentally runs the wrong payroll database update program on Friday
at 2:00pm The error is caught a few minutes after the program has terminated normally. The
best way to recover from this error is
a. restore the database to the last backup
b. restore the database to the last backup and apply all log records since the backup
c. restore the database to the last backup and apply all log records between the last
backup and Friday 1:59pm just before the erroneous updates.
d. tell the payroll department that it is too bad and nothing can be done.

Ans. c

9. You attempt to recover a database using the latest backup but find the backup file is corrupted.
What can do you?
a. Nothing. The data is lost.
b. Use the next latest backup and use all logs since that backup.
c. Don’t worry. The DBMS will automatically use the logs to repair the corrupted backup.

Ans. b

10. On Friday at 2:46pm there is an power failure and the database server stops. When power is
restored what should you do?
a. Restore all database to the last backup and apply logs.
b. Do nothing. The DBMS will automatically recovery all committed transactions and undo
any uncommitted transactions.
c. You need to use the logs to undo any uncommitted changes to the data.
d. You need to use the log to redo committed changes that were buffered in RAM and not
written to the hard drive.
e. You need to do both C and D using the appropriate command.

Ans. b

Page 2 of 14
CST363 online – Database – CSU Monterey Bay – Spring 2017a – Final Exam

11. SQL views can be used to


a. create virtual tables that are summaries of data tables.
b. hide columns from a user
c. hide rows from a user
d. provide additional security that a user can only select or update certain columns or rows
in a table that contain their user id.
e. B and C and D only.
f. All of A, B, C and D.

Ans. f

12. If I want to allow user1 to read and update the jrj.customer table I would do the following sql
a. grant update on jrj.customer to ‘user1’@’%’
b. give read, write on jrj.customer to ‘user1’@’%’
c. grant select, update on jrj.customer to ‘user1’@’%’
d. give select, update on jrj.customer to ‘user1’@’%’

Ans. c

13. What does the “WITH GRANT” keyword do on an SQL DCL statement
a. give all privileges owned by the user to another user
b. give specified privileges to another user and allow that user to give them to other users
c. give DBA administrator privileges to the user
d. gives administrator privileges to another user but only for the specified table

Ans. b

14. Given the following table and data

Key LastName Rank Room Shift


1 Smith Manager 34 AM
2 Johnson Custodian 33 PM
3 Smith Custodian 33 Evening
4 Doe Clerk 222 AM

Which is a candidate key for this data?

a. LastName
b. Room
c. Shift
d. {Rank, Room}
e. {Room, Shift}

Ans. e

Page 3 of 14
CST363 online – Database – CSU Monterey Bay – Spring 2017a – Final Exam

Short Answer– answer with a few well writen sentences.

15. Normalization (4 points)


a. Give an example of a modification problem? Give as many specifics as possible such as
an example table and values of rows and why this is a modification problem.

Ans. It is a situation that exists when the storing of one row in a table records facts
about two themes or the deletion of a row removes facts about two themes, or when a
data change must be made in multiple rows for consistency. The modification anomalies
can plague a database if you don’t structure the SQL database correctly. To prevent
these problems, you can normalize the database structure. Consider the following Sales
table:

Table: SALES

Customer_id Item Price


1001 Detergent 15
1007 Toothpaste 3
1010 Bleach 4
1024 Toothpaste 3

Suppose your company sells household cleaning products, and you charge all customers
the same price for each product. The SALES table keeps track of everything for you.
Assume that customer 1001 moves away and no longer is a customer. You don’t care
what he’s bought in the past, because he’s not going to buy anything from you again.
You want to delete his row from the table.

If you do so, however, you don’t just lose the fact that customer 1001 has bought
laundry detergent; you also lose the fact that laundry detergent costs $15. This situation
is called a deletion anomaly. In deleting one fact (that customer 1001 bought laundry
detergent), you inadvertently delete another fact (that laundry detergent costs $15).

You can use the same table to illustrate an insertion anomaly. For example, suppose you
want to add stick deodorant to your product line at a price of $2. You can’t add this data
to the SALES table until a customer buys stick deodorant.

The problem with the SALES table is that this table deals with more than one thing: It
covers not just which products customers buy, but also what the products cost. To
eliminate the anomalies, you have to split the SALES table into two tables, each dealing
with only one theme.

Table1: Cust_Purch

Customer_id Product
1001 Detergent

Page 4 of 14
CST363 online – Database – CSU Monterey Bay – Spring 2017a – Final Exam

1007 Toothpaste
1010 Bleach
1024 Toothpaste
Table2: Product_Price

Product Price

Detergent 12

Toothpaste 3

Bleach 4

Table1 deals with the single idea of customer purchases.

Table2 deals with the single idea of product pricing.

You can now delete the row for customer 1001 from CUST_PURCH without losing the
fact that laundry detergent costs $15. (The cost of laundry detergent is now stored in
Table2) You can also add stick deodorant to Table2 whether or not anyone has bought
the product. Purchase information is stored elsewhere, in the Table1. This process of
breaking up a table into multiple tables, each of which has a single theme, is called
normalization. A normalization operation that solves one problem may not affect other
problems.

b. How would normalization fix this problem? Show what the tables you gave in part a
look like after normalization and explain how this fixes the modification problem from
part a.

Ans. Please see above answer a

Page 5 of 14
CST363 online – Database – CSU Monterey Bay – Spring 2017a – Final Exam

16. Atomic. (8 points)


i. What does the term “atomic” mean in database processing?

Ans. In database systems, atomicity is one of the ACID transaction properties. An atomic
transaction is an indivisible and irreducible series of database operations such that
either all occur, or nothing occurs. A guarantee of atomicity prevents updates to the
database occurring only partially, which can cause data inconsistency issue. As a
consequence, the transaction cannot be observed to be in progress by another database
client. At one moment in time, it has not yet happened, and at the next it has already
occurred in whole (or nothing happened if the transaction was cancelled in progress).

ii. Why is it important that program work in an “atomic” manner?

Ans. It is very important that the program work in an “atomic” manner. In most
database applications, users submit work in the form of transactions, also known
as logical units of work . A transaction is a series of actions to be taken on a database
such that all of them are performed successfully or none of them are performed at all, in
which case the database remains unchanged. Such a transaction is sometimes called
atomic because it is performed as a unit. Consider the following sequence of database
actions that could occur when recording a new order:
1. Change the customer record, increasing the value of Amount Owed.
2. Change the salesperson record, increasing the value of Commission Due.
3. Insert the new-order record into the database.
Suppose the last step fails because of insufficient file space or any other unknown issue.
Imagine the confusion that would ensue if the first two changes were made but the
third one was not. Thecustomer would be billed for an order that was never received,
and a salesperson would receive a commission on an order that was never sent to the
customer. Clearly, these threeactions need to be taken as a unit: Either all of them
should be done or none of them should be done.

iii. What is the php statement that is used to start a transaction in mysql?

Ans. beginTransaction();

iv. What is the php statement that will terminate a successful transaction in mysql?

Ans. commit();

You are applying for a bank loan. The loan officer wants to determine how much money you
have in your checking and saving accounts. At the same time you are transferring $10,000 from
your checking to your savings account. The following scenario occurs

You Loan Officer


Savings = $1500, Checking = $25,000
Read savings account. Return value $1500
Start Transaction

Page 6 of 14
CST363 online – Database – CSU Monterey Bay – Spring 2017a – Final Exam

Move $10,000 from checking to savings.


New Savings = $11,500 , checking = $15,000
Read checking. Return value $11,500
Commit Transaction
Total assets = $13,000

The Loan Officer report says you have $13,000 in assets. But actually you have $27,000 in assets
( combined checking + savings ).

17. What is the problem and how would you solve it? [Hint: what isolation level should the Loan
Officer program be using?] (2 points)

Ans. The problem type is dirty read because loan officer is able to read change before it is
actually committed. The loan officer program should be using read committed isolation level at
the minimum.

18. Give an example of a lost update problem? (2 points)

Ans. Let us consider the case where two users are about to update the same row/document in
some data store, e.g. let user A retrieve some row first. After that, assume that user B gets the
same row; however, B writes his update immediately, and in particular before A writes his
update. Then, the changes made by user B are silently overwritten by the update performed by
user A. This is known as the lost update problem. This situation can be shown as follows:

Time User A User B


1:00 Read
1:01 Read
1:02 Update
1:03 Update

19. Specify the SQL CREATE TABLE statements that would be used to implement the following E-R
model . Specify primary and foreign keys constraints. Specify appropriate data types and NULL
or NOT NULL properties for each attribute. (2 points)

Page 7 of 14
CST363 online – Database – CSU Monterey Bay – Spring 2017a – Final Exam

Ans.

CREATE TABLE IF NOT EXISTS `EMPLOYEE` (

`EmployeeNumber` INT NOT NULL,

`FirstName` VARCHAR(45) NULL,

`LastName` VARCHAR(45) NULL,

`Department` VARCHAR(45) NULL,

`Phone` VARCHAR(20) NULL,

`Email` VARCHAR(100) NULL,

PRIMARY KEY (`EmployeeNumber`));

CREATE TABLE IF NOT EXISTS `Project` (

`ProjectID` INT NOT NULL,

`ProjectName` VARCHAR(45) NULL,

`Department` VARCHAR(45) NULL,

`MaxHours` DECIMAL(9,2) NULL,

`StartDate` DATE NULL,

`EndDate` DATE NULL,

PRIMARY KEY (`ProjectID`));

20. A hard drive containing database JRJ crashes and all data is lost. Briefly describe what you
would do. You do not have to give specific MySQL commands, but you have to indicate the
steps. (2 points)

Ans. Step 1 : Restore Latest Full Backup

Step2: Apply all the binary logs from the full backup time to the time of crash

Page 8 of 14
CST363 online – Database – CSU Monterey Bay – Spring 2017a – Final Exam

If you need to create the Art Course tables for questions 20 - 29, use the file from iLearn

 Lab1 Art Course Tables.sql

21. What are the names of the tables created in the art course database? (2 points)

Ans. course, customer and enrollment

22. What are the names of the columns in the enrollment table? (2 points)

Ans. CustomerNumber
CourseNumber
AmountPaid

23. What is the datatype of the course.CourseDate column? (2 points)

Ans. DateTime

24. What are the foreign keys in the enrollment table? (2 points)

Ans. ENROLL_CUST_FK FOREIGN KEY (CustomerNumber)

REFERENCES CUSTOMER(CustomerNumber) &

ENROLL_COURSE_FK FOREIGN KEY (CourseNumber)

REFERENCES COURSE(CourseNumber)

25. Write a sql SELECT statement that will retrieve all the customers that have phone numbers in
the 360 area code and display the CustomerLastName, CustomerFirstname, CustomerID and
Phone. The result should be sorted by CustomerLastName. (2 points)

SELECT CustomerLastName,CustomerFirstName, CustomerNumber, phone

FROM customer where phone like '360%'

order by CustomerLastName;

26. Write an sql SELECT statement that will return the Course and CourseNumber and CourseDate
and the number of students enrolled in the the course. The result should be in Course
sequence. (2 points)

Page 9 of 14
CST363 online – Database – CSU Monterey Bay – Spring 2017a – Final Exam

Ans. Select C.Course,C.CourseNumber,C.CourseDate, count(C.Course) As Total

from Course C join enrollment E

on c.CourseNumber=E.CourseNumber

group by C.Course, C.CourseNumber,C.CourseDate

Order By C.Course;

27. Write an sql SELECT that returns all the courses that offered in October between ‘2015-10-01’
and ‘2015-10-31’ (2 points)

Select * from course where coursedate between


'2015-10-01' and '2015-10-31';

28. Write an sql SELECT that returns customer LastName, FirstName , the course name, the amount
paid and the required fee for customers who have NOT paid the full fee for the course they are
enrolled in. (2 points)

SELECT CustomerLastName, CustomerFirstName , course, AmountPaid,fee

FROM CUSTOMER cu JOIN ENROLLMENT e

ON cu.customernumber = e.customerNumber

JOIN COURSE co ON e.coursenumber = co.coursenumber

WHERE AmountPaid<>Fee;

29. Write an sql DELETE statement that will drop all enrollments for Ariel Johnson. (2 points)
Ans. delete from enrollment where CustomerNumber
= (select CustomerNumber from customer where CustomerLastName='Johnson'
AND CustomerFirstName='Ariel');
-OR-

delete from Enrollment where CustomerNumber=1;

# As this CustomerNumber=1

Page 10 of 14
CST363 online – Database – CSU Monterey Bay – Spring 2017a – Final Exam

30. Write an sql update statement that will change Lynda Myers name to Lynda Jackson. (2 points)

update customer set CustomerLastName='Jackson'


where CustomerNumber=7
and CustomerLastName='Myers'
and CustomerFirstName=’Lynda’;

Given a table of biology facts about animals and their habits (the following table shows a sample of
rows from the table)

Key CommonName Class Eats LifeExpectancy


1 Cat Mammal mice 15
2 Cat Mammal milk 15
3 Bear Mammal fish 30

31. Discuss whether this table is normalized? Explain your reasoning. (2 points)

Ans. The table is not normalized and is resulting into data redundancy. The CommonName, Class
and LifeExpectancy needs to be in a separate table and Eats need to go a new Entity.

32. Given the table of biological facts above, write a select statement for (8 points)
a. Find all animals that eat fish.

Ans. select * from Biology where Eats=’fish’;

b. Bears only eat fish. What is the select statement and what should the answer be to
show this statement is TRUE?
Ans. select * from Biology where CommonName=’Bear’ and Eats!=’fish’;
Your answer is correct in case you have NO ROWS returned .

c. What do cats eat?

Ans. select Eats from Biology where CommonName=’Ca’’;

d. What select statement and result would show that no animal eats sharks?

Ans. select * from Biology where Eats=’sharks’;

This should return 0 rows

Essay (8 points)

33. Describe in a few well written paragraphs recent trends in databases. Include in your answer
what the terms BigData, Data Warehouse, Star-Schema, NoSQL, Hadoop, Distributed Databases,
OODBMS mean, and how they are used to solve problems in the real world.

Page 11 of 14
CST363 online – Database – CSU Monterey Bay – Spring 2017a – Final Exam

Trends in Databases

The first ever revolution in the database technology was driven by the introduction of the
electronic computer, a lot powerful machines which could help process millions of records in
just few minutes and then the second by the emergence of the relational database. Some of key
players who claim to be the winner in this domain were IBM, Oracle, and Microsoft. At some
point DB2, Oracle and SQL Server along with a couple of other players dominated the entire
Relational Database Management System (RDBMS) market. It offered some of features like
performance, security, reporting capabilities right out of the box and became really popular in a
really short time frame.

In the meantime, with introduction of social media and online shopping becoming more and
more popular, the data volumes are growing really fast. The traditional RDBMS are finding it
hard to meet new processing needs or meet the new scalability requirements. Which is a causing
the seismic shift in the database landscape. Hadoop, Spark, MongoDB, Cassandra and many
other non-relational systems today form an important and growing part of the enterprise data
architecture of many big companies. The concept of Big Data is almost taking over the bigger
chunk of data processing needs and analysis. I can see that there is a great future ahead in the
recent divergence of database technologies which is followed by a period of convergence toward
some sort of unified model of databases.

It is quite possible that the disruptive new database technology is imminent; we can’t stop it
from happening, the big changes in database technology that have occurred within the last
decade or so represent as much change as we can easily accept. Now we will talk about some of
the trending technologies in the database domain. The first one is Big Data; It is a term that
describes the large volume of data, which is both structured and unstructured that help any
business on a day-to-day basis. It’s not the amount of data that’s important. It’s what
organizations do with the data that matters. The Big data can be analyzed for insights that help in
better decision making and strategic business moves. This concept has really gained the
momentum in early 2000s. Another open-source software framework for storing data and
running applications on clusters of commodity hardware is Hadoop. It provides massive storage
for any kind of data, huge processing power and the ability to handle virtually limitless
concurrent tasks or jobs. It is taking a big chunk of analysis part off the traditional RDBMS.

Page 12 of 14
CST363 online – Database – CSU Monterey Bay – Spring 2017a – Final Exam

Another one Data Warehouse, it is also known as an enterprise data warehouse, is a system
used for reporting and data analysis, and is considered a core component of business intelligence.
The Data Warehouses are central repositories of integrated data from one or more disparate
sources. We store current and historical data in one single place which can be used for creating
analytical reports for the management throughout the enterprise. It is worth mentioning here
about the Star Schemas, which is the simplest style of data mart schema and is the approach
most widely used to develop data warehouses and dimensional data marts. It consists of one or
more fact tables referencing any number of dimension tables. The star schema is an important
special case of the snowflake schema, and is more effective for handling simpler queries.

Another trending technology in the database domain is NoSQL; it is a collection of wide range of
technologies and architectures, seeks to solve the scalability and big data performance issues that
relational databases weren’t able to do. It is very useful when an enterprise needs to access and
analyze massive amounts of unstructured data or data that's stored remotely on multiple virtual
servers in the cloud. One of big player in domain is Cassandra.

A distributed database is a database in which storage devices are not all attached to a common
processor. It may be stored in multiple computers, located in the same physical location; or may
be dispersed over a network of interconnected computers. A distributed database system consists
of loosely coupled sites that share no physical components. An object database also object-
oriented database management system (OODBMS) is a database management system in which
information is represented in the form of objects as used in object-oriented programming. Object
databases are different from relational databases which are table-oriented.

Page 13 of 14
CST363 online – Database – CSU Monterey Bay – Spring 2017a – Final Exam

Feedback

You are given many surveys during this course to give feedback. Here is one more. But please do take
this one.

Textbook (choose the response you most agree with)


a) I read the textbook and I learned a lot from it….agree, but vidoes were also very usef
b) I mostly did not read the textbook and relied on the videos and other sources to learn what was
required in this course. I used the textbook mostly for the assignment questions.
c) I tried reading the textbook but found the author hard to understand. That might be because
we did not cover the book in sequence by chapter but rather skipped around.
d) I found the textbook hard to understand and it had nothing to do with the order of the chapters
we covered. I think the textbook is not very good.

Videos (choose the respone you most agree with)

a) l learned a lot from watching the videos from the instructor. ---Agree, we need to add more
small videos
b) The videos were ok but sort of dry and boring.
c) I mostly did not watch the videos and used other resources to get by in this course.

Assignments (indicate the assignment numbers for the following 3 questions)

 Of the 14 assignments in the course, I learned the most from <indicate which asssignment
numbers were most useful> ……all were unique and informative
 The assignments which were most difficult were <indicate which asssignment numbers > .
 The assignments which I found most confusing include <indicate which asssignment numbers >
..12.

Agree or Disagree The feedback I received on assignments, quiz and exams was useful and helped me
to learn. ….Agree, it helped me focus on each question

Agree or Disagree The grading of assignments, quiz and exams was fair. ….agree no question about it.

Agree or Disagree Writing a learning journal entry every week helped in my learning for this
course….Agree (it is boring but EOD help you better organize)

Any other comments you want to make: either positive or negative about anything in this course? If
you have feedback that will help me to improve the course, please write it here.

I think overall course was quite useful, the Teacher had a great wealth of knowledge on the
topic.

Page 14 of 14

Das könnte Ihnen auch gefallen