1、图 1玩家信息E-R图2. 游戏信息E-R图(如图2所示)图 2游戏信息E-R图3. 排行信息E-R图(如同3所示)图 3排行信息E-R图4. 交易信息E-R图(如图4所示)图 4职务信息E-R图5. 游戏币信息E-R图(如图5所示)图 5考勤信息E-R图6. 整体简洁E-R图(如图6所示)图 6整体简洁E-R图7. 用户信息E-R图(如图7所示)图 7用户信息E-R图3. 逻辑结构设计1. 关系模型设计1) 玩家信息对应的关系模型玩家(玩家编号(主键),姓名,性别,游戏编号(外键),等级,充值总金额2) 游戏信息对应的关系模型游戏(游戏编号(主键),游戏名称,运营公司,上线时间)3) 排行信
2、息对应的关系模型排行(游戏编号(外键),游戏人数,充值总金额)4) 交易信息对应的关系模型交易(交易编号(主键),玩家编号,游戏编号,RMB金额,交易时间)5) 考勤信息对应的关系模型考勤(员工编号(主键一部分),日期(主键一部分),请假次数,迟到次数,缺勤次数)6) 用户信息对应的关系模型用户(用户名,密码,权限)2. 数据库表结构的设计1) 玩家信息表结构2) 游戏信息表结构3) 排行信息表结构4) 交易信息表结构5) 游戏币信息表结构4. 数据库的实现1. 创建玩家信息表CREATE TABLE player(pid int primary key,pname varchar(10),s
3、ex varchar(2),gid int,levels int,money int);2. 向玩家信息表中插入记录insert into player values(1,张三,男,1,58,51);insert into player values(2,李四,1,59,58);insert into player values(3,王五,2,27,65);insert into player values(4,赵六,2,25,25);insert into player values(5,徐涛,2,29,5);insert into player values(6,石头,3,27,53);i
4、nsert into player values(7,陈子文,3,25,5);insert into player values(8,王灿女,4,66,35);insert into player values(9,徐香气,4,66,25);insert into player values(10,郭俊明,5,6,45);insert into player values(11,王一insert into player values(12,王二,3,6,5);insert into player values(13,王三,4,66,30);insert into player values(1
5、4,王四,2,76,35);insert into player values(15,王五五insert into player values(16,王六,1,89,3);insert into player values(17,王七 ,4,54,35);insert into player values(18,王八,2,66,31);insert into player values(19,王九,4,86,35);insert into player values(20,王十,1,66,37);insert into player values(21,赵一,4,66,54);insert i
6、nto player values(22,赵二,3,66,35);insert into player values(23,赵三,1,69,38);insert into player values(24,赵四,5,66,39);insert into player values(25,赵五,4,60,5);3. 在表空间上创建游戏表CREATE TABLE game( gid int primary key,gname varchar(10),type varchar(5) NOT NULL,operating_company varchar(10),birth_date date4. 向游
7、戏表中插入记录insert into game values(1,吞噬天地网游网易, 2014-9-1insert into game values(2,英雄联盟竞技腾讯2010-5-20insert into game values(3,DOTA2暴雪2006-1-30insert into game values(4,炫舞休闲2012-6-1insert into game values(5,模拟人生模拟2010-2-255. 创建排行信息表CREATE TABLE rankpeoplesum int,moneysum int6. 向排行信息表中插入记录insert into rank v
8、alues(1,25216020,35000);insert into rank values(2,26514260,250000);insert into rank values(3,215656560,205000);insert into rank values(4,2515540,350000);insert into rank values(5,1655620,3000);7. 创建交易信息表CREATE TABLE salerecordsaleid int primary key,pid int,RMB int,saledate date 8. 向交易信息表中插入记录insert
9、into salerecord values(1,1,2,35000,insert into salerecord values(2,2,3,250000,2013-8-12insert into salerecord values(3,3,4,205000,2014-9-12insert into salerecord values(4,4,1,350000,2012-7-21insert into salerecord values(5,5,4,7000,2014-9-3insert into salerecord values(6,11,4,35050,2010-3-1insert in
10、to salerecord values(7,6,5,50010,2014-4-17insert into salerecord values(8,9,2,935000,2009-8-5insert into salerecord values(9,6,3,835000,2015-3-14insert into salerecord values(10,18,1,3215000,2010-3-11insert into salerecord values(11,22,2,1325000,2014-3-19. 创建游戏币信息表CREATE TABLE gamebgameb int10. 向游戏币
11、信息表中插入记录insert into gameb values(1,8,800);insert into gameb values(2,9,9000);insert into gameb values(3,65,6500);insert into gameb values(4,5,500);insert into gameb values(5,25,25000);insert into gameb values(6,25,2500);insert into gameb values(7,25,2500);11. 创建用户信息表create table users(username char(
12、10) not null,password char(30) not null,juris char(30)12. 向用户信息表中插入记录insert into users(username,password,juris)values(YH123所有权限YH00查询13. 建立外键和CHCEK约束alter table playeradd constraint player_game foreign key (gid)references game(gid);alter table rankadd constraint rank_game foreign key (gid)alter table salerecordadd constraint salerecord_player foreign key (pid)references player(pid);add constraint salerecord_game foreign key (gid)add constraint check_sex check (sex in();5. 主要代码1. 查询代码1) 查询王五的等级select levels from playerwhere player.pname=;2) 查询模拟戏人生的运营公司select
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1