-
大小: 1.04MB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2023-10-23
- 語言: C/C++
- 標(biāo)簽: DBMS??數(shù)據(jù)庫??課程設(shè)計(jì)??C數(shù)據(jù)庫??
資源簡介
課程設(shè)計(jì)時(shí)寫的數(shù)據(jù)庫,實(shí)現(xiàn)了大部分操作,建刪改查,并發(fā)控制等,還有當(dāng)時(shí)寫的時(shí)候的設(shè)計(jì)文檔

代碼片段和文件信息
#include?“stdio.h“
#include?“stdlib.h“
#include?“string.h“
#include?“conio.h“
#include?“windows.h“
#include?“iostream.h“
#include?“power.h“
#define?MAX_PROLEN?10 //最大屬性字符長度
#define?MAX_PRONUM?8 //最大屬性個(gè)數(shù)
#define?MAX_RECNUM?30 //最大記錄個(gè)數(shù)?
#define?MAX_TNAME?15 //最長表名
#define?MAX_TNUM?15 //最大表個(gè)數(shù)?
#define?MAX_VIEWNUM?15 //最大表個(gè)數(shù)
#define?MAX_USERLEN?10 //用戶名長度
#define?MAX_PWDLEN?18 //密碼最大長度
#define?MAX_USERNUM?10 //用戶名最大個(gè)數(shù)
//***************************
typedef?struct
{
int?re_num; //記錄的個(gè)數(shù)
int?pro_num; //屬性個(gè)數(shù)
int?key_no; //規(guī)定關(guān)鍵字是第幾個(gè)屬性使用的是下標(biāo)從0開始
//int?pro_len[MAX_PRONUM]; //屬性長度
char?key[MAX_PROLEN]; //定義關(guān)鍵字關(guān)鍵字也是一個(gè)屬性
char?tname[MAX_TNAME]; //表名
char?proname[MAX_PRONUM][MAX_PROLEN]; //屬性的名字
char?protype[MAX_PRONUM]; //屬性的類型
char?record[MAX_RECNUM][MAX_PRONUM][MAX_PROLEN]; //三維表保存的內(nèi)容是記錄的值
}table;
typedef?struct
{
char?proname[MAX_PRONUM][MAX_PROLEN]; //可見的屬性
int?prono[MAX_PRONUM]; //可見屬性的下標(biāo)
char?tname[MAX_TNAME]; //對(duì)應(yīng)的表名
char?vname[MAX_TNAME]; //視圖名
int?pro_num;
}view; //視圖,該試圖對(duì)應(yīng)一個(gè)表,一個(gè)表可以對(duì)應(yīng)多個(gè)視圖
typedef?struct
{
char?iname[MAX_TNAME]; //一個(gè)索引對(duì)應(yīng)一個(gè)表
int?key_num;
char?key[MAX_RECNUM][MAX_PROLEN]; //
}index;
typedef?struct
{
char?username[MAX_USERLEN];
char?pwd[MAX_PWDLEN];
int?revoke; //0是glz,1是nb
}user;
table?NULLTABLE; //空表,初始化的時(shí)候定義NULLTABLE.key_no=-1
table?t[MAX_TNUM];
view?vi[MAX_VIEWNUM];
index?ind[MAX_TNUM];
user?u[MAX_USERNUM];
FILE?*alfp;
int?t_num=0;
int?i_num=0;
int?v_num=0;
int?u_num=0;
int?CURRENTREVOKE;
int?speedfactor=10;
bool?dbislock()
{
int?databaselock;
FILE?*fp;
if((fp=fopen(“dblock.db““rb“))==NULL)
{
printf(“不存在鎖文件請(qǐng)檢查后再使用.\a“);
fclose(fp);
exit(-1);
}
fread(&databaselocksizeof(int)1fp);
fclose(fp);
if(databaselock==1)
return?true;
else?
return?false;
}
void?dblock()
{
int?databaselock=1;
FILE?*fp;
if((fp=fopen(“dblock.db““wb“))==NULL)
{
printf(“不存在鎖文件請(qǐng)檢查后再使用.\a“);
fclose(fp);
exit(-1);
}?
fwrite(&databaselocksizeof(int)1fp);
fclose(fp);
}
void?dbunlock()
{
int?databaselock=0;
FILE?*fp;
if((fp=fopen(“dblock.db““wb“))==NULL)
{
printf(“不存在鎖文件請(qǐng)檢查后再使用.\a“);
fclose(fp);
exit(-1);
}
fwrite(&databaselocksizeof(int)1fp);
fclose(fp);
}
void?BackUp()
{
if(CURRENTREVOKE==0)
{
gotoxy(124);printf(“\a對(duì)不起您的權(quán)限不允許這項(xiàng)操作.按任意鍵返回...“);
getch();
return;
}
if(!dbislock()) //沒有鎖,那就加鎖@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
dblock(); //dblock();?????dbunlock();
else
{
clrscr();
printf(“數(shù)據(jù)庫處于鎖狀態(tài),即使超級(jí)用戶也不能進(jìn)行修改!\a“);
printf(“\n按任意鍵返回...“);
getch();
return;
}
char?filename[20];
clrscr();
PrintColorStringXY(367014015“數(shù)據(jù)的備份“);
Drawframe(2060514);
gotoxy(279);?printf(“輸入備份數(shù)據(jù)的文件名:“);
gotoxy(2710);
gets(filename);
FILE?*fp;
if((fp=fopen(filename“wb“))==NULL)
fp=fopen(filename“wb+“);
//以下共6個(gè)文件提供全體打包保存dblock.dbtable.dbindex.dbview.dbdic.dblog.txt
//*****************對(duì)dblock.db的備份****
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件??????46072??2008-07-20?11:11??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\可執(zhí)行文件\backup.db
?????文件??????????0??2008-07-22?10:54??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\可執(zhí)行文件\config.db
?????文件??????????4??2008-07-23?10:34??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\可執(zhí)行文件\dblock.db
?????文件?????290921??2008-07-23?10:59??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\可執(zhí)行文件\DBMS.exe
?????文件????????659??2008-07-23?10:34??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\可執(zhí)行文件\dic.db
?????文件???????4804??2008-07-23?10:34??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\可執(zhí)行文件\index.db
?????文件???????2802??2010-01-06?20:19??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\可執(zhí)行文件\log.txt
?????文件????????316??2008-07-23?10:58??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\可執(zhí)行文件\READ_ME_BEFORE_RUN.txt
?????文件??????37924??2008-07-23?10:34??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\可執(zhí)行文件\table.db
?????文件???????2224??2008-07-23?10:34??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\可執(zhí)行文件\view.db
?????文件?????195072??2008-07-23?10:07??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\實(shí)驗(yàn)報(bào)告4--7\20050675_段金晟_E4_數(shù)據(jù)庫原理實(shí)驗(yàn).doc
?????文件??????48640??2008-07-23?10:20??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\實(shí)驗(yàn)報(bào)告4--7\20050675_段金晟_E5_數(shù)據(jù)庫原理實(shí)驗(yàn).doc
?????文件??????27648??2008-07-23?10:49??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\實(shí)驗(yàn)報(bào)告4--7\20050675_段金晟_E6_數(shù)據(jù)庫原理實(shí)驗(yàn).doc
?????文件?????524288??2008-07-23?10:45??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\實(shí)驗(yàn)報(bào)告4--7\20050675_段金晟_E7_數(shù)據(jù)庫原理實(shí)驗(yàn).doc
?????文件?????528896??2008-07-24?11:52??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\整體文檔實(shí)驗(yàn)8\數(shù)據(jù)庫課程設(shè)計(jì)報(bào)告.doc
?????文件??????46072??2008-07-20?11:11??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\源程序\backup.db
?????文件??????????0??2008-07-22?10:54??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\源程序\config.db
?????文件??????74689??2008-07-23?10:11??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\源程序\db2.cpp
?????文件??????????4??2008-07-23?10:34??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\源程序\dblock.db
?????文件????????659??2008-07-23?10:34??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\源程序\dic.db
?????文件???????4804??2008-07-23?10:34??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\源程序\index.db
?????文件???????2152??2008-07-23?10:34??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\源程序\log.txt
?????文件???????8679??2008-07-22?10:33??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\源程序\power.h
?????文件????????352??2008-07-23?10:56??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\源程序\READ_ME_BEFORE_RUN.txt
?????文件??????37924??2008-07-23?10:34??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\源程序\table.db
?????文件???????2224??2008-07-23?10:34??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\源程序\view.db
?????目錄??????????0??2008-09-03?10:41??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\可執(zhí)行文件
?????目錄??????????0??2008-09-03?10:41??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\實(shí)驗(yàn)報(bào)告4--7
?????目錄??????????0??2010-01-06?20:20??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\整體文檔實(shí)驗(yàn)8
?????目錄??????????0??2008-09-03?10:41??20050675_段金晟_數(shù)據(jù)庫原理實(shí)驗(yàn)\源程序
............此處省略5個(gè)文件信息
評(píng)論
共有 條評(píng)論