开发者

Database Table design problem

Scenario: There is a hierarchy of PROCESS. Like

PR-2, PR-3 are children of Pr-1,

PR-4, PR-5 are children of PR-2

Now the leaf processes (in our case PR-3, PR-4 and PR-5 can be described in terms of series of ACTIVITY

Now, 开发者_运维百科ACTIVITY is just a child of PROCESS but has some extra attributes, so

Should I make two diff. tables in the database (one for ACTIVITY and one for PROCESS)?

or

Should I add some fields (for extra attributes of ACTIVITIY) in the PROCESS table and store the ACTIVITY in PROCESS table.

=================================== EDITED ======================================

Actually, here PROCESS AND ACTIVITY are the one's that involved in BPM (Businees Process Management)

Those who have knowledge of BPM can figure out what ACTIVITY AND PROCESS are.

Those who don't know BPM, I explain you what I mean by PROCESS and ACTIVITY.

Any enterprise has various PROCESSes (like CustomerOrderPlaced, CustomerOrderCancelled etc.) and ACTIVITies are like parts of a process which are to be performed to complete the process.

So, ACTIVITY is a child of PROCESS with some extra attributes.

Or in terms of Java, ACTIVITY extends PROCESS


As soon as you say "ACTIVITY are like parts of a process", "ACTIVITY extends PROCESS" is no longer a valid statement. It's not an is-a relationship. It's a has-a relationship.

In ER terms there is a one-to-many relationship between Process and Activity. Or possibly a many-to-many relationship if one Activity belongs to multiple Processes.

For example, CustomerPlacesOrder is a Process. The Activities are:

  • Customer fills shopping Cart;
  • Customer checks out;
  • Customer enters delivery and billing info, registering if necessary;
  • Worker receives order;
  • If the items are in stock, the Worker selects an appropriate packing container and fills it;
  • Worker send it on the daily deliveries.

Or however complicated you want to get. Inheritance this is not.


You should have multiple tables. The tables can be like below:

ProcessTable

ID (Primary Key)
ProcessName
ProcessCode ...

ActivityTable

ID (Primary Key)
ActivityName
ActivityCode
ActivityDesc
ProcessID (Foreign Key to ProcessTable) ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜