Can a superkey include things that aren’t part of the primary key?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Logically speaking, yes. If table
Xhas columns{A, B, C}andAis the primary key then{A},{A, B},{A, C}and{A, B, C}are all superkeys because if you have any one of those sets, you know all the values in the row (if it exists.)However it’s not treated as a key in SQL for some purposes, e.g. if table
YhasAandByou can not usually define a foreign keyY(A, B) REFERENCES X(A, B), because{A, B}is not a primary key. If you want to be able to declare that foreign key you must add anotherUNIQUEconstraint onX(A, B)which is inefficient as it duplicates part of the primary key.In my opinion this is one of the many flaws of SQL.