Uploaded by YC 17

Homework 1

advertisement
Database Systems
CMP 320
Homework 1
Bashar Husein
B00079456
1.5) Describe two different types of database end users? Discuss the main activities of each.
Naïve end users make up a large section of end-users. They use canned transactions, which are
previously well-defined functions. Most mobile app users fall in this category, including social
media users.
Sophisticated end users are usually business analysts, scientists, engineers, and others familiar
with the system capabilities. Many use tools in the form of software packages that work closely
with the stored database.
1.6) Discuss two of the capabilities that should be provided by a DBMS.
Two capabilities that should be provided by a DBMS are:
-
Restricting unauthorized access to data; only the DBA staff uses privileged commands.
Enforcing integrity constraints on the database
1.9) What is the difference between controlled and uncontrolled redundancy?
Redundancy means having the same data stored multiple times in the DBMS. If they are
uncontrolled, they can have inconsistencies that can cause problems when trying to merge tables.
Also, if a change needs to be made, it must be done to each file separately. If there is controlled
redundancy, it makes sure that all the data is the same across all the files, as well as improves
performance of queries. It also allows for the change in one file to be done on all the files
associated with that data.
2.3) What is the difference between a database schema and a database state?
A database schema is the description or definition of the database, including structure, data
types, and constraints. It is part of metadata and should be constant.
A database state, commonly referred to as a database instance, is the data stored in a database at
a particular moment in time.
2.6) What is the difference between procedural and nonprocedural DMLs?
Data Manipulation Languages are split into procedural and nonprocedural. The main difference
between the high level (non-procedural) and the low level (procedural) is that the high level is
“set”-oriented and specifies what data to retrieve rather than how to retrieve it while the low
level retrieves data one record at a time.
2.9) What is the difference between the two-tier and three-tier client/server architectures?
The main difference between the two-tier and the three-tier is that the clients of the three-tier
client-server architecture talks to the web server, and the web server talks to the database server.
The web server, an intermediate layer, stores the web connectivity software and business logical
part used to access the database server. It acts like a conduit for sending partially processed data
between the database server and the client. In the two-tier client-server architectures, users
interact with specialized servers using client software. They interact directly with the data in the
database server.
5.4) What is the difference between a key and a superkey?
A superkey is a set of attributes of a relation where no 2 tuples in r(R) have the same value. A
key is a minimal superkey, where attributes that are not needed are removed from the superkey
set, so it contains the bare minimum to be able to uniquely identify each tuple.
5.8) Discuss the entity integrity and referential integrity constraints. Why is each considered
important?
Entity integrity states that primary key attributes cannot have null values in any tuple because the
primary key is used to uniquely identify a tuple. If null values are allowed, that tuple would not
be identifiable. Also, if null values are allowed, two tuples can have the same value for their
primary key, which defies the rules of primary keys.
Referential Integrity is a relationship among tuples in two relations: a referencing relation and a
referenced relation. Tuples in the referencing relation have foreign key attributes that reference
the primary key attributes of the referenced relation. It is important because it can be used to
separate information into a different table to avoid redundancy which is not allowed, as well as
ensures consistency between the tables of the referencing relation and a referenced relation.
5.11) Suppose that each of the following Update operations is applied directly to the database
state shown in Figure 5.6 (shown below). Discuss all integrity constraints violated by each
operation, if any, and the different ways of enforcing these constraints.
a. Insert <‘Robert’, ‘F’, ‘Scott’, ‘943775543’, ‘1972-06-21’, ‘2365 Newcastle Rd,
Bellaire, TX’, M, 58000, ‘888665555’, 1> into EMPLOYEE.
No integrity constraints violated.
b. Insert <‘ProductA’, 4, ‘Bellaire’, 2> into PROJECT.
Violates referential integrity since there is no DEPARTMENT with the Dnumber 2. The DBMS
will reject the insertion. The user can change the Dnum to a valid Dnumber from the
DEPARTMENT table (1, 4, or 5).
c. Insert <‘Production’, 4, ‘943775543’, ‘2007-10-01’> into DEPARTMENT.
Violates key constraint since there already is a department with the Dnumber 4. The DBMS will
reject the insertion. The user can change the Dnumer of the Production department to a value
other than 1, 4 or 5.
Violates referential integrity since there is no employee with the Ssn 943775543. The DBMS will
reject the insertion. The user can change the Mgr_ssn of the Production department to a valid Ssn
from the EMPLOYEE table.
d. Insert <‘677678989’, NULL, ‘40.0’> into WORKS_ON.
Violates entity integrity since the Pno is part of the key but is set to null. The DBMS will reject
the insertion. The user can change the Pno to a value a valid Pnumber from the PROJECT table.
Violates referential integrity since there is no employee with the Ssn 677678989. The DBMS will
reject the insertion. The user can change the Essn of the insertion to a valid Ssn from the
EMPLOYEE table.
e. Insert <‘453453453’, ‘John’, ‘M’, ‘1990-12-12’, ‘spouse’> into DEPENDENT.
No integrity constraints violated.
f. Delete the WORKS_ON tuples with Essn = ‘333445555’.
No integrity constraints violated.
g. Delete the EMPLOYEE tuple with Ssn = ‘987654321’.
Violates referential integrity since it is referenced in many relations in other tables (2 tuples in
WORKS_ON, 1 tuple in DEPENDENT, 1 tuple in DEPARTMENT). The DBMS will reject the
deletion. The user can delete all the tuples from the all the tables that have a relationship with the
tuple of the Ssn 987654321 from the EMPLOYEE table.
h. Delete the PROJECT tuple with Pname = ‘ProductX’.
Violates referential deletion since it is referenced in two tuples in the WORKS_ON table. The
DBMS will reject the deletion. The user can delete the tuples with the Pno of 1 in the
WORKS_ON table.
i. Modify the Mgr_ssn and Mgr_start_date of the DEPARTMENT tuple with Dnumber
= 5 to ‘123456789’ and ‘2007-10-01’, respectively.
No integrity constraints violated.
j. Modify the Super_ssn attribute of the EMPLOYEE tuple with Ssn = ‘999887777’
to ‘943775543’.
Violates referential integrity since there is no employee with the Ssn 943775543. The DBMS
will reject the change. The user can change the Essn of the insertion to a valid Ssn from the
EMPLOYEE table.
k. Modify the Hours attribute of the WORKS_ON tuple with Essn =
‘999887777’ and Pno = 10 to ‘5.0’.
No integrity constraints violated.
Download