I'm very new about relational-database and wonder how should I design my database generally like case as follows:
Conditions
- There are five articles in my apps and those are able to be bookmarked by users and also those articles are defined as uniqe
articleidlikea,b,c,d,e. - There are three users in my apps and users are defined as uniqe
useridlike1,2,3. - Finally, I should manage or control the relations of which articles are bookmarked by specified users.
I leard that I can choose following ways technically but wonder which shuold be choosed for good paerformance and maitainance genellary.
■ case1 Managing those relations in single table. allmixedtable
| userid | articleid |
|---|---|
| 1 | a |
| 1 | c |
| 1 | d |
| 2 | d |
| 3 | b |
| 3 | e |
■ case2 Creating usertable and managing those relations in several tables respectivley.
user1table
| articleid |
|---|
| a |
| c |
| d |
user2table
| articleid |
|---|
| d |
user3table
| articleid |
|---|
| b |
| e |
■ case3 Managing those relations in sigle table as array
| userid | articleid |
|---|---|
| 1 | [a,c,d] |
| 2 | [d] |
| 3 | [b,e] |
I feel case1 is the best but in terms of performance of serching certin records using userid key others could be better.
I understand that it depends on a situation but want to know as general thinking.
I'll do appreciate your helpful comment, thank you!