Professional Documents
Culture Documents
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.
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.
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
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.
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;