0
create table Coordinator(
cor_id char(6) primary key,
cor_name varchar(10) not null,
contact_no char(12),
address varchar(50));

create table Student(
student_id char(6) primary key,
name varchar(10) not null,
department char(20),
grade char(6),
percentage smallint,
contact_no char(12),
address varchar(50));

create table Criteria(
crt_id char(6) primary key,
min_cutoff smallint);

create table Company(
cmp_id char(6) primary key,
crt_id char(6),
cmp_name varchar(25) not null,
grade char(6),
package int,
contact_no char(12),
address varchar(50),
foreign key (crt_id) references Criteria(crt_id));

**create table Coordinate_with(
cor_id char(6),
cmp_id char(6),
date char(10),
shift varchar(10),
primary key (cor_id,cmp_id),
foreign key (cor_id) references Coordinator(cor_id),
foreign key (cmp_id) references Company(cmp_id));**

create table Placed_in(
cmp_id char(6),
student_id char(6),
primary key (cmp_id,student_id),
foreign key (comp_id) references Company,
foreign key (student_id) references Student);

create table Criteria_Branch(
crt_id char(6),
branch_allowed varchar(20),
primary key (crt_id, branch_allowed),
foreign key (crt_id) references Criteria(crt_id);
4

1 回答 1

1

shift是保留字。您需要以不同的方式命名该列。

您永远不应该将日期存储为charvarchar列!

此外,名称date也不是一个很好的选择。除了作为保留字之外,它不记录该列的内容。“开始日期”、“结束日期”、“加入日期”、“截止日期”……

使用chardatatype 几乎总是不会做你想做的事,因为它的值被填充到定义的长度。我很确定你想要varchar(或varchar2)代替。

如果您的 ID ( cor_id, ...) 确实是数字,则应将这些列定义为number(或integer)。

所以有问题的表格至少应该是这样的:

create table Coordinate_with
(
  cor_id char(6),
  cmp_id char(6),
  start_date date,      -- or whatever name describes better what kind of date that is.
  shifted varchar(10),  -- the name is just a suggestion, use what best describes this column
  primary key (cor_id,cmp_id),
  foreign key (cor_id) references Coordinator(cor_id),
  foreign key (cmp_id) references Company(cmp_id)
);
于 2013-04-27T13:57:29.390 回答