drop table user;
create table user(
ID int(10) primary key auto_increment,
password varchar(10),
user_name varchar(10),
actor_id int(10)
);insert into user values(1,'joe','joe',1);
insert into user values(2,'kan','kan',2);
insert into user values(3,'gern','gern',2);
insert into user values(4,'jone','jone',3);
insert into user values(5,'jack','jack',3);
insert into user values(6,'jake','jake',3);ALTER TABLE user ADD CONSTRAINT fk_actor
FOREIGN KEY (actor_id)
REFERENCES actor(id);drop table actor;
create table actor(
ID int(10) primary key auto_increment,
actor_name varchar(10)
);insert into actor values(1,'sup_user');
insert into actor values(2,'gen_user');
insert into actor values(3,'sim_user');drop table droit;
create table droit(
ID int(10) primary key auto_increment,
droit_name varchar(10),
actor_id int(10)
);ALTER TABLE user ADD CONSTRAINT fk_driot
FOREIGN KEY (actor_id)
REFERENCES actor(id);insert into droit values(1,'I',1);
insert into droit values(2,'D',1);
insert into droit values(3,'M',1);
insert into droit values(4,'S',1);
insert into droit values(5,'I',2);
insert into droit values(6,'M',2);
insert into droit values(7,'S',2);
insert into droit values(8,'S',3);
大家指点一下 看看我这个表建的是否有问题!尤其是最后一张表