• Post Reply Bookmark Topic Watch Topic
  • New Topic

What if the PK is also a FK ???

 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What should the procedure (in ejbCreate() and ejbPostCreate() ) be if our (a concat one) PK is also a FK (cmr field)???

Suppose table COmpanyEmail:
companyID -> PK and FK
email -> PK

We cannot set both at ejbCreate() because companyID is a CMR field, but, on the other hand we must set both at ejbCreate() because the PKs must be set in ejbCreate().
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Leandro

What kind of relation is the table (companyId,email)? If you can let us know your database model a little bit it would be more helpful.

Because if it sounds confusing, it may be confusing by design itself.

Thanks
Maulin
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also I think you are trying to model "Relation table" using Entity bean hence facing the problem (just a guess from your earlier post...)

Regards
Maulin
 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maulin, this is not a relation table (this is a 1..N relation)
I got a table COMPANY with fields:
- companyID (PK)
- companyName
- companyType
- etc...

Then, i got a table COMPANY_EMAIL with fields.
- email (PK)
- companyID(PK and also a FK)


Note that i'm not really interested if this is the best database shema model, but on how to specifically model this situation with Entity CMPs.

Ye, i know i could change the database schema in this case (making only the email a PK), but i'm sure that situations like this may happen again and i might not be apple to change the database schema. That's way i'm looking for a solution for that.

If you need more information to help me, let me know.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay I see how it is now...

Well, its not a problem. It happens as CompanyEmail is Weak entity. I have similar things dealt with as I had Rule and Condition objects where Condition was WeakEntity and ConditionKey must have RuleID in there..

I will let you know tomorrow what did I do there..


Thanks
Maulin
 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you can use CMR field option in the CMP for this Entity Bean Model.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!