简体   繁体   中英

database design for global notifications

I have a notification system in which there are various types "comments", "product_added" etc. and there are many users too.

Based on user's friends would see notifications upon action performed by user or his/her friends. the thing is that i have to maintain a record of which friend has read the notification or not, I already have a table in which I have stored the:

notification_id,    
type_id ,   
item_id ,   
user_id ,   
owner_user_id , 
is_seen,
time_stamp, 
title_html, 
title_text, 
body_html,
body_text,  
href,
icon_url

Should I use an array to store all the friends id's who seen the notification in is_seen or should I create a new table named notification_seen in which I maintain record for each friend who seen that notification?

All notifications would last up to 30 days and also have to keep in mind that if a user has more then 200 friends, then storing 200 ids in a array and then retrieving it and breaking array then showing them (inshort a long procedure according to me).

So can any one suggest which one is a better way or any more better way that I am not aware of?

Use a separate table. An array in a relational database is always a bad idea because you cannot apply database operations and queries to single array elements without user defined functions or complicated expressions in queries. And also it does not adhere to the normalization paradigm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM