I have a database that's formatted like this:
URLID USERNAME URL
0 jake abc.com
1 jake 123.com
2 po google.com
3 po googl3.com
4 po ranoutoffakeurlslol.com
However, I want it to be something like this:
USERNAME URLS
jake {abc.com, 123.com}
po {google.com, googl3.com, ranoutoffakeurlslol.com}
How would I do it? If it's not possible, then, how can I make method 1 more efficient?
Thanks in advance!
解决方案
Since this is a one-to-many relationship (i.e. one user can be associated with many URLs) you should create a separate table for storing the URLs:
URLID USERNAME
1 jake
2 po
URLID URL
1 abc.com
1 123.com
2 google.com
2 googl3.com
2 ranoutoffakeurlslol.com