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 6661897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:19:59+00:00 2026-05-26T02:19:59+00:00

I have a table that maintains specific business transactions, let’s call it LOANS .

  • 0

I have a table that maintains specific business transactions, let’s call it LOANS. Each record can at any given time have one of several “states”, for example “in re-payment / open”, “defaulted”, “voided”, or “paid”.

The status of a record can only change due to an “event” or action taken by the user of the application (some events do not cause a state change, eg a payment modifies the record but does not change the state). While keeping track of the current status, it is also important that we can easily track the “event” that put the transaction in this state.

I have seen other databases setup such that LOANS contains a status column, and a letter (or even a foreign key to a table of possible states) is used to designate current status. Then the EVENTS table has a column that is a FK to LOANS.

This solution works, but I am concerned that this allows for a possible loss of data integrity. In other words, there is nothing to prevent status from being set to “defaulted” with no EVENT to support the change. It would be left solely to the application to ensure this never happens (there is no referential integrity in this solution as I see it).

My alternate solution is to scrap the status column in LOANS and instead use a lastEvent column which is an FK to EVENTS. The EVENTS table would then maintain the “type” of event which would in turn describe the state change (eg if the lastEvent was of type ‘payoff’ then naturally the state is ‘paid’).

My questions are:

  1. Should I even be concerned about the data integrity (is this such a common thing to do because it is ok to do it)?
  2. Is my proposed solution sound, or is there a better solution?
  3. Are there any pitfalls in my solution that I should be aware of?

In case it matters, I am using MS SQL SERVER 2005.

  • 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-26T02:19:59+00:00Added an answer on May 26, 2026 at 2:19 am
    1. Only you know what the risks are if you don’t have referential integrity here – but in general, yes, it’s worth designing your database so you can use referential integrity. It reduces errors, and increases the chances future developers will understand your schema.

    2. I’d have a schema along the lines of…

      Loans


      Loan_Id (PK)

      amount
      ….

      Events


      Event_id (PK)

      Loan_ID (FK)

      Event_type_id (FK)

      Date

      status_id (fk)

      event_type


      event_type_id (pk)

      description

      status


      status_id (pk)

      description

    To find the current status of any load, you’d need to find the newest entry in the events table for that loan. To see the history of a loan’s status changes, you can query the events table.

    When you record events which do not change the status, the record with the new event simply contains the current status of the event – so you might get a table like:

    Event_id   Loan_ID Event_type_id    Date         status_id 
     ------------------------------------------------
     1               1           NEW   1 Jan 2011   NEW
     2               1       APPROVE   2 Jan 2011   NEW
     3               1       DEFAULT   1 Feb 2011   DEF
    ...
    

    This way, you always retrieve the current status by finding the latest record.

    It dramatically reduces the risk of bugs – if your logic for “events” changes, and an event does change the status of a loan, you only have to change this in one place – the code which creates the record in the event database. You don’t have to remember to also change the “loan” record.

    As for performance – I’d only optimize for this if you really need to – on a well-tuned database, the join and max should not be show stoppers.

    You can refine the model by creating a table which maps valid status transitions and their associated events; depending on your database, you could enforce this through triggers.

    I think this is better than a “last event” foreign key, because it’s redundant – by definition, the last event is the record with the MAX(date) for that loan.

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

Sidebar

Related Questions

I have a table which maintains performance data of a system, each record is
I have a table that holds information about cities in a game, you can
I have two tables, A and B and a simple table, X, that maintains
I have a table that maintains rows of products that are for sale (
I have table that I insert data with following query (from c# code): INSERT
I have table that contain date and time field. id|date|time ========= 1|01/01/2001|10:45 2|01/02/2002|11:45 3|01/03/2003|12:45
I have a table that got into the db_owner schema, and I need it
I have a table that contains tasks and I want to give these an
I have a table that has redundant data and I'm trying to identify all
I have a table that records a sequence of actions with a field that

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.