Solved

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

Posted on 2004-07-30
8
214 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
  • 4
  • 2
8 Comments
 
LVL 30

Accepted Solution

by:
Mayank S earned 500 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

776 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