That's exactly what indexes are for, and they are created/mantained "automatically" by your database. In fact, if you created such a table you would be duplicating information, as you would be repeating the original table key in n rows of your "relationship table" AND repeating the other key. It would be like an N-M relationship.
Graphically, something like... ( Table A and Table B, 1-N from A to B):
Table A
-------
A1, AData_1, ...
A2, AData_2, ...
Table B ------- B1, BData_1,..., A1 B2, BData_2,..., A1 B3, BData_3,..., A1 B4, BData_4,..., A2
with an extra table...
Table A ------- A1, AData_1, ... A2, AData_2, ...
Table B ------- B1, BData_1,... B2, BData_2,... B3, BData_3,... B4, BData_4,...
Table A_B ------- B1, A1 B2, A1 B3, A1 B4, A2
If you don't have any index on table B using the foreign key of table A, you might get some performance improvement but it is in this case where one would have "unnecessary data". I always recommend and use indexes and just two tables but...
Regards,
D.
David Nielsen escribi�:
As i undestand it: If I do it bidirectional in my example i would insert a row pr. mailmessage for each user i sent it to, it would gime a lot of similar mailmessages, with just the toUsers field changed, if you have a unidirectional relation with a relation table you would only have one row in mailmessages with the actual message and a lot of foreign key in the relation table thar points at this one message. so you would not have a lot of unnessesary data, and the database woulnd grow as big. Im not a pro database, but i would think it would give me some performance, if i just have a relation table which only contains keys to my actual tables.
Regards, David
On Thu, 2003-10-02 at 12:30, Daniel L�pez wrote:
Hi,
Do you really need an extra table when creating a unidirectional 1-n relationship? I've always used bidirectional relationships so I've never tried, but I don't see the reason why unidirectional ones would require such an extra table. May be I did not understand the statement below.
Cheers,
D.
Edward Kenworthy escribi�:
This is a unidirectional 1:m so yes you do need a relationship table.
... //snipped
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user
