M
M
Michael2017-05-10 20:22:15
MySQL
Michael, 2017-05-10 20:22:15

How to properly design a database for such a task?

Hello. The task is something like this:
There are 4 sites from which I receive news. There is a user who enters keywords. And every time the news arrives, I must send a link to it to the user if:
1) he indicated this site in the subscriptions
2) in the description of the news there is at least one keyword indicated by him.
And I can not understand how to design a DB in any way. If you take MongoDB, then something like this:

User = {
email: "[email protected]",
sites: ["ya.ru", "google.com"],
keys: ["spirt", "sport", "music"]
}

If to take MySQL I do not understand. I thought about making one table for each site, where emails of those who are subscribed to them would be stored in one column. And in a separate table, store the keywords for the user in the form of a long string, where the words are separated by commas. But again, I'm not sure if this is correct.
How to be?
PS I’ll clarify that there are only 4 sites. And the keywords for all users are different

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lega, 2017-05-10
@mak_ufo

If you take MongoDB, then something like this:
There is not much to think about, the norm is an option.
And store in a separate table
This is redundant, in mysql you can do the same as for mongodb

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question