Solved

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

Posted on 2004-07-30
8
226 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 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

738 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