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

  • Home
  • SEARCH
  • 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 668009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:59:33+00:00 2026-05-13T23:59:33+00:00

Do you see database triggers / referential integrity rules being used in a way

  • 0

Do you see database triggers / referential integrity rules being used in a way that changes actual data in the database (changing row w in table x causes a change in row y in table z)?

If yes, How does this tie-in with the increasing popularity of in-memory caching (memcache and friends)? After all, these actions occur inside the database but the caching system must be aware of them in order to reflect to correct state (or at least invalidate the possibly changed state). I find it hard to believe that callbacks are implemented for such cases.

Does anyone have real-world experience with such a setup / real-world experience with considering such a setup and abandoning it (which way did you go? if caching, how do you enforce integrity?)

  • 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-13T23:59:34+00:00Added an answer on May 13, 2026 at 11:59 pm

    Simple Answer:

    • Referential integrity is a must have
    • Caching is a qualified must have
    • Triggers are a nice to have

    Longer Answer

    I’ve been developing applications on relational databases since 1993 (Dec RDB since you ask, and on flat file systems before then) and triggers have never been popular with many developers because they can ‘delete stuff that you don’t want deleting’. Referential integrity is also often frowned on by developers because a database in third normal form with proper referential integrity is difficult to bodge together in a few minutes.

    Caching is also often considered quite ‘hard’ to do right, although I’m not sure why.

    Whilst many systems can live without triggers, I’d say that no application database can comfortably survive without referential integrity. Look at the tags on this question, the database behind this site will have a table for the tags (probably called ‘Tag’) and questions (probably called ‘Question’). ‘Question’ will have a foreign key to the primary key on the Tag table, but as questions can have many tags and tags can have many questions I’d guess that the relationship is like this:

       Question
       (TagId)         1 | Database triggers / referential integrity and in-memory caching
          |  
        -----
        | | |
      QuestionTag
     (QuestionId)       1 | 1  ... 1 | 2  ... 1 | 3 ...
        (TagId)
        | | |
        -----
          |
         Tag            1 | database ... 2 | referential-integrity ... 3 | triggers ...
       (TagId)
    

    This kind of referential integrity is the bedrock of any reliable application and isn’t negotiable. You can see how it adds credibility to the application design and confidence in its longevity.

    The caching on SO may be turned on for such a thing as tags (although it isn’t guaranteed) so assume that the tags are cached in memory and that you have enough reputation to be allowed to add a tag to SO. You add your tag and it may well be persisted to the database instantly – but is the cache then updated?

    What you have is a trade-off. Can the site survive without knowing about your new tag? And if so for how long? Fundamentally what is the lifecycle of a tag, as it progresses from being added by a user to being in the database, available to other users, used by other users? The cache will be rebuilt according to the rules set down by the development team – and that rule will be a trade-off essentially so that any new tag is available quickly enough without slowing the application down.

    Triggers can enforce referential integrity, say the tag you add is ‘rubbish’, but by the time the admins see it three questions are tagged ‘rubbish’. The admins then decide to delete the ‘rubbish’ tag – but what about the questions that are tagged with it? If there is a trigger on the ‘tag’ table that is fired on the delete, it could then run round the ‘question’ table and remove all references to ‘rubbish’. There are lots of alternatives to this approach – many of which are programmatic workrounds – but is there a cleaner alternative?

    I’ve worked on lots of sites in the last 20 years, the good ones use referential integrity and increasingly caching. Triggers that change data anonymously (all they fundamentally are are event driven stored procedures) are not popular and increasingly misunderstood but still have a role.

    Caching and referential integrity cannot be considered an either-or – development teams must design applications so that both can be incorporated.

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

Sidebar

Ask A Question

Stats

  • Questions 375k
  • Answers 375k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Here's an extension which makes it work (at least partially):… May 14, 2026 at 8:07 pm
  • Editorial Team
    Editorial Team added an answer Because in the case of the varchar, it has to… May 14, 2026 at 8:07 pm
  • Editorial Team
    Editorial Team added an answer If the primary key is only one column, you can… May 14, 2026 at 8:07 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.