Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

class design vs. db design

Thread view: 
John_Woo - 19 Dec 2006 12:32 GMT
Hi,

if I want to reflect a 1:1 relationship for user:account, the design
model may be:

for class:
A.    User
   -------------
  int user_id;
 int account_id;

B.  User
    ------------
   int user_id;
   Account account;

for db:
C. User (user_id int); Account(account_id int, user_id int)

D. User (user_id int, account_id int); Account (account_id int)

Questions:
1. How to compare A vs. B in terms of OO design, JDO (java data object)

2. How to compare A vs. B in terms of db schema (with foreign key
constraint)

3. C vs. D, which is better? should create user first or account first?

---
Thanks
John
Toronto
Oliver Wong - 19 Dec 2006 18:46 GMT
> Hi,
>
[quoted text clipped - 19 lines]
> Questions:
> 1. How to compare A vs. B in terms of OO design, JDO (java data object)

   I like B better. It looks like less work to get the account from the
user.

> 2. How to compare A vs. B in terms of db schema (with foreign key
> constraint)

   I suppose A would be slightly less work to implement a ORM for, but you
could just download an ORM like Hibernate to do the work for you, so I'd
still stick with B.

> 3. C vs. D, which is better? should create user first or account first?

   If the relation is 1:1, why not stick it all in one big table?

   - Oliver
John_Woo - 19 Dec 2006 20:27 GMT
> > for db:
> > C. User (user_id int); Account(account_id int, user_id int)
[quoted text clipped - 4 lines]
>
>     If the relation is 1:1, why not stick it all in one big table?

Good point, thanks,  Oliver.

but both these two tables may extend, like USER may have 10+ fields,
same as Account table.
if they have to be separated, I'm still looking for tips on selection
of model C, D

John


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.