I understand that a candidate key can not have NULL values. But a candidate key can itself be a combination of many attributes which are called prime attributes. Can these prime attributes have NULL as a value?
我理解一个候选键不能有空值。但是候选键本身可以是许多属性的组合,这些属性称为素数属性。这些素数属性作为值是否为NULL ?
Regards,
问候,
2 个解决方案
#1
2
Prime attribute An attribute which appears as an attribute for some candidate key. (It needn't be the primary key, or even any key of interest.)
属性:作为某个候选键的属性出现的属性。(它不必是主键,甚至是任何感兴趣的键。)
模式和钥匙
Prime attributes are part of a candidate key. A candidate key, as the name suggests, is a candidate for primary key. That means, a candidate key can become a primary key, if required.
基本属性是候选键的一部分。顾名思义,候选键是主键的候选键。这意味着,如果需要,候选键可以成为主键。
Now if you recall, any primary key cannot be null. So, by definition, a prime attribute cannot be null. If it is null, it ceases to be a prime attribute.
如果你还记得,任何主键都不能为空。根据定义,一个素数属性不能为空。如果它是null,它就不再是一个prime属性。
Here is an explanation.
这是一个解释。
If you have a composite candidate key lets say
如果你有一个复合候选键
CK1(P1, P2)
P1 and P2 are a prime attributes. You can set P1 or P2 as null, because there is no constraint on prime attributes other than those of primary key attributes.
P1和P2是质数属性。您可以将P1或P2设置为null,因为除了主键属性之外,对主要属性没有约束。
So,
所以,
CK1(P1, P2=null)
Now, CK1 cannot be a primary key, hence is no more a candidate key and hence, P2 is no more a prime attribute.
现在,CK1不能是主键,因此不再是候选键,因此P2不再是质数属性。
#2
0
I believe it depends on the database you use.
我相信这取决于你使用的数据库。
For example, you don't have to do it explicitly in MySQL. This is defined in the manual:
例如,不需要在MySQL中显式地执行。这在手册中有规定:
A PRIMARY KEY is a unique index where all key columns must be defined as NOT NULL. If they are not explicitly declared as NOT NULL, MySQL declares them so implicitly (and silently).
主键是唯一的索引,其中所有键列必须定义为NOT NULL。如果它们没有被显式声明为非空,那么MySQL将它们隐式地(并且是静默地)声明。
#1
2
Prime attribute An attribute which appears as an attribute for some candidate key. (It needn't be the primary key, or even any key of interest.)
属性:作为某个候选键的属性出现的属性。(它不必是主键,甚至是任何感兴趣的键。)
模式和钥匙
Prime attributes are part of a candidate key. A candidate key, as the name suggests, is a candidate for primary key. That means, a candidate key can become a primary key, if required.
基本属性是候选键的一部分。顾名思义,候选键是主键的候选键。这意味着,如果需要,候选键可以成为主键。
Now if you recall, any primary key cannot be null. So, by definition, a prime attribute cannot be null. If it is null, it ceases to be a prime attribute.
如果你还记得,任何主键都不能为空。根据定义,一个素数属性不能为空。如果它是null,它就不再是一个prime属性。
Here is an explanation.
这是一个解释。
If you have a composite candidate key lets say
如果你有一个复合候选键
CK1(P1, P2)
P1 and P2 are a prime attributes. You can set P1 or P2 as null, because there is no constraint on prime attributes other than those of primary key attributes.
P1和P2是质数属性。您可以将P1或P2设置为null,因为除了主键属性之外,对主要属性没有约束。
So,
所以,
CK1(P1, P2=null)
Now, CK1 cannot be a primary key, hence is no more a candidate key and hence, P2 is no more a prime attribute.
现在,CK1不能是主键,因此不再是候选键,因此P2不再是质数属性。
#2
0
I believe it depends on the database you use.
我相信这取决于你使用的数据库。
For example, you don't have to do it explicitly in MySQL. This is defined in the manual:
例如,不需要在MySQL中显式地执行。这在手册中有规定:
A PRIMARY KEY is a unique index where all key columns must be defined as NOT NULL. If they are not explicitly declared as NOT NULL, MySQL declares them so implicitly (and silently).
主键是唯一的索引,其中所有键列必须定义为NOT NULL。如果它们没有被显式声明为非空,那么MySQL将它们隐式地(并且是静默地)声明。