Hi,
I am pretty new to Hibernate, I have a very simple data modeling question ---
We have a composite key, it is the key for 10 of our total 30 tables, there is 2 way to design this,
a) put this composite key in each of 10 tables
b) put this composite key in a seperate table with a unique_id, and use this unique_id as key in the 10 tables
for a)
--------------------
Profile_table
--------------------
User_id (key1)
Site_id (key2)
profile_data
...
...
----------------------
and same for each of 10 tables
for b)
--------------------
User_table
--------------------
User_id
User_Master_id (key1)
Site_id (key2)
...
---------------------
---------------------
Profile_table
---------------------
User_id
profile-data
...
...
----------------------
Then use User_id in other tables
For a) I dont like it, because data redundency
For b) every time I retrieve data from a table like - Profile, I have to join the User-table,
so, the question is how difficult to do the join relationship in Hibernate? Could this join be generate automatically if I use hql. The problem is if I dont use Hibernate, there is no doubt for me to use (b), but by using hibernate, somebody argued the data better be in one table.
Any input are welcome, thank you very much.
|