Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7400963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:20:19+00:00 2026-05-29T04:20:19+00:00

I have a structure for a notification system that I believe is pretty dynamic,

  • 0

I have a structure for a notification system that I believe is pretty dynamic, though I fear my solution may be breaking some sort of cardinal rule of database design.

Notifications

id
notification_type_id
data
created_at

Users Notifications

user_id
notification_id
is_read

The part that I question is the data column in the notifications table, which is to hold the relevant data (in json format) necessary to build the message. For instance, if the notification is for a new comment added on a post, then data would contain the id of the post as well as the id of the user who commented on the post to build the necessary message.

Example: {post_id: 123, user_id: 456} would build the message “Dumbo answered your question How much does it cost to…?”

The thought of having one column hold multiple references to other records hits me wrong, but it does seem like a pretty dynamic option. If not this, the only other option I can think of is to generate the message prior and then storing that in the database, which seems too static to me as everybody involved would receive the same exact message.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:20:20+00:00Added an answer on May 29, 2026 at 4:20 am

    The relational model allows arbitrarily complex types. But if a complex type has some internal structure, then

    • the dbms ignores it, or
    • the dbms (not the user) provides functions to manipulate it.

    Dates, for example, have internal structure. Database management systems provide functions to manipulate that structure by truncating it, extracting parts of it, adding and subtracting intervals, and so on.

    JSON has internal structure, too. If your DBMS supports a JSON data type, it will provide functions to manipulate it. If it doesn’t, it ignores the fact that it’s a JSON type, and just returns the stored JSON data to the user.

    So far, no problem.

    But, having said that . . .

    Example: {post_id: 123, user_id: 456} would build the message “Dumbo
    answered your question How much does it cost to…?”

    One problem here is that the dbms can’t guarantee that user_id 456 exists, so the caller can’t know whether the conversion from ID number to name will work. It also can’t know whether post ID 123 still exists. Those kinds of constraints are what foreign keys are for, and you can’t enforce foreign key constraints on id numbers stored as JSON.

    Your main risk there is returning nonsense (or NULL) to the caller. In some cases, that’s perfectly defensible. (Blogs, for example. Who really cares if you get a nonsense message once in a while?) In other cases, it might be catastrophic.

    If, instead, you stored the text “Dumbo answered your question, ‘How much …'”, there would be no chance of failure because of deleted users or posts. Even if both the post and user were deleted, the message “Dumbo answered your question, ‘How much …'” would still be a true fact. (Though perhaps somewhat less useful, depending on how your system handles deletions.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

let's say that I have structure like this : As most you may see
I have a structure that contains an arrays of another structure, it looks something
I have a structure that roughly looks like this: List<ProductLine> -> ID Name ...
I'm using velocity templates to generated plain-text emails for a notification system. I have
I have a structure that only one function must access. The function converts tokens
I have a C++ application which has the following structure: Class AAA: has some
I have a structure which I need to populate and write to disk (several
I have a structure in C#: public struct UserInfo { public string str1 {
I have a structure like this: <ul> <li>text1</li> <li>text2</li> <li>text3</li> </ul> How do I
I have a structure: struct pkt_ { double x; double y; double alfa; double

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.