mysql - Best way to relate multiple rows across tables -


i want know best practice relating 1 row in 1 table, multiple rows in table.

let's have following 2 tables:

table_users id    | username ------------------------------------------------------------------------ 1     | user1 2     | user2 3     | user3  table_texts id    | text ------------------------------------------------------------------------ 1     | secret text, user2 , user3 should see. 

now solution create third table:

table_user_text_relation id    | text_id    | user_id ------------------------------------------------------------------------ 1     | 1          | 2 2     | 1          | 3 

and select this:

select     table_texts.text       table_users, table_texts, table_user_text_relation      table_users.id = table_user_text_relation.user_id     ,     table_texts.id = table_user_text_relation.text_id 

and fine... however, if have 6000 users each access 500 texts, table_user_text_relation have have 3.000.000 rows establish many many relationships?

is there better / smarter way this?

this how it. have been searching long time , having match table best way. because match table uses ints, doesn't take room. best practice.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -