candidate-key

How to implement priorities in SQL (postgres)

心已入冬 提交于 2019-12-02 10:18:36
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 | Apple | 3 3 | Orange | 2 4 | Banana | 4 Whats the best way to achieve this with PHP and Postgres. Given

How to find a candidate key

核能气质少年 提交于 2019-12-02 05:14:38
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. Since I can get A from E, I can remove A and AD(since DE is the same) and since I can get BC from A I can

Are Determinants and Candidate Keys same or different things?

隐身守侯 提交于 2019-11-28 09:16:37
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 DOB field does not determine the employee_id or the name fields because more than one employee may