You are on page 1of 5

Database System

1. A. What are some reasons why using a spreadsheet is not a good alternative to using a large-scale database? Using a spreadsheet is not a good alternative to using a large-scale database because its scale difficult to use for multiple uses, it does not offer transaction control, the cells in a spreadsheet can contain any type of data, and referential integrity controls between spreadsheet are difficult to implement efficiently. Why would you choose a database system instead of simply storing data in operating system file? Because database is an integrated collection of data, usually so large that it has to be stored on secondary storage devices such as disks or tapes. This data can be maintained as a collection of operating system files, or stored in a DBMS. 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 to store 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 DBMS) 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 and Organization 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. 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. Why have client/Server systems become so prevalent in the business world? Because all system provides high capacity when backup and have high security, so we need to use client/server system to perform this operation. What is logical data independence and why is it important? Logical Data Independence is a type of data transparency that matters for a centralized DBMS. It refers to the immunity of user applications to make changes in the definition and Organization of data. Logical data independence is important because when have any Change in conceptual schema, it will not change in the external schemas and their Associated application programs. cal Explain the difference between logical and physical data independence? The difference between logical and physical data independence are: Logical Data Independence: Logical data independence is the ability to modify the conceptual schema without having alteration in external schemas or application programs. Alterations in the conceptual schema may include addition or deletion of fresh entities, attributes or relationships and should be possible without having alteration to existing external hips schemas or having to rewrite application programs. Physical Data Independence: Physical data independence is the ability to modify the inner schema without having alteration to the conceptual schemas or application programs. Alteration he in the internal schema might include. * Using new storage devices. * Using different data structures. * Switching from one access method to another. * Using different file organizations or storage structures. ge * Modifying indexes. Explain the difference between external, internal, and conceptual schemas. How are These different schema layers related to the concepts of logical and physical data Independence?


The difference between external, internal, and conceptual schemas are: - Internal schema: at the internal level to describe physical storage structures and access path for the database. Typically use a physical data model. - Conceptual schema: at the conceptual level to describe the structure and constraints for the whole database for a community of users. Use a conceptual or an implementation data model. - External schema: at the external level to describe the various user views. Usually uses the same data model as the conceptual schema. What is Security? List and explain two type of security? Security is data access to users is restricted. There are two type of security: - System privileges: allows a user to perform certain action within the database such as executing SQL Data Definition Language (DDL) statements. - Object privileges: allows a user to perform certain actions on database object, such as executing SQL Data Manipulation Lan Language (DML) statements.

9. A.

2. A.


10. 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. 11. Compare and contrast the main tasks carried out by DA (Data Administrator) and DBA (Database Administrator). A. - DA: providing a common umbrella for a large collection of data that shared by several users. - DBA: can effectively shield end-users from the chores of fine users fine-turn in the data Representation, periodic back-ups etc. ups 12. 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. 13. 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 concepts that make up real-world events. It is very important because it has developed a common understanding of the problem and the solution to communicate the desired structure and behavior of our systems. 14. Describe the step of database design.


5. A.

6. A.

7. A.

REQUIREMENTS COLLECTION AND ANALYSIS Functional Requirements Data Requirements



High-Level Transaction Specification

Conceptual Schema (In a high-level data model)




Logical (Conceptual) Schema (In the data model of a specific DBMS)



Internal Schema

Application Programs


1. Requirements collection and analysis - Document data requirements. - Functional requirements + User-defined operations or transaction including retrievals and updates. defined 2. Conceptual Design - Using a high level conceptual data model.

- Concise description of the data requirements + Entities, relationships and constrains - Not concerned with implementation / storage details. - (High-Level) Confirm that conceptual schema meets the identified functional requirements. 3. Logical Design (Data model mapping) - Map conceptual schema to a implementation data model (e.g. relational data model) 4. Physical Design - Specify internal storage structure, indices, access paths and file organizations. 15. Identify the main tasks associated with step 1 of logical database design. A. The main tasks associated with step 1 of logical database design is Create and Check ER Model. This steps will do as the following tasks: - Identify entities. - Identify relationships. - Identity and associate attributes with entities or relationships. - Determine attribute domains. - Determine candidate, primary, and alternate key attributes. - Specialize / Generalize entities (optional step). - Check model for redundancy. - Check model supports user transactions. - Review model with users. 16. 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. 17. Describe the definition of words that are used in relation database below: - Foreign key: is a reference to a key in another relation. - Key attribute: is one or more attribute, whose values uniquely identify each entity. - Composite key: a candidate key that consists of two or more attribute. - Atomic / Simple attribute: an attribute composed of single components with an independent existence. - Composite attribute: an attribute that can be further subdivided to yield additional attribute. - Multi-valve attribute: an attribute that holds a multiple values for a single entity. - Single-value attribute: an attribute that can have only a single value for a single entity. - Derived attribute: an attribute that represents a value that is derivable from that value Of a related attribute or set of attribute, not necessarily in the same entity. 18. Discuss the differences between the candidate keys and the primary key of a table. Explain what is meant by a foreign key? How do foreign key of tales relate to candidate keys? Give examples to illustrate your answer. A. The different between the candidate key and primary of a table are: - Candidate key: is one or more attribute, whose values uniquely identify each entity. - Primary key: the candidate key selected to be the primary key. Foreign key is a reference to a key in another table. Foreign key also candidate key that store in other table. example, we have table Student and Score as below: Student StuID StuName Sex 1 N Score StuID SubID Score

20. Describe the main phases involved in database design. A. The main phases involved in database design are: - Conceptual Design: create model that captures major entities, relationship among entities, and attributes of entities required for particular system. - Logical Design: transform the major entity / attribute / relationship requirements into high-level specification for database. Then improve the high-level database specification. - Physical Design: transform the high-level specification for database into detailed specification for how to construct actual database in a specific relational database software. 21. Identify important factor in the success of database design. A. The factor that is important in the success of database design are: - Work interactively with the users as much as possible. - Follow a structured methodology throughout the data modeling process. - Use diagrams to represent as much of the data model as possible. - Good documentation of additional data semantics. - Build a data dictionary to supplement the data model diagrams. - Be willing to repeat steps. 22. Discuss the main activities associated with each step of the logical database design methodology. A. The main activities associated with each step of the logical database design methodology: 1. Build and validate local logical data model - Map local conceptual data model to local logical data model. - Derive relations from local logical data model. - Validate model using Normalization. 2. Build and validate global logical data model - Merge local logical data model to global logical data model. - Validate global logical data model. - Draw final entity-relationship diagram. 23. Transform the following ER diagram to a relational schema that shows referential integrity constrains. BookID Title PName PAddress PPhone

Book M



Book Copies

Book Loads


DueDate BranchID N Library-Branch Borrower BPhone BanchName A. Address BName BAddress CardNo

The Relational Schema that transform form ER diagram above is: Book BookID Title AuthorName 1 1 N N Book Copies BookID BrandID NoOfCopies 1 Libray-Branch BranchID 1 BranchName Address

Publisher PName PPhne PAddress

Book Loads BookID N BrandID CardNo DueDate DateOut

N N Borrower CardNo BName BPhone BAddress

Table Student choose attribute StuID to store in table Score as a Foreign key. 19. What is the difference between a unary relationship, a binary relationship, and a ternary relationship? A. The difference of these 3 relationships is: - Unary relationship: a relationship is maintained within a single entity. - Binary relationship: relationship of two entities. - Ternary relationship: relationship of three entities.

24. Transform the following ER diagram to a relational schema that shows referential integrity constrains.

29. 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 Relational Schema that transform form ER diagram above is:

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) Or S.snum In (Select E.snum From Class C, Enrolled E, Faculty F) Where And C.fid=F.fid And F.fname=I. Teach; Find b.Find the names of all students who are enrolled in two classes that meet at the same time. - Select Distinct S.sname From Student S Where S.snum in (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. and 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.fname From Faculty F Where 5 > (Select E.snum From Class C, Enrolled E Where and 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.sname From Student S Where S.snum in (Select E.snum From Enrolled E Group by E.snum Having Count(*) >= All (Select count (*) From Enrolled E2 Group by E2.snum)); g. Find the names of students not enrolled in any class. - Select Distinct S.sname From Student S Where S.snum not in (Select E.snum From Enrolled E); 30. Why do you study Normalization data? A. We study Normalization data because it is a technique for producing a set of tables with desirable properties that support the requirement of a user or company. And it also a technique to reduce data redundancy and repeating group data.

25. What are the two major components of SQL and what function do they server? A. The two major components of SQL are: - DDL (Data Definition Language) There are 6 function: Create, Drop, Alter, Rename, Grant, Revoke. - DML (Data Manipulation Language) There are 4 function: Select, Insert, Delete, Update. 26. What is the different a subquery and join? Under what circumstances would you not be able to use a subquery? A. The different between subquery and join are: - Subquery: is a method of finding one answer using another query. - Join: is the method of joining one or more tables together and find a answer. In join both the tables should have a common column name but subquery without having a column name we can execute the query. 27. 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 ild key in parent table. - Not null: is the most straight forward of all the constraints. It specifies that a column will not allow NULL values. - Check: can apply directly to a specific column, or it can apply at the table level if the Constraint 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 two el rows contains the same value for the column or columns that have the Unique constraint. 28. How are Primary Key constraint and Unique constraint different? A. The difference between Primary Key constraint and Unique constraint are: - Primary key: + ensure that no two rows contains the same value. + Not allow NULL value. + Have only one primary key in a table. - Unique: + ensure that no two rows contains the same value. + Have more than one Unique key in a table.

31. Describe the characteristic of a table that violate first normal f form (1NF) and then describe how such a table is converted to 1NF. Provide an example to illustrate your uch answer. A. First Normal From (1NF) says that all column values must be contains only one value (not allow multiple value) and column of table not allow repeating group. Example: Department DNumber DName Manager 1 Research Dara 2 Administrator Socheat 3 Head Quarters Vichet Dep_Location DNumber 1 1 1 2 3 DLocation Kadal PP PV PP PP

Department relation normalize into two 1NF relations: Department and Dep_Loaction. 32. Describe the characteristic of a table in second normal form (2NF).Describe an approach to converting a first normal form (1NF) table to second normal f form (2NF) table. Provide an example to illustrate your answer. A. Second Normal Form(2NF) only applies to tables with composite primary keys. A table That is in 1NF in which the values of each non non-primary-key column can be worked out

(fully functional dependent) from the values in all the columns that make up the primary key. It not allow Partial dependant. Example: Emp_project: PNumber Hours SSN Emp SSN EName Project PNumber PName PLocation 33. Describe the characteristic of a table in third normal form (3NF). Provide an example to illustrate your answer. A. Third Normal Form(3NF) is a table that in 1NF and 2NF and in which no non-primary-key Column is transitively dependent on the primary key. Example: InvoiceNo InvoiceDate CustomerID

123423479 130 Nitts 550227043 340783453

Vichet Daren


65 65

07 07


CustomerID CustomerName Address 34. You are hired to implement an object-relational database schema for Gill Art Gallery Company. The database schema consists of the following business requirements. The Gill Art Gallery wishes to maintain data on their customers, artists and paintings. They may have several paintings by each artists in the gallery at one time. Paintings may be bought and sold several times. In other worlds, the gallery may sell a painting, then buy it back at a late date and sell it to another customer. Sample Reports and Screen Gallery Customer History Form Problem: Customer Name a. Describe and illustrate the process of normalizing the data from information requirement above to Fist Normal Form (1NF), Second Normal Form (2NF), and Jackson, Elizabeth Phone (206) 284-6783 Third Normal Form (3NF). 123 4th Avenue b. Transform ON result in 3NF to ERD. Fonthill, your A. a. The process of normalizing the data from information above as below: L3J 4S4 - First Normal Form (1NF) + Sale_Hist Purchases Made (SaleNo, Cust_name, Cust_addr, Phone) + Sale_Hist_details (SaleNo, Artist, Title, Purchase_Date, Sale_Price) Artist Second Normal Form (2NF) Title Purchase Date Sales Prices + Sale_Hist (SaleNo, Cust_name, Cust_addr, Phone) 03 Carol Channing Laugh with Teeth 09/17/2000 7000.00 + Sale_Hist_details (SaleNo, ArtistNo, Purchase_Date) 15 Dennis Frings South toward Emerald Sea 05/11/2000 1800.00 + Channing 03 Carol Artist (ArtistNo,the Movies At Title, Sale_Price) 02/14/2002 5550.00 15 Dennis Frings South (3NF) 07/15/2003 2200.00 - Third Normal Formtoward Emerald Sea + Customer (CustNo, Cust_name, Cust_addr, Phone) + Sale_Hist (SaleNo, CustNo (FK)) + Sale_Hist_details (SaleNo, Artist, Purchase_Date) + Artist (ArtistNo, Title, Sale_Price) b. Transform the result in 3NF to ERD. ArtisNo Title M N SaleNo CustNo

- 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.

36. You are hired to implement an object-relational database schema for a Project, Inc.,. The database schema consists of the following requirement. Project, Inc., is an engineering firm with approximately 500 employees. A database is Required to keep track of all employees, projects assigned, and departments worked in. Every employee has a unique number assigned by the firm, required to store his or her name and date of birth. If an employee is currently married to another employee of projects, Inc, the data of marriage and who is married to whom is married to an employee. Each Employee is given a job title(for example, engineer, secretary, and so on) An employee dose only one type of job at any given time, and it is only needed to retain information for an employees current job. There are 11 different departments, each with a unique name. An employee can report to only one department. Each department has a phone number. To procure various kinds of equipments, each department deals with many vendors. A vendor typically supplies equipment to many departments. It is required to store the name and address of each vendor and the date of offering between a department and a vendor. An employee can work on many project. Each projects can have many employees work. Projects are distinguished by project number, and the estimated cost of each project must be stored. Problem: a. Create an Entity-Relationship (ER) model of the data requirements for the Projects, Inc. case study using Chen-Style ER notation. State any assumptions necessary to support your design. b. Derive a relational schema from your ER model that represents the entities and relationships. Identify primary and foreign key. A. a. Create and Entity-Relationship (ER) model. DeptID DeptName M VID N Vname


Sale_Hist Details


Sale_Price Purchase_Date

Was bought

Department Phone 1
Work in



Title OfferDate


CustNo Cust_name

1 DOM Customer

N 1 Employee 1





Phone Cust_addr

EmpName 35. 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:
ProjID 100 Proj-Name E-Commerce Proj-Mgr-ID 789487453 Emp-ID 123423479 980808980 234809000 542298973 110 Distance-Ed 820972445 432329700 689231199 712093093 120 Cyber 980212343 834920043 380802233 553208932 EmpName Vichet Dara Danith Rithy Sokun Kunthea Sokein Vutha Manith Dyna Emp-Dept MIS TeachSupport TechSupport TeachDoc MIS TeachSupport TeachDoc Engineerring TeachSupport TeachDoc EmpHrly-Rate 65 45 45 30 65 45 30 80 45 30 TotalHrs 10 6 6 12 5 12 8 4 11 12





Derive a relational schema to entities relationship. 1 Department DeptID DeptName Phone 1 N Supplied DeptID VID OfferDate 1 N Vedor VID VName Address

Worked in DeptID N EmpID Title

1 N 1

Employee EmpID EmpName DOB


Works EmpID ProID

Married EmpID DOM

Project ProID ProName Cost