简体   繁体   中英

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 PROCESS es (like CustomerOrderPlaced, CustomerOrderCancelled etc.) and ACTIVIT ies 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) ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM