Hi All,
I use erwin for data modelling. I tried to use EJB CMP 2.0 to implements by database tables. I ran into this design problems and i guess i am awefully stuck.
Consider this scenario,
Employee {
employeeId(pk),
DeptId(pk),
employeeName,
postalAddress
}
Department {
DeptId(pk),
DeptName,
Location
}
As per my requirement, each employee should be belonging to a department. so there exists a identifying relationship between the employee and department and the deptId is carried over to the employee table as part of the primary key.
(.)Now in the employee bean, is the deptId a CMP field or a CMR field? where will i set my primary key - in ejbCreate or in ejbPostCreate?
(.)what will my primary key class contain? two Integer Fields? or one integer field and one field of type local Remote interface to Department bean?
(.) how will my findByPrimaryKey work?
Any help will be greatly appreciated.
Ram.
-
primary key - modulling problem (3 messages)
- Posted by: ram ram
- Posted on: January 11 2003 05:07 EST
Threaded Messages (3)
- primary key - modulling problem by Sriram rk on January 12 2003 03:00 EST
- primary key - modulling problem by ram ram on January 13 2003 02:00 EST
- primary key - modulling problem by Ferhat SAVCI on January 13 2003 04:44 EST
-
primary key - modulling problem[ Go to top ]
- Posted by: Sriram rk
- Posted on: January 12 2003 03:00 EST
- in response to ram ram
Use a Primary Key class for the composite primary key in the employee bean and Integer type for your department bean. -
primary key - modulling problem[ Go to top ]
- Posted by: ram ram
- Posted on: January 13 2003 02:00 EST
- in response to Sriram rk
thanks for the help,
i too thought of the same approach. but this question remains. what is the dept Id? cmp field or cmr field? in abstract xml schema?
ram. -
primary key - modulling problem[ Go to top ]
- Posted by: Ferhat SAVCI
- Posted on: January 13 2003 04:44 EST
- in response to ram ram
Hmm, employeeId is not unique... Peculiar requirement.
Anyway, I would leave aside data modelling and go for O2R mapping. Just adding oIDs would solve the problem (that's what they are for):
Department (oID(pk), DeptId,...)
Employee (oID(pk),DeptOID(fk),EmployeeId,...)
Set unique contraint on DeptOID+EmployeeId or better yet, check it as a business rule.
Now, DeptOID is surely a CMR field.