user11185206
user11185206

Reputation:

Is this classed as a composite primary key?

I am making a car rental system. I have a table with the information about cars and in the table I have 2 attributes one called VIN(which is a unique identification number) and I also have ULP(Unique License Plate), because they are both unique and you cannot have two primary keys in one table, will they both be classed together as Composite Primary Keys

Upvotes: 5

Views: 196

Answers (2)

Gordon Linoff
Gordon Linoff

Reputation: 1269503

A primary key has three attributes:

  • It is never NULL.
  • It is unique.
  • There is only one per table.

Other keys (or combinations of keys) with these attributes are candidate primary keys. You can choose any of them that you want for the primary key of the table. Or, you can create a synthetic primary key yourself.

A composite primary key is when the primary key has more than one key. You could create a composite key from your two fields, but that does not seem necessary.

Instead, you have two candidate primary keys and you can choose either of them as the primary key for your table. Or declare the columns as NULL and unique and have an auto-incremented key.

Upvotes: 1

Tab Alleman
Tab Alleman

Reputation: 31775

No. More likely one will be the primary key and the other will be an alternate key.

A composite key is when the combination of two columns make the row unique. In your case you have two unique columns, which is not the same thing.

Upvotes: 6

Related Questions