Skip to content
Advertisement

How to make a composite key out of two foreign keys

I have three tables:

In Table 1 primary key is pizza and in Table 2 ingredient. In Table 3, pizza and ingredient are foreign keys, that reference Table 1 and Table 2 respectively, and i want to make them into a composite key.

Here’s what i tried:

But i’m not sure whether it’s a correct implementation.

Advertisement

Answer

No, it doesn’t make sense to assemble a single composite FK. Those are two separate foreign key constraints, unrelated to each other.

Your table is perfectly correct as:

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