[MySQL光速入门]003 留点做业...

建立数据库library

建立数据表

  1. 图书类别表(booktype)

序号 属性名称 含义 数据类型 是否为空 备注
1 typeid 类别编号 int not null 主键
2 typename 类别名称 varchar(20) null
  1. 图书信息表(book)

序号 属性名称 含义 数据类型 是否为空 备注
1 bookid 图书编号 char(10) not null 主键
2 bookname 图书名称 varchar(20) not null
3 typeid 类别编号 int null 外键
4 bookauthor 图书做者 varchar(20) null
5 bookpublisher 出版社 varchar(50) null
6 bookprice 图书价格 doublue null
7 borrowsum 借阅次数 int null
  1. 图书存储信息表(bookstorage)

序号 属性名称 含义 数据类型 是否为空 备注
1 bookbarcode 图书条码 char(20) not null 主键
2 bookid 图书编号 char(10) not null 外键
3 bookintime 图书入馆时间 datetime null
4 bookstatus 图书状态 varchar(4) null
  1. 读者类别表(readertype)

序号 属性名称 含义 数据类型 是否为空 备注
1 retypeid 类别编号 int not null
2 typename 类别名称 varchar(20) not null
3 borrowquantity 可借数量 int not null
4 borrowday 可借天数 int null
  1. 读者信息表(reader)

序号 属性名称 含义 数据类型 是否为空 备注
1 readerid 读者编号 char(10) not null 主键
2 readername 读者姓名 varchar(20) not null
3 readerpass 读者密码 varchar(20) not null
4 retypeid 类别编号 int null 外键
5 readerdate 发证日期 datetime null
6 readerstatus 借书证状态 varchar(4) null
  1. 图书借阅表(bookborrow)

序号 属性名称 含义 数据类型 是否为空 备注
1 borrowid 借阅号 char(10) not null 主键
2 bookbarcode 图书条码 char(20) not null 外键
3 readerid 读者编号 char(10) not null 外键
4 borrowtime 借书日期 datetime null
5 returntime 还书日期 datetime null
6 borrowstatus 借阅状态 varchar(4) null

为建立的表插入以下数据

  1. 图书类别表(booktype)

typeid typename
1 天然科学
2 数学
3 计算机
4 建筑水利
5 旅游地理
6 励志/自我实现
7 工业技术
8 基础医学
9 室内设计
10 人文景观
  1. 图书信息表(book)

bookid bookname typeid bookauthor bookpublisher bookprice borrowsum
TP39/1712 Java程序设计 3 陈永红 机械工业出版社 35.5 30
013452 离散数学 2 张小新 机械工业出版社 45.5 10
TP/3452 JSP程序设计案例 3 刘城清 电子工业出版社 42.8 8
TH/2345 机械设计手册 7 黄明凡 人民邮电出版社 40 10
R/345677 中医的故事 8 李奇德 国防工业出版社 20.0 5
  1. 图书存储信息表(bookstorage)

bookbarcode bookid bookintime bookstatus
132782 TP39/1712 2009-08-10 00:00:00 在馆
132789 TP39/1712 2009-08-10 00:00:00 借出
145234 013452 2008-12-06 00:00:00 借出
145321 TP/3452 2007-11-04 00:00:00 借出
156833 TH/2345 2009-12-04 00:00:00 借出
345214 R/345677 2008-11-03 00:00:00 在馆
  1. 读者类别表(readertype)

retypeid typename borrowquantity borrowday
1 学生 10 30
2 教师 20 60
3 管理员 15 30
4 职工 15 20
  1. 读者信息表(reader)

readerid readername readerpass retypeid readerdate readerstatus
0016 苏小东 123456 1 1999-09-09 00:00:00 有效
0017 张明 123456 1 2010-09-10 00:00:00 有效
0018 梁君红 123456 1 2010-09-10 00:00:00 有效
0021 赵清远 123456 2 2010-07-01 00:00:00 有效
0034 李瑞清 123456 3 2009-08-03 00:00:00 有效
0042 张明月 123456 4 1997-04-23 00:00:00 有效
  1. 图书借阅表(bookborrow)

borrowid bookbarcode readerid borrowtime returntime borrowstatus
001328 132789 0017 2011-01-24 00:00:00 2011-02-28 00:00:00 已还
001356 145234 0018 2011-02-12 00:00:00 2011-02-27 00:00:00 已还
001432 132782 0016 2011-03-04 00:00:00 2011-04-05 00:00:00 已还
001435 145321 0021 2011-08-09 00:00:00 2011-09-02 00:00:00 已还
001578 156833 0034 2011-10-01 00:00:00 2011-11-01 00:00:00 未还
001679 345214 0042 2011-02-21 00:00:00 2011-03-05 00:00:00 未还

建立数据库stucourse

没有表结构, 根据数据, 本身决定使用哪一种数据类型git

  1. 学生表(student)

sid sname sex age dept
1001 宋江 25 计算机系
3002 张明 23 生物系
1003 李小鹏 26 计算机系
1004 郑冬 25 计算机系
4005 李晓红 27 工商管理
5006 赵紫月 24 外语系
  1. 教师表(teacher)

tid tname title salary dept cid
3102 李明 初级 2500 计算机系 C1
3108 黄晓明 初级 4000 生物系 C3
4105 张晓红 中级 3500 工商管理 C2
5102 宋力跃 高级 3500 物理系 C4
3106 赵明阳 初级 1500 地理系 C2
7108 张丽 高级 3500 生物系 C3
9103 王彬 高级 3500 计算机系 C1
7101 王力号 初级 1800 生物系 C1
  1. 课程表(courseinfo)

cid cname cbook ctest dept
C1 计算机基础 b1231 2009-4-6 计算机系
C2 工商管理基础 b1232 2009-7-16 工商管理
C3 生物科学 b1233 2010-3-6 生物系
C4 大学物理 b1234 2009-4-26 物理系
C5 数据库原理 b1235 2010-2-6 计算机系
  1. 选课表(scourse)

sid score cid tid
1001 87 C1 3102
1001 77 C2 4105
1001 63 C3 3108
1001 56 C4 5102
3002 78 C3 3108
3002 78 C4 5102
1003 89 C1 9103
1004 56 C2 3106
4005 87 C4 5102
5006 null C1 7101
  1. 教材表(bookinfo)

bid bname bpublish bprice quantity
b1231 Image Processing 人民大学出版社 34.56 8
b1212 Signal Processing 清华大学出版社 51.75 10
b1233 Digital Signal Processing 邮电出版社 48.5 11
b1234 The Logic Circuit 北大出版社 49.2 40
b1235 SQL Techniques 邮电出版社 65.4 20

快速跳转

相关文章
相关标签/搜索