資料庫--訓

最近蛋痛,把幾年前學的雙拼又拿起來。打字的速度顯著下降!

  • 1. Developing a data model
    • Attribute, class, or relationship?
      • Here are some examples of questions to help you decide. Might I want to select objects based on the value of an attribute? If the answer is yes, consider introducing a class for that information(create a grede class).

        我這裡有一些案例可以幫助你做出決定。我是否可能會根據一個屬性的值去選擇一個對象?例如,你是否可能會根據年級去選擇一個球隊?如果是,考慮為該信息引入一個表(類)(一個年級表)。
      • Am Ilikely now or in the future to store other data about this information? For example, might I want to keep additional information about the captain: phone, address, and so on? If yes, consider introducing a class.

        我是否可能現在或則在未來需要存儲該信息的其他數據。比如,我是否準備保存隊長的其他信息:電話、地址等等。如果想,考慮建立一個表(類)。

      • Am I storing (or should I be storing) such information already? For example, the information about a captain is the same or similar to infromation about members. Consider a relationship between existing class.

        我是否正在(或則應該)存儲這些信息?比如,隊長的信息和隊員的信息是很相似的。考慮在已經存在的表之間建立一個關係。
    • More than one relationship between two classes兩表之間不止一個關係
      • Consider more than one relationship between two classes if there is different information involving both classes. For example, a member might play for a team, captain a team, manage a team, and so on.

        如果兩表間都有不同的數據時就需要考慮多個關係。比如,一個球員可能效力於管理帶領一個球隊。
    • Consider self relationships自身關係
      • Objects of a class can be related to each other. For example, members sponsor other members, people are parents of other people. 表的對象之間可以相互關聯。比如,球員贊助其他球員百姓是百姓的父母
    • Different routes between classes 表之間的不同路徑
      • Check wherever there is a closed loop to see whether the same information is being stored more than once.

        檢測關係路徑是否包含閉路以便發現相同的信息是否被存儲了多次。
      • Check to ensure you are not inferring more than you should from a route; that is, look out for fan traps where a class is related to two other classes and there is a cardinality of Many at both outer ends.

        檢測儀確保你不會獲取到你不應該得到的數據;即小心Fan Trap,一個表和兩個其他表相關,關係外側的兩個類的集合都包含多個元素。

      • Check to ensure a path is available for all objects; that is look ourt for chasm traps(are there optional relationships along the route?).

        確保一條關係路徑可以通向所有對象;即Chasm trap問題。
    • Information dependent on objects of more than two classes
      • Consider introducing a new class where you need to know about combinations of objects from three or more class simultaneously; for example, which member played for which team in which match?

        當你需要同時從三個或以上的表中獲取一個組合對象時,考慮引入一個新的表。比如,那個球員效力於某個球隊,參加了某場比賽?
      • Any attributes inn the class must dependon particular combination of objects from each of the participating classes; such as, what do I need to know about a particular member playing on a particular team in a particular match?

        一個新表中的任一個屬性必須依賴每一個參與表的對象的特殊組合;比如,某個特定球員效力於某個特定的球隊,參與了某場比賽,對此我需要了解什麼?
      • Consider what information might be pertinent to two objects form pairs of the contributing classes; for example, what do I need to know about a particular member and a particular team independent of any match?

        考慮什麼信息可能成為兩個表之間的中心;比如,對於獨立於球賽的一個特定球員和一個特定球隊,我需要知道什麼?

推薦閱讀:

簡析關係型資料庫和非關係型資料庫的比較(下)
簡析關係型資料庫和非關係型資料庫的比較(上)

TAG:資料庫 | 資料庫設計 |