SQL Help
Go to solution
Solved by Dan Watling,
The problem is that the "AuthorID" field referenced in the constraint is not guaranteed to be unique. In your create statement above, the PK for the AUTHORS table is AuthorID + PublisherID. SQL Server requires foreign keys reference unique keys in the target table (i.e. primary key or a unique index). You have three options here: 1) Drop the PublisherID from the AUTHORS table PrimaryKey, 2) Create a UNIQUE constraint on the AUTHORS.AuthorID field, or 3) Add the PublisherID to the BOOKS table and reference it in the foreign key constraint.
-Dan
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now