Javaweb-数据库设计案例





1. create table music( id int PRIMARY key, title varchar(32), alias varchar(32), image varchar(64), style varchar(8), type varchar(4), medium varchar(4), publish_time date, publisher varchar(16), number tinyint, barcode bigint, summary varchar(1024), artist varchar(16) );
2. create table song( id int unique, name varchar(32), serial_number tinyint, music_id int );
3. alter table song add CONSTRAINT fk_song_music FOREIGN key (music_id) REFERENCES music(id);
4. create table review( content varchar(256), rating tinyint, review_time datetime, music_id int, user_id int );
5. alter table review add CONSTRAINT fk_review_music FOREIGN key (music_id) REFERENCES music(id);
6. alter table review add CONSTRAINT fk_review_user FOREIGN key (user_id) REFERENCES user(id);
7. create table user( username varchar(16) unique, image varchar(64), signature varchar(64), nickname varchar(16), id int primary key );
8. create table music_user( id int PRIMARY key, music_id int, user_id int );
9. alter table music_user add CONSTRAINT fk_music_user_music FOREIGN key (music_id) REFERENCES music(id);
10. alter table music_user add CONSTRAINT fk_music_user_user FOREIGN key (user_id) REFERENCES user(id);

posted @ 2024-09-08 10:33  wangyin0425  阅读(9)  评论(0编辑  收藏  举报