Hw fdb(2)


Published on

Published in: Education, Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Hw fdb(2)

  1. 1. <ul><li>Please describe 3 phases if database design
  2. 2. Conceptual
  3. 3. The process of constructing a model of the data used in an enterprise, independent of all physical consideration.
  4. 4. Logical
  5. 5. The process of constructing a model of the data used in an enterprise based on a specific data model (eg. relational), but independent of a particular DBMS and other physical consideration.
  6. 6. Physical
  7. 7. The process of producing a description of the implementation of the database on secondary storage; it describes the base relations, file organization, and indexes design used to achieve efficient access to the data, and any associated integrity constraints and security measures.
  8. 8. What are the differences between conceptual and logical
  9. 9. Conceptual: The process of constructing the model is independent from all physical consideration.
  10. 10. Logical: The process of constructing the model is based on a specific data model, but independent of a particular DBMS and other physical consideration
  11. 11. How do you define the index on a column of a table
  12. 12. Index : a data structure that improves the speed of data retrieval operations on a database table at the cost of slower writes and increased storage space. Indexes can be created using one or more columns of a database table, providing the basis for both rapid random lookups and efficient access of ordered records.</li></ul>Please write a SQL statement about creating index<br />CREATE INDEX index_name ON table_name(column_name);<br /><ul><li>What are unary, binary, ternary, and quaternary? Give 1 example each
  13. 13. Unary relationships have only one participant-the relation is associated with itself. The classic example of a unary relationship is Employee to Manager. One's manager is, in most cases, also an employee with a manager of his or her own. It is also known as recursive relationship.
  14. 14. Binary relationships, the association between two entities is the most common type in the real world.
  15. 15. A ternary relationship involves three entities and is used when a binary relationship is inadequate. Many modeling approaches recognize only binary relationships. Ternary or n-ary relationships are decomposed into two or more binary relationships. 
  16. 16. Quaternary relationships involve four entities. For example a professor teaches a course to students using slides. Here the four entities are professor, slides, course, and student. The relationship between the entities are Teaches. Another example:
  17. 17. How do you use subclass and super class in ERD?
  18. 18. Superclass: An entity type that includes distinct subclasses that requires to be represented in data model. It is also known as generalization.
  19. 19. Subclass: An entity type that has a distinct role and is also a member of superclass. It is also known as specialization.
  20. 20. Please describe 2 common problems when you design a database (example)
  21. 21. One table hold all domain value
  22. 22. Ignoring normalization
  23. 23. Insufficient domain memory</li></ul>Occurrence of connection traps such as fan trap and chasm trap.<br />Fan Trap occurs where a model represents a relationship between entity types, but pathways between certain entity occurrences is ambiguous.<br />Chasm Trap occurs where a model suggests the existence of a relationship between entity types, but pathway does not exist between certain entity occurrences.<br /><ul><li>What is normalization? How do you use functional dependency? (2NF/3NF)
  24. 24. Normalization is a technique for producing a set of suitable relation that supports the data requirements of an enterprise and to minimize data redundancy.
  25. 25. The functional dependency can be classified as : full functional dependency, partial functional dependency and also transitive functional dependency. It makes use of Functional Dependencies that exist in a table (relation, more formally) and the primary key or Candidate Keys in analyzing the tables.
  26. 26. 1NF
  27. 27. Make sure that there is no data redundancy by eliminate repeating groups.
  28. 28. 2NF
  29. 29. Based on the concept of full functional dependency.
  30. 30. Full functional dependency indicates that if:
  31. 31. A and B are attributes of a relation
  32. 32. B is fully dependent on A if B is functionally dependent on A but on any proper subset of A.</li></ul>3NF<br />Based on the concept of transitive dependency.<br />Transitive dependency is a condition where:<br />A, B, and C are attributes of a relation such that if A -> B and B -> C<br />Then C is transitively dependent on A through B. (Provided that A is not functionally dependent on B or C).<br /><ul><li>Please create ERD for the following questions:
  33. 33. A holding company has several company and each company has 4 departments
  34. 34. Every employee only work for 1 department and 1 department only can have 10 employee
  35. 35. Every company has only one main business and every company’s business is different from each other
  36. 36. Please create global ERD for the following question
  37. 37. Big company has several apartment
  38. 38. So the employee of the company stay in the 1 room of the apartment
  39. 39. Every apartment has unique names and address and the capacity of the apartment and the number of floors
  40. 40. Every room identify by room number
  41. 41. Every employee will be assigned to 1 room of apartment
  42. 42. Every room has a phone number and has a parking lot number
  43. 43. One room may have or may not have a parking lot (NULL)
  44. 44. Each room associated one car number
  45. 45. Normalize the following table to 1NF, 2NF, and 3NF
  46. 46. 1NF</li></ul>2NF<br />Property(propertyno, paddress)<br />Propertyinspection(propertyno,idate,itime,comments,staffno,sname,carreg)<br />3NF<br />Property(propertyno,paddress)<br />Staff(staffno,sname)<br />Propertyinspection(propertyno, idate,itime,comments,staffno,carreg)<br /><ul><li>How the DBS run the query processing?
  47. 47. DBMS QUERY prepares the SQL statement (in general, one that returns rows) by indicating to the database engine where to put return data (if any), and then tells the database to execute the SQL statement.This command is used for statements, either SQL SELECT statements or stored procedures, that return data. For statements that do not return data, use DBMS RUN. Example :
  48. 48. DBMS QUERY SELECT title_id, name, dir_first_name, dir_last_name FROM table_name
  49. 49. What is the transaction?
  50. 50. A database transaction is a logical unit of database operation which is executed as a whole to process user requests for retrieving data or updating the database. An SQL transaction automatically begins with a transaction-initialing SQL statement (eg. SELECT, INSERT).
  51. 51. How to ensure the integrity while executing transactions?
  52. 52. Concurrency control techniques that include locking(e.q deadlock detection adn recovery) and time stamping. The concurrency control schedules transactions to avoid any interference. Secondly serializability identifies executions of transactions to ensure consistency
  53. 53. What are the property of transaction?</li></ul>The properties of database transactions are summed up with the acronym ACID:<br />Atomicity - all or nothing<br />All of the tasks (usually SQL requests) of a database transaction must be completed;<br />If incomplete due to any possible reasons, the database transaction must be aborted.<br />Consistency - serializability and integrity<br />The database must be in a consistent or legal state before and after the database transaction. It means that a database transaction must not break the database integrity constraints.<br />Isolation<br />Data used during the execution of a database transaction must not be used by another database transaction until the execution is completed. Therefore, the partial results of an incomplete transaction must not be usable for other transactions until the transaction is successfully committed. It also means that the execution of a transaction is not affected by the database operations of other concurrent transactions.<br />Durability<br />All the database modifications of a transaction will be made permanent even if a system failure occurs after the transaction has been completed.<br />