in

The ORM Foundation

Get the facts!

Nulls and Foreign key relationships

Last post Fri, Jun 24 2011 16:20 by mnnoon. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • Fri, Jun 24 2011 15:42

    • mnnoon
    • Top 10 Contributor
      Male
    • Joined on Wed, Apr 16 2008
    • Lawndale, CA
    • Posts 60

    Nulls and Foreign key relationships

    Quick questions on Nulls and foreign key relationship.  I've currently been asked to default all fields and even foreign key relationships to some default value.  Even on left outer joins between rows that may not exist yet we have to set default values types using the isnull feature.   My question is this, if a table requires referential integrity, is it ok to set foreign key fields to a 0?  

    Also, since I'm fairly new at not using Nulls with Microsoft Sql Server, is this a fairly common practice?

     Thanks,
    Marc Noon

  • Fri, Jun 24 2011 15:58 In reply to

    Re: Nulls and Foreign key relationships

    What reason was given for this new requirement? It sounds like it might be due to ignorance.
  • Fri, Jun 24 2011 16:08 In reply to

    • mnnoon
    • Top 10 Contributor
      Male
    • Joined on Wed, Apr 16 2008
    • Lawndale, CA
    • Posts 60

    Re: Nulls and Foreign key relationships

    The reason is to standardize the way things are done.  I can see this being done on a value type, but on foreign key relationships, it seems strange.   But the database is relaxed which makes it possible and requires extra steps due to the fact that their should be the database keeping track of these enforcements.

  • Fri, Jun 24 2011 16:20 In reply to

    • mnnoon
    • Top 10 Contributor
      Male
    • Joined on Wed, Apr 16 2008
    • Lawndale, CA
    • Posts 60

    Re: Nulls and Foreign key relationships

    You know what... this is almost a moot point after thinking about it.  Because only if its a 1 to 1 relationship it won't be a problem   Because if a sub table doesn't exist yet it can't have a value assigned to its foreign key relationship for its parent table anyways.   Back to the grind stone.

    Filed under:
Page 1 of 1 (4 items)
© 2008-2024 ------- Terms of Service