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
- same columns, but each sitemap will create many rows with 1 url per row
A good Design would look like this:
Table 1 (User -> Websites one to many relation):
Table 2 (Website -> URLs one to many relation):
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:
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.