I have a question about the relationship between two tables.
Let's say we have table users and links.
users
+++++++++
id name
1 name1
2 name2
3 name3
+++++++++
links
+++++++++
id link
1 link1
2 link1
3 link1
+++++++++
Now the usual way to link these two to the name_links table. For instance:
name_links
++++++++++++
uid lid
1 1
1 3
2 3
2 1
2 2
3 2
++++++++++++
Now I was wondering if it would be nice to make a table like this
name_links
++++++++++++
uid lid
1 1,3
2 1,2,3
3 2
++++++++++++
The pros and cons that I can think of are as follows:
pros1:
You will always search by indexes, for faster queries select an example where uid = 1, and then select links 1.3. Both are indexes, so they will be a fast load.
If you have 1000 users and each of them has 20 links, this means that you need to go through 20,000 entries to get all the links (I think I'm not sure about that). Using this method, you accept only one index, and you're done.
cons1:
name_links, , 2 2, :
+ 1
+
+
, , .
cons2:
- 2, , , , .
, , , , .
, . ? , . .
, !