You are on page 1of 5

Database System

1. Data Discuss the meaning of each of the following terms:


a. Database:is a system for storing complex, Structure information (table, file) on hard disk.
b. DBMS: A Database Management System (DBMS) is a software package designed tostore and manage
databases
c. Application program: implement these specifications as programs, then they test, debug, document, and
maintain these canned transactions.
d. Database System:A database system is a term that is typically used to encapsulate the constructs of a
data model, database Management system (DBMS) and database
e. Data independence:is the type of data transparency that matters for centralized DBMS.It refers to the
immunity of user application to make changes in the definition andOrganization of data.
f.Views: is essentially some subset of the database.
g. Meta-data:is an emerging practice with close ties to librarianship, information science, information
technology.

2. Explain the three type of database architecture below:


a. Single-tier architecture: all on one machine access by terminals.
b. Two-tier architecture:has only database server can provide to more client using data.
c. Three-tier architecture: tow kings of DBMS connected by middleware.

3. Why have client/Server systems become so prevalent in the business world?


A. Because all system provides high capacity when backup and have high security, so we need to use
client/server system to perform this operation.

4. What is distribute database? Descript the reason why use the distributed database.

-Distributed database: A single logical database that is spread physically across computers in multiple locations
that are connected by a data communication link. Because It is important to distinguish between distributed and
decentralized databases
5. Transaction គឺជាការធ្វើការជាកញ្ចប់ពេលជួប Error វានឹង Roll back ទិន្នន័យទាំអស់នោះមកវិញ Ex: When do transaction and store data Table
deposit and and update to transaction when meet error it will rollback data back, coz make sure data is be safe

6. What are the responsibilities of a DBA? If we assume that the DBA is never interested in running his or
her own queries, does the DBA still need to understand query optimization?Why?
A. The responsibilities of a DBA are:
- Designing the logical and physical schema.
- Security and authorization.
- Data availability and recovery from failures.
- Data tuning.
DBA need to understand because some of these responsibilities (database design and tuning) are related to
query optimization.

7. Explain the following in terms of providing security for a database:


- Authorization: is providing permission.
- Views: show all information for user.
- Backup and Recovery: is one of the most important aspects or database administration.
- Integrity: define data to store.
- Encryption: check constrain, protect data avoid from hacker.
- RAID: Synchronization of HDD.

8. What is data modeling? Why is it important?


A. Data modeling is the analysis of data objects that are used in a business. Data modeling focuses on
representing the data as the user actually sees it, bridging between the conceptsthat make up real-world events. It
is very important because it has developed a commonunderstanding of the problem and the solution to
communicate the desired structure and behavior of our systems.

9. Explain the following terms briefly: attribute, domain, entity, relationship, entity set,
relationship set, one-to-many relationship, many-to-many relationship, participation
constraint, weak entity set. Give examples to illustrate your answer.
A. - Attribute: a property of an entity or a relationship type.
Ex: number and balance are attributes of account entity.
- Domain: is the set of allowable values for one or more attributes.
- Entity: an instance of an entity type that is uniquely identifiable.
Ex: account and customer are entities.
- Relationship: an association of entities where the association includes one entity from each participating
entity type.
Ex: a cust_acct relationship associate a customer with each account he or she has.
- Entity Set: is a collection of related entities.
Ex: all persons having an account at a bank.
- Relationship set: is a set of relationship of the same type.
Ex: Binary Relationship Set, Ternary Relationship Set.
- One-to-Many Relationship: an entity in A is associated with any number in B. An entity in B is associated
with at most one entity in A.
Ex: There are many products in one brand.
- Many-to-Many Relationship: entities in A and B are associated whit any number from
each other.
Ex: There are many customer have many account in a bank.
- Participation Constraint:
- Weak Entity Set: is indicated by a doubly-outlined box.
Ex: Weak entity transaction depend on strong entity account.

10. What is constraint? Explain the 5 type of constraint.


A. Constraints are a way to validate the data in a column or columns of a table.
There are 5 type of constraint:
- Primary key: is similar to a Unique constraint, with two exception:
+Not allow NULL value.
+Have only one primary key in a table.
- Foreign key: maintain the data integrity between a parent table and a child table. It Allows you to define a
column in the child table that exists as a primary key or a unique key in parent table.
- Not null: is the most straight forward of all the constraints. It specifies that a columnwill not allow NULL
values.
- Check: can apply directly to a specific column, or it can apply at the table level if theConstraint must
reference more than one column. It useful if you need to keep value of a Column within a certain range or within a
list of specific values, such as M or F.
- Unique: can be applied at the column level or at the table level. It ensures that no tworows contains the same
value for the column or columns that have the Unique constraint.
11. Transform the following ER diagram to a relational schema that shows referential
integrity constrains.
BookID Title PName PAddress PPhone

N 1
Book B-P Publisher

M
AuthorName
DateOut
Book NoOfCopies Book
Copies Loads

DueDate
BranchID

N CardNo

Library-Branch Borrower
BPhone
BanchName Address BName
BAddress

The Relational Schema that transform form ER diagram above is:

Book 1 N Book Copies 1 Libray-Branch


BookID BookID BranchID
1 N 1 BranchName
Title BrandID
AuthorName NoOfCopies Address
N

Book Loads
BookID
N BrandID N
Publisher CardNo Borrower
PName DueDate N CardNo
PPhne 1 DateOut 1 BName
PAddress BPhone
BAddress

12. Transform the following ER diagram to a relational schema that shows referential Integrity constrains.

A. The Relational Schema that transform form ER diagram above is:


13. With reference to sample Microsoft Access database call University. Please consider
the following relations:
Student (snum: integer, sname: string, major: string, level: string, age: integer)
Class (name: string, meets at: string, room: string, fid: integer)
Enrolled (snum: integer, cname: string)
Faculty (fid: integer, fname: string, deptid: integer)

The meaning of these relations is straightforward; for example, Enrolled has on record per
student-class pair such that the student is enrolled in the class.
Write the following queries in SQL. No duplicates should be printed in any of the answers.
a. Find the age of the oldest student who is either a History major or enrolled in a course
taught by I. Teach.
- Select Max(S.age) From Student S Where (S.major=’History’) OrS.snumIn
(Select E.snumFromClass C, Enrolled E, Faculty F) Where E.cname=C.name And
C.fid=F.fidAndF.fname=’I. Teach’;

b. Find the names of all students who are enrolled in two classes that meet at the same time.
- Select Distinct S.snameFromStudent S WhereS.snumin (Select E1.snum From
Enrolled E1, Enrolled E2, Class C1, Class C2, Where E1.snum=E2.snum and
E1.cname <> E2.cname and E1.cname=C1.name and E2.cname=C2.name and
C1.meetat=C2.meetat);

c. Find the names of faculty members for whom the combined enrollment of the course
that they teach is less than five.
- Select Distinct F.fnameFrom Faculty F Where 5 > (Select E.snumFrom Class C,
Enrolled E Where C.name=E.cnameand C.fid=F.fid);

d. For each level, print the level and the average age of students for that level.
- Select S.level, AVG(S.age) as [average of student] From Student S Group by S.level.

e. For all levels except JR, print the level and the average age of student for that level.
- Select S.level, AVG(S.age) as [average of student] From Student S
Where S.level<> ‘JR’ Group by S.level;

f.Find the names of students enrolled in the maximum number of classes.


- Select Distinct S.snameFrom Student S Where S.snumin (Select E.snumFrom
Enrolled E Group by E.snumHavingCount(*) >= All (Select count (*)From
Enrolled E2 Group by E2.snum));

g. Find the names of students not enrolled in any class.


- Select Distinct S.snameFromStudent S Where S.snumnot in (Select E.snumFrom
Enrolled E);
14. Suppose that you have table Project that does not in Normalization (unnormalized
table) as figure below Fig 1.1. Please Derive to 1NF, 2NF and 3NF Relation. Explain.
Project:
Total-
Proj-ID Proj-Name Proj-Mgr-ID Emp-ID Emp-Name Emp-Dept Emp-Hrly-Rate
Hrs
100 E-Commerce 789487453 123423479 Vichet MIS 65 10
980808980 Dara TeachSupport 45 6
234809000 Danith TechSupport 45 6
542298973 Rithy TeachDoc 30 12
110 Distance-Ed 820972445 432329700 Sokun MIS 65 5
689231199 Kunthea TeachSupport 45 12
712093093 Sokein TeachDoc 30 8
120 Cyber 980212343 834920043 Vutha Engineerring 80 4
380802233 Manith TeachSupport 45 11
553208932 Dyna TeachDoc 30 12
123423479 Vichet MIS 65 07
130 Nitts 550227043 340783453 Daren MIS 65 07

A. - First Normal Form (1NF)


+Project (Proj-ID, Proj-Name, Proj-Mgr-ID)
+Project_Details (Proj-ID, Emp-ID, Emp-Name, Emp-Dept, Emp-Hrly-Rate, Total-Hrs)
Note: a employee can work for multiple project, therefore Employee ID is included as
part of the key.
- Second Normal Form (2NF)
+Project (Proj-ID, Proj-Name, Proj-Mgr-ID)
+Project_Details (Proj-ID, Emp-ID, Total-Hrs)
+Employee (Emp-ID, Emp-Name, Emp-Dept, Emp-Hrly-Rate)
Note: The Total-Hrs is the fully-functional dependant of the Proj-ID and Emp-ID.
Therefore, we separate the employee information in to the Employee table. The
employee information is Partial dependent.
- Third Normal Form (3NF)
+Project (Proj-ID, Proj-Name, Proj-Mgr-ID)
+Project_Details (Proj-ID, Emp-ID, Total-Hrs)
+Employee (Emp-ID, Emp-Name, Emp-Dept)
+Department (Emp-Dept, Emp-Hrly-Rate)
Note: The Emp-Hrly-Rate is the transitively dependent, so we separate it in to
Department table and put the primary key of Department table as a foregien key of
Employee table.

You might also like