Likes / Stars / Following – same or separate data structures? [duplicate]

I am building a social network, which will have standard features of ‘likes’ (upvotes) for posts, ‘following’ between users and ‘stars’ for favorite posts. These might reasonably expand in the future for similar functionality.

I am mostly using NoSQL (namely, MongoDB docs) but would appreciate an SQL perspective as well.

I am planning on persisting these in collections which might hold documents as following:

Followers Collection, example doc: {follower_id: 123, followee_id: 456}

Likes Collection, example doc: {liker_id: 123, post_id: 789}

Stars Collection, example doc: {user_id: 123, starred_item_id: 555}

The emerging structure seems very similar. Some additional data may be identical (creation date?), and while other might be different (type of item liked/starred/followed, and/or additional, type-specific fields [say a numerical value for a ‘rating’ class]), there appears to be so much in common that it might be prudent to consolidate all of these into a similar ‘model’, both in terms of a single DB collection (or SQL table) as well as shared/single code model.

I am mostly concerned about:

  1. Collection growing too large – this is already a concern just for ‘likes’, it might be exacerbated (although only by ~*3) by throwing in ‘stars’ and ‘followers’ too.
  2. Logic between these data objects growing apart over time, making using a shared data model wrong.

So, would this be a good idea? Likes/Stars/Following – are they more similar or more separate?

Most specifically, assuming 3 collections which are similar but not identical, would it make more sense to consolidate them into one or keep them separate? Both considering code complexity (and DRYness) and DB constraints (e.g. index size).

5

Since Likes and Stars(favorite) pertain to the same object, a “post”. A unifying domain could be used to store Likes and Stars such as postIcons: {userId: ‘123’, postId:’789′, like: true, star: true}. You would have an entry for every post your user liked or favorited but would only have one record for a post your user liked and favorited.

‘Followee’ pertains to another user. So your user can follow many other users. Sounds like Follows could be a List of ids on a user object such that your user has many ‘followeeIds’.

In your comment where you have an ‘action_type’ you would have a record for the same user and the same item for each ‘action_type’.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Likes / Stars / Following – same or separate data structures? [duplicate]

I am building a social network, which will have standard features of ‘likes’ (upvotes) for posts, ‘following’ between users and ‘stars’ for favorite posts. These might reasonably expand in the future for similar functionality.

I am mostly using NoSQL (namely, MongoDB docs) but would appreciate an SQL perspective as well.

I am planning on persisting these in collections which might hold documents as following:

Followers Collection, example doc: {follower_id: 123, followee_id: 456}

Likes Collection, example doc: {liker_id: 123, post_id: 789}

Stars Collection, example doc: {user_id: 123, starred_item_id: 555}

The emerging structure seems very similar. Some additional data may be identical (creation date?), and while other might be different (type of item liked/starred/followed, and/or additional, type-specific fields [say a numerical value for a ‘rating’ class]), there appears to be so much in common that it might be prudent to consolidate all of these into a similar ‘model’, both in terms of a single DB collection (or SQL table) as well as shared/single code model.

I am mostly concerned about:

  1. Collection growing too large – this is already a concern just for ‘likes’, it might be exacerbated (although only by ~*3) by throwing in ‘stars’ and ‘followers’ too.
  2. Logic between these data objects growing apart over time, making using a shared data model wrong.

So, would this be a good idea? Likes/Stars/Following – are they more similar or more separate?

Most specifically, assuming 3 collections which are similar but not identical, would it make more sense to consolidate them into one or keep them separate? Both considering code complexity (and DRYness) and DB constraints (e.g. index size).

5

Since Likes and Stars(favorite) pertain to the same object, a “post”. A unifying domain could be used to store Likes and Stars such as postIcons: {userId: ‘123’, postId:’789′, like: true, star: true}. You would have an entry for every post your user liked or favorited but would only have one record for a post your user liked and favorited.

‘Followee’ pertains to another user. So your user can follow many other users. Sounds like Follows could be a List of ids on a user object such that your user has many ‘followeeIds’.

In your comment where you have an ‘action_type’ you would have a record for the same user and the same item for each ‘action_type’.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Likes / Stars / Following – same or separate data structures? [duplicate]

I am building a social network, which will have standard features of ‘likes’ (upvotes) for posts, ‘following’ between users and ‘stars’ for favorite posts. These might reasonably expand in the future for similar functionality.

I am mostly using NoSQL (namely, MongoDB docs) but would appreciate an SQL perspective as well.

I am planning on persisting these in collections which might hold documents as following:

Followers Collection, example doc: {follower_id: 123, followee_id: 456}

Likes Collection, example doc: {liker_id: 123, post_id: 789}

Stars Collection, example doc: {user_id: 123, starred_item_id: 555}

The emerging structure seems very similar. Some additional data may be identical (creation date?), and while other might be different (type of item liked/starred/followed, and/or additional, type-specific fields [say a numerical value for a ‘rating’ class]), there appears to be so much in common that it might be prudent to consolidate all of these into a similar ‘model’, both in terms of a single DB collection (or SQL table) as well as shared/single code model.

I am mostly concerned about:

  1. Collection growing too large – this is already a concern just for ‘likes’, it might be exacerbated (although only by ~*3) by throwing in ‘stars’ and ‘followers’ too.
  2. Logic between these data objects growing apart over time, making using a shared data model wrong.

So, would this be a good idea? Likes/Stars/Following – are they more similar or more separate?

Most specifically, assuming 3 collections which are similar but not identical, would it make more sense to consolidate them into one or keep them separate? Both considering code complexity (and DRYness) and DB constraints (e.g. index size).

5

Since Likes and Stars(favorite) pertain to the same object, a “post”. A unifying domain could be used to store Likes and Stars such as postIcons: {userId: ‘123’, postId:’789′, like: true, star: true}. You would have an entry for every post your user liked or favorited but would only have one record for a post your user liked and favorited.

‘Followee’ pertains to another user. So your user can follow many other users. Sounds like Follows could be a List of ids on a user object such that your user has many ‘followeeIds’.

In your comment where you have an ‘action_type’ you would have a record for the same user and the same item for each ‘action_type’.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật