UML Model/Relation Db Table Mapping Design For LiteMda - Draft
来源:互联网 发布:java英文日期格式 编辑:程序博客网 时间:2024/05/17 22:38
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
- UML Model/Relation Db Table Mapping Design For LiteMda - Draft
- Domain Object Layer Design and Sample Code for LiteMDA
- LiteMDA Design Version 0.2
- LiteMda Design Ver 0.1
- Could not determine type for: model.Student, at table: Contact, for columns: [org.hibernate.mapping.
- Relation Model
- create table for db
- UML for Database Design
- DB design from UML to SQL
- LiteMda - my thinking in mda and aop - framework diagram draft
- Django 的 model 处理,它是一种 ORM (Object Relation Mapping, 对象与关系的映射)
- MSQL Design Draft.2013
- relation data model
- how to mapping phoenix table for hive
- mybatis generator 根据table 创建mapping、dao、model
- Object Relation Mapping—ORM
- CRM TABLE AND RELATION
- Cakephp Tip: Break naming convention between DB table and model
- LiteMDA中支持Generic的BusinessObjectFactory实现
- Domain Object Layer Design and Sample Code for LiteMDA
- LiteMDA Design Version 0.2
- ORM中的对象间关联及其默认事务需要 - The Object Associations And The Default Transaction Requirements In ORM
- O/R Mapping中对象关系映射解决方案汇总
- UML Model/Relation Db Table Mapping Design For LiteMda - Draft
- LiteMda Design Ver 0.1
- LiteMda - my thinking in mda and aop - framework diagram draft
- 为AjaxHelper0.51进一步扩展JSRS的MVC支持及一个基于JSRS的Whois查询范例
- JavaScript Remote Scripting In AjaxHelper Ver 0.5
- 两篇觉得比较好的今年高考满分作文
- 几个AjaxHelper范例程序的在线演示
- 推荐一个非常好的C#的开源Wiki程序Perspective
- AjaxSideBarV0.1目标功能