Answer the question
In order to leave comments, you need to log in
Is it possible to design a database table like this?
There is an email list for mailing, everything works like this: a user adds news / order, etc., you need to notify other users on the site about this, if these users are offline, letters are sent without delay, but if online, there is a delay (for example 3 minutes), if the user has not read the event on the site in 3 minutes, an email is sent to him, otherwise the email is removed from the list
You could do this:
news
id, name, author_id, text, email_id
orders
id, name, author_id, supplier_id, email_id
emails: id,
author_id
, recipient_id, subject, text, time_to_send, created
Would it be correct to make the order_id, news_id, etc. fields in the emails table?
id, author_id, recipient_id, order_id, news_id, subject, text, time_to_send, created
What is the best way to proceed in this case?
Answer the question
In order to leave comments, you need to log in
If strict normalization is carried out, then there should be a table of letters (id, author_id, subject, text, created), a mailing table (letter_id, recipient_id, time_to_send). If the letters<->news and letters<->orders links are many-to-many, then two link tables (letter_id, news_id) and (letter_id, order_id), if not, then the news_id and order_id fields are also in the letters table. And then you need to look at whether denormalization is needed and to what extent.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question