zoukankan      html  css  js  c++  java
  • UML Model/Relation Db Table Mapping Design For LiteMda Draft

    In this article, I talk about the "UML Model/Relation Db Table Mapping Design" for LiteMda.

    What is "UML Model/Relation Db Table Mapping Design"?
    -To make the persistation of Domain Objects being transparent to Db Tables, it needs to find a way, as natually as possible, to represent all the kinds of associations among class objects.

    What kinds of associations need to be considered?
    -Generalization, Association, Directed Association, Self Association, Aggregation and Composition, .

    Then, let's deal with them on by one.

    Generalization

    ClassB generalizes ClassA means ClassB is a subclass of ClassA.



    Natually, we can uses two tables, TableA and TableB, to implement the mapping. TableB as the subclass needs including all the columns in TableA, and there will be two default transactions be implemented that when we insert a new row to TableB, we must also insert one in TableA, and when we delete rows in TableA, we must check if the related rows in TableB also need to be deleted. To represent the Generalization Hierarchy, we may use a global ID for each instance, and if, for one instance, there are more than one rows  in the tables, the global ID of them should be same.

    Association/Aggregation/Composition

    ClassB associates with ClassA means ClassB and ClassA have the references each other.



    ClassB aggregates ClassA means ClassA is one of the parts of ClassB.



    ClassB is composed of ClassA and some other classes means ClassA and some other classes can fully compose a ClassB.



    The reason that I talk about them together here is for O/R Mapping, they are some degree similar that they all need to associate with their related objects, having the references each other for each pair of objects.

    Since ClassB and ClassA have the references each other, we can use TableB and TableA ,and each table has a column as the friend key of the other, of cource, the main keys and friend keys are all global IDs. Transactions needed: delete.

    Directed Association

    ClassB directed associates with ClassA means ClassB has a reference to ClassA, but ClassA hasn't a back reference.



    Different from Association, only TableB has a column as friend key to TableA, and the main keys and friend keys are all global IDs. Transactions needed: delete.

    Self Association

    ClassA self associates with itself means ClassA has a reference to another ClassA.



    We can use TableA to represent ClassA, and TableA has a column as a friend key to TableA, and the main keys and friend keys are all global IDs. Transactions needed: delete.

    ----------------

    Something else:

    Two kinds of the basic associations aren't be discussed here, Realization(class generalize from an interface) and Dependency(class uses an interface or another class), because generally, they won't impact the Db Tables' structures for class objects.

    This article is a draft version, welcome any suggestion and criticism, thanks!

    //The End

  • 相关阅读:
    2018/2/26 省选模拟赛 0分
    2018/2/25 省选模拟赛 36分
    BZOJ 2428 JZYZOJ1533 : [HAOI2006]均分数据 模拟退火 随机化
    BZOJ 4036: [HAOI2015]按位或 集合幂函数 莫比乌斯变换 莫比乌斯反演
    BZOJ 3196 Tyvj 1730 二逼平衡树 树套树 线段树 treap
    POJ 2728 JZYZOJ 1636 分数规划 最小生成树 二分 prim
    JZYZOJ1998 [bzoj3223] 文艺平衡树 splay 平衡树
    POJ 3974 Palindrome 字符串 Manacher算法
    BZOJ 1013: [JSOI2008]球形空间产生器sphere 高斯消元
    jQuery cookie使用
  • 原文地址:https://www.cnblogs.com/teddyma/p/194924.html
Copyright © 2011-2022 走看看