Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to map?

 
Grady Jamyson
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem about OR mapping.

The situation is:
Branches have departments, and each department of branch could
have groups. And sometimes, groups could directly belong to branch but not
department.

Suppose I have the following classes,

Class Branch
-------------
int branchID
String name
Department[] dept
Group[] group

Class Department
----------------
int deptID
String deptName

Class Group
----------------
int groupID
String groupName

How to set dept and group in branch table?
Are these three classes could satisfy the situation?

Thanks for advise.
 
karl koch
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what ORM tool are you using ?
k
 
Loren Rosen
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the real significance of the department/branch/group distinction? Do you need to store very different data for each? Are their lots of business rules regarding their behavior?
 
Grady Jamyson
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't use any ORM tool.
I just want to know how to map the classes to the relational tables.
 
Grady Jamyson
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the distinction of the department/branch/group is not very obvious.
Because they all have names, id ...etc.
But their relationship is like a tree. For instance,
branch has some departments, and departments have groups,
and sometimes branch has groups.

And their bahaviors are not all the same, just like different employees in different departments don't have the same behaviors.
 
Loren Rosen
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the reason I ask: One approach is to just use a single class (and corresponding table), called, say, OrganizationalUnit. There could also be an OUType class, essentially an enumeration. Then label the OUs with their types, and enforce the requirements about fits where in the tree as business rules. One reason for doing it this way is that the rules may change over time.
 
Grady Jamyson
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. I will try the method you said.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic