Results 1 to 2 of 2

Thread: Nullable and foreign key field question

  1. #1

    Thread Starter
    Member mdukuen's Avatar
    Join Date
    Sep 2001
    Location
    Mar del Plata, Argentina.
    Posts
    35

    Question Nullable and foreign key field question

    I have this tables:

    CLIENTS
    ----------
    CLIENT_ID
    CLIENT_NAME
    CITY_ID

    CITYES
    --------
    CITY_ID 1...100
    CITY_NAME

    I have both tables related.
    But some clients dont´have city information.
    How can i relate both tables to ensure "relational integrity" (all city id i clients table exists in cityes table) if some clientes havent city information???
    Sorry for my english and thanks!
    Mariano Dukuen
    *** Please apologize my english ***

  2. #2
    Fanatic Member vb_dba's Avatar
    Join Date
    Jun 2001
    Location
    Somewhere aloft between the real world and insanity
    Posts
    1,016
    I would add a row to my city table, something like city_id = 1 and city_name = "N/A". I would make the default city_id value in the client table = 1. If a user doesn't enter a city id, it defaults to 1, and referential integrity is still enforced.

    Chris
    Chris

    Master Of My Domain
    Got A Question? Look Here First

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width