Есть три разумных способа построить этот стол. Основополагающий реляционный принцип состоит в том, что все известные ограничения должны быть объявлены для dbms, чтобы dbms могли обеспечить их соблюдение. Во всех случаях три столбца, содержащие реальные данные, вероятно, должны быть объявлены как NOT NULL.
create table wibble (
column_1 data-type not null,
column_2 data-type not null,
column_3 data-type not null,
primary key (column_1, column_2, column_3)
);
create table wibble (
surrogate_id_number integer primary key,
column_1 data-type not null,
column_2 data-type not null,
column_3 data-type not null,
unique (column_1, column_2, column_3)
);
create table wibble (
surrogate_id_number integer not null unique,
column_1 data-type not null,
column_2 data-type not null,
column_3 data-type not null,
primary key (column_1, column_2, column_3)
);
Должно быть очевидно, что ограничение первичного ключа только для столбца с идентификационным номером не может работать. Это позволит дублировать такие данные.
1 Value1 Value2 Value3
2 Value1 Value2 Value3
3 Value1 Value2 Value3
4 Value1 Value2 Value3
5 Value1 Value2 Value3
person
Mike Sherrill 'Cat Recall'
schedule
19.04.2013