首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Annotation运用两个foreign key做联合主键

2013-06-26 
Annotation使用两个foreign key做联合主键Annotation使用两个foreign key做联合主键1、数据库里面的表结构

Annotation使用两个foreign key做联合主键
Annotation使用两个foreign key做联合主键
1、数据库里面的表结构
学生:(Id , Name)
课程:(Id , Name)
选课表:(Student_ID , Course_ID , Score)
2、Student类


3、Course类

7、生成的建表语句
create table _course (        id integer not null auto_increment,        name varchar(255),        primary key (id)    )    create table _score (        score integer not null,        course_ID integer,        student_ID integer,        primary key (student_ID, course_ID)    )    create table _student (        id integer not null auto_increment,        name varchar(255),        primary key (id)    )    alter table _score         add index FKA89FA193A2A75DE0 (course_ID),         add constraint FKA89FA193A2A75DE0         foreign key (course_ID)         references _course (id)    alter table _score         add index FKA89FA19337241E94 (student_ID),         add constraint FKA89FA19337241E94         foreign key (student_ID)         references _student (id)

热点排行