数据库课程设计说明书_第1页
数据库课程设计说明书_第2页
数据库课程设计说明书_第3页
数据库课程设计说明书_第4页
数据库课程设计说明书_第5页
已阅读5页,还剩32页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、课程设计说明书设计题目: 数据库系统插入和更新表的记录 _专 业: 信息管理与信息系统 班 级: _设 计 人: _山东科技大学2011年7月1日课程设计任务书学院 信息科学与工程学院 专业 班级 姓名 一、 课程设计题目:(1) 使用C#实现一个简单DBMS的部分功能插入和更新表的记录 (2) (3) 二、 课程设计主要参考资料:(1) 数据库系统概论(第四版),王珊、萨师煊主编,高等教育出版社 (2) ASP.NET(C#)基础教程 (3) 三、 课程设计应解决的主要问题:(1)用界面实现建立新表结构。 (2)实现对现有所有表的现实以及打开表。 (3)实现对表的插入及修改 (4)实现删除现

2、有表 四、 课程设计相关附件(如:图纸、软件等):(1) DBMS文件夹 (2) (3) 五、 任务发出日期: 2011-4-29 课程设计完成日期: 2011-7-01 指导教师签字: 系主任签字: 指导教师对课程设计的评语指导教师签字: 2011年 月 日一、 设计要求:(1) 设计内容创建表:实现:CREATE TABLE (, )表的新增和编辑:实现:INSERT INTO (, ) VALUES (, )说明:在最后一条记录后插入新的记录实现:UPDATE SET =,= WHERE 说明:一次更新一条记录(2) 设计要求1、表的物理文件采用Access、VFP等系统的文件;2、有两

3、个以上的关系模式,关系模式要满足实体完整性和参照完整性。3、语句以命令行或图形化界面两种形式实现;4、分析设计内容,画出程序流程图,设计表的存储结构;5、提交课程设计报告。(3) 任务步骤1、根据要求实现创建图形界面;2、创建一个表文件,写入表结构信息;3、打开一个表文件,查看记录;4、编辑表的记录;5、删除表;二、 需求分析:数据库系统能够有效地组织和管理大量的数据。研究数据库管理系统的实现技术,对于掌握数据库系统的原理和技术,了解数据库系统的内部结构,开发高效的数据库应用系统,具有重要意义。在建立了数据库之后,就应实现对表的建立、修改、删除,并对每个表插入记录、修改记录、删除记录。该系统要

4、进行必要的异常处理,从而保证系统的稳定性并且尽量使界面和谐美观,满足用户的需求。三、 设计思想:(1)总体思路此课程设计主要要完成的任务是创建表、删除表以及对表插入和更新记录。系统整体功能结构图如下:(2)主要结构四、 程序流程图:接下图接上图五、 主要源程序:(1)定义表结构体typedef structchar table_name10;/表名int property_num;/属性的个数char property_name1000010;/属性名int property_type1000;/属性类型(1=int,2=char)int property_null100;/属性是否为空(1=

5、允许,2=不允许)int property_key10;/是否主码(1=是主键,2=不是主键)TABLE;(2)读取表信息void read_from_file()alfp1=fopen(table.txt,r);fscanf(alfp1,%d,&table_num);for(int i=0;itable_num;i+)fscanf(alfp1,%s,&tablei.table_name);fscanf(alfp1,%d,&perty_num);for(int j=0;perty_num;j+)fscanf(alfp1,%s,&pe

6、rty_namej);fscanf(alfp1,%d,&perty_typej);fscanf(alfp1,%d,&perty_nullj);fscanf(alfp1,%d,&perty_keyj);fclose(alfp1);(3)写入表信息void write_to_file()alfp1=fopen(table.txt,w);fprintf(alfp1,%dn,table_num);for(int i=0;itable_num;i+)/表fprintf(alfp1,%s %dn,tablei.table_name,tablei.

7、property_num);for(int j=0;perty_num;j+)/属性 fprintf(alfp1,%s %d %d %dn,perty_namej,perty_typej,perty_nullj,perty_keyj);fprintf(alfp1,n);fclose(alfp1);(4)创建表void createtable()TABLE newtable;/用来存储新创建的表/step1:输入表名int tablename_is_right=0;while(!tablenam

8、e_is_right)system(cls);gotoxy(4,3);printf(表名:);gotoxy(10,3);scanf(%s,&newtable.table_name);/判断表名是否已经存在int name_is_equal=0;for(int i=0;itable_num;i+)if(compare(newtable.table_name,tablei.table_name)=0)name_is_equal=1;if(name_is_equal=1)gotoxy(4,5);printf(表%s已经存在,按任意键返回重新输入.,newtable.table_name);getch

9、();else tablename_is_right=1;/表名while/step2:输入属性个数int propertynum_is_right=0;while(!propertynum_is_right)system(cls);gotoxy(4,3);printf(表名: %-10sn,newtable.table_name);gotoxy(4,4);printf(属性个数:);gotoxy(14,4);scanf(%d,&perty_num);/判断属性个数是否正确if(perty_num=0)gotoxy(4,6);printf(您输入

10、的属性个数有误,按任意键重新输入.n);getch();else propertynum_is_right=1;/属性个数whileint i;/i代表循环中的属性int j;/j代表在i之前的属性 for(i=0;perty_num;i+)/i代表属性个数0,1,2. /step3:输入属性名int propertyname_is_right=0;while(!propertyname_is_right)system(cls);gotoxy(4,3);printf(表名: %-10sn,newtable.table_name);gotoxy(4,4);printf(

11、属性个数: %dn,perty_num); printf( -n); printf( 属性名 属性类型 是否允许为空 是否为主键 n); printf( (1=int 2=float) (1=是 2=否) (1=是 2=否)n); printf( -n);for(j=0;ji;j+)gotoxy(4,9+j);printf(属性%2d: %-10s %d %d %d,j+1,perty_namej,perty_typej,perty_nullj,perty_keyj);got

12、oxy(4,i+9);printf(属性%2d:,i+1);gotoxy(15,i+9);scanf(%s,&perty_namei);/判断属性名是否存在int name_is_equal=0; for(j=0;ji;j+)if(compare(perty_namei,perty_namej)=0) name_is_equal=1; if(name_is_equal=1) gotoxy(4,10+perty_num);printf(属性%s已经存在,按任意键返回重新输入.,

13、perty_namei); getch(); else propertyname_is_right=1;/属性名while/step4:选择属性类型int propertytype_is_right=0;while(!propertytype_is_right)system(cls);gotoxy(4,3);printf(表名: %-10sn,newtable.table_name);gotoxy(4,4);printf(属性个数: %dn,perty_num); printf( -n); printf( 属性名 属性类型 是否允许为空 是否为主键n); printf(

14、 (1=int 2=float) (1=是 2=否) (1=是 2=否)n); printf( -n);for(j=0;ji;j+)gotoxy(4,9+j);printf(属性%2d: %-10s %d %d %d,j+1,perty_namej,perty_typej,perty_nullj,perty_keyj);gotoxy(4,i+9);printf(属性%2d: %-10s,i+1,perty_namei);gotoxy(31,i+9);scanf(%d,&new

15、perty_typei);/判断选择的属性类型是否正确 if(perty_typei!=1&perty_typei!=2)gotoxy(4,i+9+2);printf(您选择的属性类型有误,按任意键重新选择.n);getch();else propertytype_is_right=1;/属性类型while/step5:选择是否允许为空int propertynull_is_right=0;while(!propertynull_is_right)system(cls);gotoxy(4,3);printf(表名: %-10sn

16、,newtable.table_name);gotoxy(4,4);printf(属性个数: %dn,perty_num); printf( -n); printf( 属性名 属性类型 是否允许为空 是否为主键 n); printf( (1=int 2=float) (1=是 2=否) (1=是 2=否)n); printf( -n);for(j=0;ji;j+)gotoxy(4,9+j);printf(属性%2d: %-10s %d%d %d,j+1,perty_namej,perty_typej,newtable.pr

17、operty_nullj,perty_keyj);gotoxy(4,i+9);printf(属性%2d: %-10s %d,i+1,perty_namei,perty_typei);gotoxy(48,i+9);scanf(%d,&perty_nulli);/判断选择是否正确 if(perty_nulli!=1&perty_nulli!=2)gotoxy(4,i+9+2);printf(您的选择有误,按任意键重新选择.n);getch();else p

18、ropertynull_is_right=1;/是否允许为空while/step6:选择是否为主键int propertypropertykey_is_right=0;while(!propertypropertykey_is_right)system(cls);gotoxy(4,3);printf(表名: %-10sn,newtable.table_name);gotoxy(4,4);printf(属性个数: %dn,perty_num); printf( -n); printf( 属性名 属性类型 是否允许为空 是否为主键 n); printf( (1=int 2=

19、float) (1=是 2=否) (1=是 2=否)n); printf( -n);for(j=0;ji;j+)gotoxy(4,9+j);printf(属性%2d: %-10s %d %d %d,j+1, perty_namej,perty_typej,perty_nullj,perty_keyj);gotoxy(4,i+9);printf(属性%2d: %-10s %d %d,i+1, perty_namei,perty_typei,newtabl

20、perty_nulli);gotoxy(61,i+9);scanf(%d,&perty_keyi);/判断选择是否正确 if(perty_keyi!=1&perty_keyi!=2)gotoxy(4,i+9+2);printf(您的选择有误,按任意键重新选择.n);getch();else propertypropertykey_is_right=1;/主键的非空属性应该为不允许空if(perty_keyi=1&perty_nulli=1)gotoxy(4,i+9+

21、2);printf(该属性设为主键,因此改为不允许为空,按任意键继续.n);getch();perty_nulli=2;system(cls);gotoxy(4,3);printf(表名: %-10sn,newtable.table_name);gotoxy(4,4);printf(属性个数: %dn,perty_num); printf( -n); printf( 属性名 属性类型 是否允许为空 是否为主键n); printf( (1=int 2=float) (1=是 2=否) (1=是 2=否)n); printf( -n); for(j=

22、0;j=i;j+) gotoxy(4,9+j);printf(属性%2d: %-10s %d %d %d,j+1,perty_namej,perty_typej,perty_nullj,perty_keyj);if(i=perty_num-1) printf(n);/是否为主键while/属性for/step7:记录操作 int year,mon,day,hour,min,sec; getcurrenttime(&year,&mon,&day,&hour,&min,&sec)

23、; fprintf(alfp2,n%d年%d月%d日 %d:%d:%d执行如下操作:n,year,mon,day,hour,min,sec); fprintf(alfp2,用户建立表成功,表的内容是:表名:%s,表属性个数:%d,主键有:,newtable.table_name,perty_num);for(int k=0;perty_num;k+)/记录主键 if(perty_keyk=1) fprintf(alfp2,%s、,perty_namek);fputc(n,alfp2);/step8

24、:建表成功printf( -n);tabletable_num=newtable;table_num+;gotoxy(4,11+perty_num);printf(建表成功,按任意键返回.);getch();menu();(5)修改表void altertable()if(table_num=0)system(cls); printf(nnn); printf( 没有可修改的表,按任意键返回.);getch();menu();else/step1:选择操作选项int choice;int choice_is_right=0;while(!choice_is_right)

25、system(cls); printf(nn); printf( 请选择您要进行的修改操作(1-%d):nn,4*table_num);printf(n);printf( 表名 操作 操作 操作 操作n);printf( -n);for(int i=0;itable_num;i+)printf(%-10s %2d:修改表名%2d:增加属性%2d:删除属性 %2d:修改属性n,tablei.table_name,i*4+1,i*4+2,i*4+3,i*4+4);printf( -n); gotoxy(35+(4*table_num)/10+(4*table_num)/100,3);scanf(%

26、d,&choice);/判断选择的操作选项是否正确if(choice4*table_num)gotoxy(4,10+table_num);printf(您的选择有误,按任意键重新选择.);getch();elsechoice_is_right=1;int choice2=choice%4;/代表表的序列switch(choice2)case 1:/ step2:修改表名char newtablename10; int tablename_is_right=0; while(!tablename_is_right) system(cls); printf(nnn); printf( 表名操作 操

27、作 操作 操作n); printf( -n); for(int i=0;itable_num;i+) printf( %-10s %2d:修改表名 %2d:增加属性 %2d:删除属性 %2d:修改属性n, tablei.table_name,i*4+1,i*4+2,i*4+3,i*4+4);printf( -n);gotoxy(4,8+table_num);printf(原表名:%-10s 新表名:,tablechoice/4.table_name);gotoxy(32,8+table_num);scanf(%s,&newtablename);int tablename_is_equal=0;

28、/判断表名是否已经存在 for(int k=0;k0) gotoxy(4,10+table_num);printf(%s表已经存在,按任意键重新输入.n,newtablename); getch(); else tablename_is_right=1;/while/记录操作int year,mon,day,hour,min,sec; getcurrenttime(&year,&mon,&day,&hour,&min,&sec); fprintf(alfp2,n%d年%d月%d日 %d:%d:%d执行如下操作:n,year,mon,day,hour,min,sec); fprintf(alfp

29、2,修改表名成功,表%s的表名被修改为%s,tablechoice/4.table_name,newtablename);/代换原来的for(int n=0;n10;n+)tablechoice/4.table_namen=newtablenamen;/修改表名成功 gotoxy(4,10+table_num);printf(表名修改成功,按任意键返回.); getch(); menu();break;/case1case 2:/ step3:增加属性/属性名char newpropertyname10;int propertyname_is_right=0; while(!propertyn

30、ame_is_right)system(cls); printf(nnn); printf( 请填写表%s新增加的属性:n,tablechoice/4.table_name); printf(n);printf( -n); printf( 属性名属性类型是否允许为空是否为主键n); printf( (1=int 2=float) (1=是 2=否) (1=是 2=否)n); printf( -n);for(int m=0;mtablechoice/4.property_num;m+) gotoxy(4,10+m);printf(属性%2d: %-10s %d %d %dn,m+1, table

31、choice/4.property_namem,tablechoice/4.property_typem,tablechoice/4.property_nullm,tablechoice/4.property_keym);printf( 属性%2d:,tablechoice/4.property_num+1);gotoxy(15,10+tablechoice/4.property_num);scanf(%s,&newpropertyname); /判断属性名是否已经存在int propertyname_is_equal=0;for(int l=0;l0) gotoxy(4,12+tablech

32、oice/4.property_num);printf(表中已经存在名为%s的属性,按任意键重新输入.n,newpropertyname); getch(); elsepropertyname_is_right=1;for(int n=0;n10;n+) tablechoice/4.property_nametablechoice/4.property_numn=newpropertynamen;/属性名while/属性类型 int propertytype_is_right=0; while(!propertytype_is_right) system(cls); printf(nnn);

33、printf( 请填写表%s新增加的属性:n,tablechoice/4.table_name); printf(n);printf( -n); printf(属性名 属性类型 是否允许为空是否为主键n); printf( (1=int 2=float) (1=是 2=否) (1=是 2=否)n); printf( -n);for(int m=0;mtablechoice/4.property_num;m+) gotoxy(4,10+m);printf(属性%2d: %-10s %d %d %dn,m+1, tablechoice/4.property_namem,tablechoice/4.

34、property_typem,tablechoice/4.property_nullm,tablechoice/4.property_keym);printf( 属性%2d: %-15s,tablechoice/4.property_num+1,tablechoice/4.property_nametablechoice/4.property_num); gotoxy(31,10+tablechoice/4.property_num);scanf(%d,&tablechoice/4.property_typetablechoice/4.property_num); /判断选择的属性类型是否正确

35、if(tablechoice/4.property_typetablechoice/4.property_num!=1&tablechoice/4.property_typetablechoice/4.property_num!=2) gotoxy(4,12+tablechoice/4.property_num);printf(您选择的数据类型有误,按任意键重新选择.n); getch(); else propertytype_is_right=1;/属性类型while/是否允许为空 int propertynull_is_right=0; while(!propertynull_is_rig

36、ht) system(cls); printf(nnn); printf( 请填写表%s新增加的属性:n,tablechoice/4.table_name); printf(n);printf( -n); printf(属性名 属性类型是否允许为空 是否为主键n); printf( (1=int 2=float)(1=是 2=否)(1=是 2=否)n); printf( -n);for(int m=0;mtablechoice/4.property_num;m+) gotoxy(4,10+m);printf(属性%2d:%-10s%d %d %dn,m+1, tablechoice/4.property_namem,tablechoice/4.property_typem,tablechoice

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论