candidate-key

Can a relation have Candidate Keys with different lengths?

▼魔方 西西 提交于 2020-07-11 05:58:36
问题 We can have more than one candidate key in a relation. But can we have two candidate keys in a relation different in length? Suppose I have a relation R(A,B,C,D,E) and we have only two sets of attributes which uniquely identify a tuple in the relation: {A,B,C} and {D,E}. So can we say both {A,B,C} and {D,E} are candidate keys? 回答1: But can we have two candidate keys in a relation different in length? Yes. A CK (candidate key) is a superkey (unique column set) that doesn't contain a smaller

How to implement priorities in SQL (postgres)

ぃ、小莉子 提交于 2019-12-31 06:52:05
问题 I'm writing some software that requires storing items in a database, the items need to have a 'priority' so we end up with ID | Name | Priority --------+--------------+---------- 1 | Pear | 4 2 | Apple | 2 3 | Orange | 1 4 | Banana | 3 So now, the top priority fruit is the Orange, then Apple then Banana then Pear. Now, I want to make Pear the number one priority so Pear, Orange, Apple, Banana. The table will look like: ID | Name | Priority --------+--------------+---------- 1 | Pear | 1 2 |

Are Determinants and Candidate Keys same or different things?

霸气de小男生 提交于 2019-12-28 13:53:38
问题 Here I found this: Definition: A determinant in a database table is any attribute that you can use to determine the values assigned to other attribute(s) in the same row. Examples: Consider a table with the attributes employee_id, first_name, last_name and date_of_birth. In this case, the field employee_id determines the remaining three fields. The name fields do not determine the employee_id because the firm may have more than one employee with the same first and/or last name. Similarly, the

Are Determinants and Candidate Keys same or different things?

和自甴很熟 提交于 2019-12-28 13:53:27
问题 Here I found this: Definition: A determinant in a database table is any attribute that you can use to determine the values assigned to other attribute(s) in the same row. Examples: Consider a table with the attributes employee_id, first_name, last_name and date_of_birth. In this case, the field employee_id determines the remaining three fields. The name fields do not determine the employee_id because the firm may have more than one employee with the same first and/or last name. Similarly, the

Finding Candidate Keys / Superkeys

点点圈 提交于 2019-12-22 01:32:43
问题 I am working on another question here and it asks for the candidate keys and the superkeys. I believe I have the correct candidate keys, but if someone could verify that would be great. I am also just having trouble finding superkeys. I don't know if there is a general formula to find them or whatnot. Here is the question: Relation Schema: U(A,B,C,D) FD's: A-->B B-->C C-->D D-->A I found the Candidate keys to be: {A},{B},{C},{D}. If someone could verify if this is correct, I would greatly

Subset of a candidate key

廉价感情. 提交于 2019-12-11 22:40:58
问题 As we know a candidate key is a column or combination of columns that uniquely identifies the rows in a relation. Suppose I have a relation in which candidate keys are combinations of columns. I want to ask, is it possible that a subset of a candidate key also uniquely identifies the row? OR is a candidate key a key for which there is no subset that uniquely identifies the row? 回答1: A candidate key is a column or combination of columns. Or more correctly a set of one or more columns. Or more

finding largest number of candidate keys that a relation has?

喜夏-厌秋 提交于 2019-12-11 04:58:04
问题 I am trying to solve this question which has to do with candidate keys in a relation. This is the question: Consider table R with attributes A, B, C, D, and E. What is the largest number of candidate keys that R could simultaneously have? the answer is 10 but i have no clue how it was done, nor how does the word simultaneously plays into effect when calculating the answer. 回答1: Sets that are not subsets of other sets. For example {A-B} and {A,B,C} can't be candidates keys simultaneously,

Example of when you should use a foreign key that points to a candidate key, not a primary key?

我的梦境 提交于 2019-12-06 12:52:46
问题 From my reading, I understand what makes a good primary key, what a foreign key is and what a candidate key is. I've read in several different books and sources that: A foreign key must point to a candidate key (or primary) A foreign key almost always points to a primary key The authors of the sources always say something along the lines of, "while foreign keys can point at a candidate key (not primary) they seem to". Are there any examples of why you might choose a candidate key and not the

Example of when you should use a foreign key that points to a candidate key, not a primary key?

别等时光非礼了梦想. 提交于 2019-12-04 19:47:28
From my reading, I understand what makes a good primary key, what a foreign key is and what a candidate key is. I've read in several different books and sources that: A foreign key must point to a candidate key (or primary) A foreign key almost always points to a primary key The authors of the sources always say something along the lines of, "while foreign keys can point at a candidate key (not primary) they seem to". Are there any examples of why you might choose a candidate key and not the primary key? Thank you Primary keys (PKs) have no role in relational theory. (Eg integrity or

How to find a candidate key

谁说我不能喝 提交于 2019-12-02 13:31:56
问题 I have a relation A,B,C,D,E with functional dependencies 1) A->BC 2) CD->E 3) B->D 4) E->A Using 1 gives A,D,E and then using 4 will make it D,E Using 2 gives A,B,C,D and then using 3 gives A,B,C and using 1 gives A Using 2 gives A,B,C,D and using 1 gives A,D Using 4 gives B,C,D,E and using 2 gives B,C,D and using 3 gives B,C Using 3 gives A,B,C,E and using 1 gives A,E and using 4 gives E So I would have 5 super keys? (A, E, AD, BC, DE). And from my super keys I would pick the unique ones.