Reputation: 3993
I am planning to store sitemaps with related data per url
wanted to know which is better :
creating new table per user / website
for each website, save all urls (with its data or in separate column) as an array in 1 row
save each url as separate row with the main website as identifier
Explained:
each user will have his own table, with all urls in their own rows
table will have columns: id, user, website, urls
for all urls of same site, it will save them as an array next to that particular website and user
Upvotes: 1
Views: 256
Reputation: 2256
You do not want to create a new table for each user. Put it all in one table.
Upvotes: 0
Reputation: 141829
A good Design would look like this:
Table 1 (User -> Websites one to many relation):
User (PK) | Website (FK)
Table 2 (Website -> URLs one to many relation):
Website (PK) | URL
PK = Primary Key
FK = Foreign Key
I think this is similar to your option 3 except or the separation into two tables to not store redundantly which user a website belongs to in every row.
You also may want to make a Websites table that just stores associates a website to an id:
Website Id (PK) | URL
Where you store the main URL of the website in this table, like "stackoverflow.com and then store relative urls in the (Website -> URL) relation table like "questions/8116983/which-is-better-using-multiple-rows-tables-or-arrays-in-mysql.
Then you would use Website Id's in Table 1 and 2 as well instead of Websites.
Upvotes: 2