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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:29:04+00:00 2026-05-25T18:29:04+00:00

Here is a simple example: Assume I have a customer table that has a

  • 0

Here is a simple example:

Assume I have a customer table that has a one-to-many relationship with the address table (a customer can have multiple shipping addresses but a shipping address can only belong to a single customer).

Customer Table
-------------
customer_id (PK)


Address Table
-------------
address_id (PK)
customer_id (FK)

Now I want each customer to be able to specify a default shipping address.

I can think of 2 ways but both have drawbacks.

Option 1

Add a Boolean column to the Address Table called “is_default”.

Pros

  1. Select queries are simple
  2. Straightforward for other people to understand if they see the DB model

Cons

  1. The application is forced to enforce and maintain the “only one row can be a default” constraint.
  2. Updating the default field is a pain because it requires the application to check and reset the previous default option.

Option 2

Add a column to the Customer table called “address_id” and make it a foreign key (also allow nulls just in case no address exists).

Pros

  1. Easy to update the default address if the user decides to change it.
  2. Database maintains the “only one row can be a default” constraint.

Cons

  1. I have to add a new indexed column to the Customers Table every time I decide to add some kind of default metadata.

  2. Seems like a hack

My question is, is there a standard way to handle this kind of scenario that I am overlooking? Of course there are other options (maybe creating an EAV default options table?) but I’d prefer to keep it as simple as possible because the change is being made to an existing code base so I don’t want to break anything.

  • 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-25T18:29:04+00:00Added an answer on May 25, 2026 at 6:29 pm

    (maybe creating an EAV default options table?)

    I would do this, especially if you’re worried about breaking existing code.

    Customer_Defaults
    ------------------------------------
    customer_id                          PK, FK -> Customer
    default_shipping_address_id          FK -> Address
    

    Isn’t that tidy? By pulling the whole thing into a separate table, you leave the existing tables alone. If you’re using some kind of ORM layer, the object over this new table can be queried for directly, and then you can walk to the Address object. No need to even introduce the new object to the existing Customer or Address objects.

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

Sidebar

Related Questions

Here's my hypothetical example. I have a very simple WPF window with a one
I can't get past this issue I am having. Here's a simple example: class
pretty simple question I have here, but I couldn't find the answer: Assume I
This problem is not readily reproducible in a simple example here but was wondering
Here's a very simple Prototype example. All it does is, on window load, an
I'm probably missing something simple here, but I can't find the answer elsewhere. I
No doubt I'm missing something really simple here but I just can't see the
I hope I am not missing something very simple here. I have done a
Let's look at a simple example of a dog and a cat that are
A simple question I'm sure, but I can't figure it out. I have some

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.