Question

I'm trying to add relationships between two simple tables in SSMS in a diagram. The problem is that I want the "Artwork"-table to be the primary table and "Artist"-table to be the foreign-table. But when I drag the relationships between them, then the keys are locking up both tables. And I cant figure out why?? I just want it to lock up in one direction... And as you can see in the picture, I've also set the "ArtistID"-columns in both tables as primary-keys.

SSMS Diagram Table

Was it helpful?

Solution

Do you really want a one-to-one relationship between Artist and Artwork? A one-to-many would seem to make more sense (in that one artist can be associated with many artworks, but an artwork can only have one artist).

What you would do in that case is to add another primary key column to the Artwork table (ArtworkID for example) and make the ArtistID in the Artwork table a foreign key to Artist.

It could look like this:
enter image description here

OTHER TIPS

You need to use a compound key with the artist and an artwork. Then the references will work. SSMS currently sees the two tables in a one-to-one relationship as they both have the same key. It might be an idea to introduce an artwork Id instead of using the name and title if there is any possibility of these changing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top