You are right :). But the key is that you are talking about an n-m relationship
between users and messages, not a 1-n. A 1-n relationship means ONE message is,
for example, created by ONE user and ONE user creates MANY messages. In your
case, ONE user can see MANY messages and one message can be seen by MANY users
-> MANY-MANY. In that case, you need, of course, an extra table, but I thought
we were talking about a unidirectional 1-N (see bottom of message). I might have
missed the point though :), it sometimes happens to me ;).
Cheers,
D.

> Ok. it might be,
> but i thougt that if i have a table with all users in and a table with
> all messages in and i want 10 users to se 1 message and i do the
> relation with foreign-key mapping i would insert 10 messages in the
> messages table that are exactly the same but with a diferent userkey in
> the userkey field.
> 
> if i use a relation table i would insert 1 messsage in the message table
> and 10 rows in the relation table. that only contains the key to the 10
> users and 1 message, then i would only fill message text in one row so
> it wouldnt fill the database with duplicates of the message.
> 
> 
> 
> 
> 
> On Thu, 2003-10-02 at 15:06, Daniel L�pez wrote:
> > Hi David,
> > 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 message was sent using Sake Mail, a web-based email tool from
Endymion Corporation.  http://www.endymion.com/products/sake
Ok. it might be,
but i thougt that if i have a table with all users in and a table with
all messages in and i want 10 users to se 1 message and i do the
relation with foreign-key mapping i would insert 10 messages in the
messages table that are exactly the same but with a diferent userkey in
the userkey field.

if i use a relation table i would insert 1 messsage in the message table
and 10 rows in the relation table. that only contains the key to the 10
users and 1 message, then i would only fill message text in one row so
it wouldnt fill the database with duplicates of the message.





On Thu, 2003-10-02 at 15:06, Daniel L�pez wrote:
> Hi David,
> 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
> 



-------------------------------------------------------
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

Reply via email to