①
创建旅游线路分类表tab_category - cid旅游线路分类主键,自动增长 - cname旅游线路分类名称非空,唯一,字符串100 create table tab _ category(cid int primary key auto _ increment ,cname varchar(100)not null unique);
②
####创建旅游线路表tab_route -摆脱旅游线路主键,自动增长 - RNAME旅游线路名称非空,唯一,字符串100 -价格价格 - RDATE上架时间,日期类型 - CID外键,所属分类创建表tab _ route(rid int primary key auto _
increment, rname varchar(100)not null unique, price double, rdate date, cid int, foreign key(cid)references tab_category(cid)
);
③
创建用户表tab_user
- uid用户主键,自增长
- username用户名长度100,唯一,非空
- password密码长度30,非空
- name真实姓名长度100
-生日生日
-性别性别,定长字符串1
-电话手机号,字符串11
-电子邮件邮箱,字符串长度100 创建表tab_user( UID INT主键AUTO_INCREMENT, 用户名VARCHAR(100)唯一不为空 的用户名varchar(100)unique not null, password varchar(30)not null, name varchar(100), birthday date, sex char(1)default'up', telephone varchar(11), email varchar(100) );
④
创建收藏表tab_favorite
- rid旅游线路id,外键
- 日期收藏时间
- uid用户id,外键
- rid和uid不能重复,设置复合主键,同一个用户不能收藏同一个线路两次 创建表tab_favorite( rid int, date datetime, uid int, primary key(rid,uid), foreign key(rid)references tab_route(rid), foreign key(uid)references tab_user(uid) );