?
Solved

J2EE.EJB.container-managed-relations: Are they necessary?

Posted on 2004-07-30
8
Medium Priority
?
237 Views
Last Modified: 2013-12-03
I'm creating several entity beans that use CMP to access a MySQL database. I've already added constraints to the tables in the database using SQL commands. However, I read that the constraining relationships between entity beans (one-to-one, one-to-many, etc.) can also be specified in the deployment descriptors (xml files). If I were to make use of these container-manged-relations, would it still be necessary to use foreign key constraints in the database? If I choose to leave all of the constraints in the database, is there a reason to specify contain-managed-relations?

Thanks.
0
Comment
Question by:bobwood2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
8 Comments
 
LVL 30

Accepted Solution

by:
Mayank S earned 2000 total points
ID: 11687592
Treat the database as a separate, independent entity. The database should be a replica of the real-world objects, so if the relationship actually exists, the database should reflect it.

Today, you're using an EJB to access it. Tomorrow, you might be accessing the DB through a .NET application or through some other application (or maybe just simple queries/ stored procedures).

The DB design and relationships should always be complete.
0
 

Author Comment

by:bobwood2000
ID: 11719634
Thanks.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 11723055
Welcome, but why a B :-( ? I thought I gave sufficient explanation.
0
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

 
LVL 30

Expert Comment

by:Mayank S
ID: 11723057
I hope you know about the grading system at EE.
0
 

Author Comment

by:bobwood2000
ID: 11738738
I thought Mayankeagle gave a helpful response, and since it was the only response I received, I accepted it. However, it did not fully answer the question I asked, so I thought B ("good") was more appropriate than "perfect". Upon reading about the grading system, I see that I may have misused the grading system. If so, please change the grade to an A. Thanks, and sorry for difficulty.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 11742282
Thanks, bobwood2000. The answer I gave was short but I guess that it was concise and complete. I gave you at least 3 vital reasos why you should maintain the relationships in the database:

1. The database should be a complete replica of the real-world entities that it represents and so, the relationships must be complete.

2. The database is a separate entity, so treat it as one. Don't couple it to your J2EE application.

3. Maintaining the database relationships prefectly will help you access it from any other application, like a C# or VB or ASP .NET application too, because it is indeed a separate entity accessible from anywhere.

:-)
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question