Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Foreign Keys
Message
 
 
À
23/07/2008 15:48:43
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Conception bases de données
Titre:
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01333536
Message ID:
01333686
Vues:
10
This message has been marked as a message which has helped to the initial question of the thread.
The first one should work as well. It sounds like you have problem with data. There're records in Table3 that do not have corresponding records in Table2.

>Just out of curiosity....
>
>SQL Server won't seem to let me do this:
>
>Table1: Key = ID
>Table2: Key = ID = Table1.ID (Only some Table1 records have a Table2 record)
>Table3: ForeignKey = Table2ID = Table2.ID (Table3's FK must exist in Table2)
>
>I have to do this:
>
>Table1: Key = ID
>Table2: Key = ID = Table1.ID
>Table3: ForeignKey = Table2ID = Table1.ID
>
>I can live with the second method... But the first describes the relationship better and seems safer. Attempting to do it the first way results in:
>
>The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_Table3_Table2ID". The conflict occurred in database "myData", table "dbo.myTable2", column 'ID'.
>
>Is that a known limitation of mixing Foreign keys and Primary keys... or am I missing something?
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform