Skip to content
Advertisement

How can I share the same primary key across two tables?

I’m reading a book on EF4 and I came across this problem situation:

enter image description here

So I was wondering how to create this database so I can follow along with the example in the book.

How would I create these tables, using simple TSQL commands? Forget about creating the database, imagine it already exists.

Advertisement

Answer

When it says the tables share the same primary key, it just means that there is a field with the same name in each table, both set as Primary Keys.

Create Tables

Create Relationships

It may look a bit simpler if the table names are just single words (and not key words, either), for example, if the table names were just Product and ProductWebInfo, without the (Chapter 2) appended:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement