是否有一个表(联系表)主要关键? 许多与许多关系。 我看到了约恩的一些表格,其中主要有关键,有些人没有这样的表格,请解释一下,什么时候你会把主要钥匙放在合并桌上?
事先感谢你;
是否有一个表(联系表)主要关键? 许多与许多关系。 我看到了约恩的一些表格,其中主要有关键,有些人没有这样的表格,请解释一下,什么时候你会把主要钥匙放在合并桌上?
事先感谢你;
在纯粹的合并或交叉口表中,所有领域都将是主要领域的一部分。 例如,请考虑以下表格:
CREATE TABLE USERS
(ID_USER NUMBER PRIMARY KEY,
FIRST_NAME VARCHAR2(32),
LAST_NAME VARCHAR2(32));
CREATE TABLE ATTRIBUTES
(ID_ATTRIBUTE NUMBER PRIMARY KEY,
ATTRIBUTE_NAME VARCHAR2(64));
允许许多用户具有许多属性之间的交叉口表将是
CREATE TABLE USER_ATTRIBUTES
(ID_USER NUMBER REFERENCES USERS(ID_USER),
ID_ATTRIBUTE NUMBER REFERENCES ATTRIBUTES(ID_ATTRIBUTE),
PRIMARY KEY(ID_USER, ID_ATTRIBUTE));
有时,你认为有必要在禁止令表中增加一个非主要栏目,但我认为这相对较少。
分享和享有。
所有表格都应具有首要关键意义。
你们要么使用混杂的外国钥匙,要么使用盲人注射器。
如果在您的协会桌上没有其他要素,你将使用该化合物的外国钥匙。
在协会桌上有自己的要素时,你可以使用盲人注射器。 将用另外两个指数确定化合物外壳。
这取决于你所参与的记录。 只要你不需要每个协会的多份记录,你就可以在相关记录的id上形成一个综合的主要关键。
然而,更重要的是,确保这两个栏目都有索引,并界定了参考性完整性。
关系表经常有 3<>> > 候选人钥匙,其中一人无需强制实施,而选择哪一种关键(如果有的话)是任意的。
CREATE TABLE Couples
(boy_name INTEGER NOT NULL UNIQUE -- nested key
REFERENCES Boys (boy_name),
girl_name INTEGER NOT NULL UNIQUE -- nested key,
REFERENCES Girls(girl_name),
PRIMARY KEY(boy_name, girl_name)); -- compound key
The "Couples" table lets you insert these rows from the original set:
( Joe Celko , Brooke Shields ) ( Alec Baldwin , Kim Bassinger )
Think about this table for a minute. The
PRIMARY KEY
is now redundant. If each boy appears only once in the table and each girl appears only once in the table, then each (boy_name, girl_name) pair can appear only once.From a theoretical viewpoint, I could drop the compound key and make either boy_name or girl_name the new primary key, or I could just leave them as candidate keys.
SQL products and theory do not always match. Many products make the assumption that the
PRIMARY KEY
is in some way special in the data model and will be the way to access the table most of the time.
...... 我怀疑你提出的问题是,更像,“假定一把自然钥匙与人工识别器相分离的人,我是否在完全由其他表格中提到的人为识别器组成的表格中添加人为识别码?”
I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...
<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...
我把我的用心从使用QQL转向MySQL。 它与凯科特合作,现在不工作,因为我已经改变,使用MySQL。 这里的错误信息是:
We have a restaurant table that has lat-long data for each row. We need to write a query that performs a search to find all restaurants within the provided radius e.g. 1 mile, 5 miles etc. We have ...
Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...
Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...
What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...
My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...