我需要在表格创建方面提出建议。哪个最好?如果你能解释原因,那将是非常感激的。
CREATE TABLE TRANSLATION (
LANGUAGE_CODE CHAR(2) NOT NULL,
TRANSLATION VARCHAR2(30) NOT NULL,
OBJECT_ID NUMBER NOT NULL,
OBJECT_TYPE VARCHAR(10) NOT NULL,
CONSTRAINT P$TR#PRIMARY PRIMARY KEY (LANGUAGE_CODE, OBJECT_ID, OBJECT_TYPE)
)
或
CREATE TABLE TRANSLATION (
ID NUMBER NOT NULL,
LANGUAGE_CODE CHAR(2) NOT NULL,
TRANSLATION VARCHAR2(30) NOT NULL,
OBJECT_ID NUMBER NOT NULL,
OBJECT_TYPE VARCHAR(10) NOT NULL,
CONSTRAINT P$TR#PRIMARY PRIMARY KEY (ID),
CONSTRAINT P$TR#PRIMARY UNIQUE (LANGUAGE_CODE, OBJECT_ID, OBJECT_TYPE)
)
正如您在第二个示例中仅在现有主键中看到的那样。我将永远不必通过id找到这样的行,因为没有其他表引用它。 我使用Oracle db