Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BCNF with One Surrogate Key and Two Unique Keys

I am trying to understand what BCNF is and I have a relation like this:

Student(id, ssn, email, name, surname)

where

  • id is a primary surrogate key with not null and auto increment properties,
  • ssn is a unique key with not null property, and
  • email is also a unique key with not null propery.

Are there anything that violates BCNF and if so, how can I overcome this situation with a better design?

EDIT

I am trying to write my functional dependencies but please correct me if I'm wrong.

There are three attributes which determine the others, so it's confusing that ssn and email both exist at left hand side and right hand side of the equations. It seems that this relation is not in bcnf but there must be something wrong :)

id -> (ssn, email, name, surname)
ssn -> (id, email, name, surname)
email -> (id, ssn, name, surname)
like image 680
sedran Avatar asked May 12 '13 02:05

sedran


People also ask

Can Bcnf have multiple candidate keys?

Candidate Keys and BCNFEach table can contain multiple candidate keys, any one of which can qualify as the primary key. A table contains only one primary key. Candidate keys must be unique.

Is surrogate key unique?

Surrogate keys are unique. Because surrogate keys are system-generated, it is impossible for the system to create and store a duplicate value.

What is business key and surrogate key do we need both them or one is enough?

In a temporal database, it is necessary to distinguish between the surrogate key and the business key. Every row would have both a business key and a surrogate key. The surrogate key identifies one unique row in the database, the business key identifies one unique entity of the modeled world.

What is a surrogate key and when should you use one?

A surrogate key is a unique identifier used in databases for a modeled entity or an object. It is a unique key whose only significance is to act as the primary identifier of an object or entity and is not derived from any other data in the database and may or may not be used as the primary key.


2 Answers

Yes, your table is in BCNF. This is because you don't have any overlapping candidate keys - i.e. there's no attributes which appear in two different keys.

If you had some other attribute, X, which formed part of the keys - e.g. (SSN, X) and (email, X) - then your table would fail BCNF because X should be the same for a given SSN and email pair. These key definitions would allow different values of X for given SSN and emails.

For a good explanation of BCNF, read this answer.

like image 25
Chris Saxon Avatar answered Sep 19 '22 16:09

Chris Saxon


The way to answer your question properly is to identify what functional dependencies are supposed to apply. Write down what you think the dependencies are. If the left-hand side of every non-trivial dependency is a superkey then the relation satisfies BCNF.

like image 171
nvogel Avatar answered Sep 22 '22 16:09

nvogel