review database design

chapter 5: developing a data model
1. attribute, class and relationship
2. two or more relationship between class: cause by a special member or historical data
3. different routes of classes
   1.avoid data redundancy, can not have two route to get a answer.data will be inconsistent.
   2.two or relationship is needed,when one route can not get the answer.
   3. Fan trap: one class has two many relationship to other classes.
   4. chasm trap: add an other category for uncategroied data.
   5. relationship of class itself
4. relationship involved more than two class.

chapter 6: generalization and specialization
   1. when two classes have the same relation ship to another class, consider superclass and subclass them.
   2. multisubclass two subclass can be achieved by superclass composite an interface and have two subclass to implement the interface.
   3. using inheritance only when it is required, some time a composition is enough.

Summary about the database design:
1. requirement analysis--> use case--> data model. data model are not represent the problem. it represent the data that you think is necessary to store for the problem. how the data will be used. when designing, keep asking what problem will be resolved and how the data will help.
2. polish the data model
   1. optional and cardinality relationship between classes
   2. new class are needed when two or more class are connected to have a relationship
   3. self relationship
   4. 1-many relationship consider historical data
   5. when two or more classes have the same relationship to another class, think about inheritance.
   6. if two class have two relationship, that must have different relation  information of the two class
3. data model to relational database.
   1. 1-many relationship add a new field (the foreign key, primary key of the 1 side) to the many side.
   2. constrain of the foreign key to maintain 1-1 relationship.
not null, force an 1-many, null is a 0..1-many.
   3. inheritance is a 1-0...1 relation.
   4. using normalization to double check data consistency.
4. use data--crud, and retrieve data.




你可能感兴趣的:(database)