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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:20:45+00:00 2026-05-14T23:20:45+00:00

Here is the scenario: You have a Persons table with a one-to-many relationship with

  • 0

Here is the scenario: You have a Persons table with a one-to-many relationship with an Addresses table, where one of the Address rows is the “primary” Address.

Is it better in a normalized schema to

  • Use a Persons.PrimaryAddressID to access the “primary” Address for a Person

or

  • Use an Addresses.IsPrimary bit column to reference the “primary” Address for a Person via Addresses.PersonID

or

  • Other

and why?

  • 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-14T23:20:45+00:00Added an answer on May 14, 2026 at 11:20 pm

    It depends on whether the person-to-address relationship is one-to-zero-plus or one-to-one-plus.

    If a person is required to have a primary address, I would put it in the Persons table itself (since it’s a required attribute).


    In the other hand, if a person can exist in your schema without an address, I would leave all addresses in the Addresses table as equal and use an attribute of the Persons table to select the primary (either NULL or a pointer to the relevant Addresses row).

    If you store the primality of an address in the Addresses table, what do you do when two addresses for Bob Smith both claim to be the primary? You could stop that with triggers but it’s far more efficient to design your schema properly.

    And, if two room-mates share the same address, but one lives there all the time and the other spends most of his time shacked up with his girlfriend, what happens then? If the primality is in the Addresses table, you won’t be able to share address rows between persons.


    What I’m trying to get across is that you need to allocate your attributes to the right objects. A person’s primary address belongs to a person, not an address.

    For maximum efficiency and flexibility, I would have the following schema:

    Persons:
        Id                 primary key
        PrimaryAddressId
        OtherStuff
    Addresses:
        Id                 primary key
        OtherStuff
    PersonAddresses:
        Id                 primary key
        PersonId           foreign key on Persons(Id)
        AddressId          foreign key on Addresses(Id)
    

    You have the minor data integrity problem that Persons.PrimaryAddressId may be a hanging pointer. You can’t make it a foreign key to one of the primary keys since you want it to allow NULL. That means you’ll have to cater for the possibility that it might point to a non-existent Addresses.Id.

    I would simply fix that as a before-delete trigger on Addresses so that the relevant Persons rows are updated (setting PrimaryAddressid to NULL).

    Or you could be tricky and have one address of “Unknown” in the Addresses table so that every row in Persons has at least one address (those whose primary address is unknown automatically get their PrimaryAddressid set to the “Unknown” address row.

    Then you could make it a proper constrained relationship and simplify your SQL somewhat. Pragmatism often beats dogmatism in the real world 🙂

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

Sidebar

Related Questions

Here's the scenario: I have 2 tables with data, one is the 2009 version
Here's the scenario: I have 2 tables: CREATE TABLE dbo.API_User ( id int NOT
Okay here is the scenario! I have a Person object which has an Address
Here the scenario is I have many .aspx pages if any page gives error,
Here's the scenario: I have a table for SunflowerSeeds in SQL Server 2008. CREATE
Here is my scenario: I have a single table with 2 columns. ID and
Here is my scenario, I have query that returns a lot of fields. One
Here is my scenario: I have two MySQL tables: Categories (columns: id, category) Items
Here's the scenario: I have a public repo A . Bob forks A ,
Here is my scenario: I have an Eclipse project in my desktop in a

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.