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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:37:13+00:00 2026-06-12T08:37:13+00:00

This a very basic database design/normalisation question. Suppose I have a Books table with

  • 0

This a very basic database design/normalisation question.

Suppose I have a Books table with the following columns:

isbn|title|author|status

and status can be one of checked out, available, overdue, lost (stored as integers).

When adding rows I decide “actually, when the status is checked out, I want to store another field due_date“. I only want to store this field for books with status checked out, as it has no meaning otherwise.

What is the standard, correct, canonical way to do this?

One approach is to add the column and set it to NULL if the status is not checked out, but this sounds like a bad idea to me (for integrity among other things, e.g. what if the status is available and we also have a due_date?)

The other obvious answer is to create a DueDates table and store isbn|due_date pairs in it. This is the approach I normally take but it’s easy to end up with tables and JOINs all over the place.

I am not looking for how to store books specifically, that’s just an example of the problem and I want to know the standard solution.

Edit: Does the answer change if I decide that I want to add lots of fields for checked out status only (due_date, borrowed_by, checked_out_from, …) – and have all these as NULL if the status is not checked out?

  • 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-06-12T08:37:15+00:00Added an answer on June 12, 2026 at 8:37 am

    The problem as you have stated it is fundamentally one of typing and subtyping. a “checked out book” is a type of book. an “available book” is a different type of book. A book can progress from state to state over time, and can thus belong in one subtype or another over time.

    In Object modeling, this kind of issue is handled through classes, subclasses, and inheritance.

    In ER modeling, this kind of issue is called “specialization”. You can find articles on the web dealing with ER specialization. I have not seen examples that deal with time varying specialization. More of the examples are time invarying, like the Pets case.

    In relational modeling and relational database design, there are several standard ways of building tables to implement specialization.

    The first standard way is called “Single Table Inheritance”. This is basically what you’ve designed. You end up with a lot of NULLs for data that does not pertain to the subtype of a given row. But you don’t have to do any joins.

    A second standard way is called “Class Table Inheritance”. In this way, there is a separate table for each class and subclass, and they have a shared primary key. You can look up both “Class Table Inheritance” and “Shared Primary Key” in SO and on the web. You do more joining, but you have fewer NULLS.

    There are other ways.

    Which way is best depends on the case at hand.

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

Sidebar

Related Questions

I have a basic but very important transactional database design question. I am designing
This is a very basic question, so please bear with me. Consider the following
This is a very basic question...quite embarassing, but here goes: I have a Stopwatch
I have only one table in my mySql database for a very basic website
This is a very basic SQL question. What I've got is a database for
I have a database to store people's quick links. This is a very basic
I have a very basic MySQL Database. This is the query I used to
This is very basic magento question i guess. I want to first get all
This is very basic question from programming point of view but as I am
This is a very very basic question and I know one way is to

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.