Results 1 to 4 of 4

Thread: Beginners Nightmare

  1. #1
    Join Date
    Mar 2003
    Location
    UK
    Posts
    10

    Beginners Nightmare

    Hello,Hopefully someone can help.

    Im in my second year at uni doing SQL and Relational databases.

    Problem

    I need to set up a DDB using SQL. I have written a number of queries to create tables which work.

    The I have set up my primary keys.

    Now, when setting up my Foreign Keys due to different tables requiring other tables to be set up first I basically cannot open any of them up.

    Can someone PLEASE point out my obvious error or just lend some advice

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Which database are you using?

    To create foreign keys the data in referencing column must exist in the referenced column in referenced table. So if you are missing any values in the referenced table insert them first before you try to create foreign keys. Or remove the invalid values from the referencing column.

  3. #3
    Join Date
    Mar 2003
    Location
    UK
    Posts
    10
    Using Access

    I understand that the field needs to exist before it can be referenced as a foreign key but because all my tables are created from SQL quieries and they all reference each other I cant run any of the quieries.

    Maybe I have too many foreign keys??

  4. #4
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    In that case you have to figure out an order to create tables or do not create foreign keys when you create tables.

    First create all tables, populate the data and finally create foreign keys.

Posting Permissions

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