Реализация системного каталога. Основные хранимые характеристики: отношения, атрибуты с типами связи, индексы
Дипломная работа - Компьютеры, программирование
Другие дипломы по предмету Компьютеры, программирование
utton1.Visible:=true;.Button1.Caption:='Показать';i:=0 to Form1.StringGrid1.RowCount doj:=0 to Form1.StringGrid1.ColCount do.StringGrid1.Cells[i,j]:='';.Visible:=true;.StringGrid1.ColCount:=5;.StringGrid1.Cells[0,0]:='Таблица';.StringGrid1.Cells[1,0]:='Поле';.StringGrid1.Cells[2,0]:='Тип';.StringGrid1.Cells[3,0]:='Primary';.StringGrid1.Cells[4,0]:='Foreign';;TForm1.RadioButton3Click(Sender: TObject);.Memo1.Visible:=true;(Memo1);;
TForm1.RadioButton4Click(Sender: TObject);i,j:integer;.Memo1.Visible:=false;.Visible:=true;.StringGrid1.ColCount:=3;i:=0 to Form1.StringGrid1.RowCount doj:=0 to Form1.StringGrid1.ColCount do.StringGrid1.Cells[i,j]:='';.StringGrid1.Cells[0,0]:='Индекс';.StringGrid1.Cells[1,0]:='Таблица';.StringGrid1.Cells[2,0]:='Поле';(StringGrid1);;
TForm1.N5Click(Sender: TObject);;:=3;.ComboBox1.Visible:=true;.Label1.Visible:=true;.Label1.Caption:='Таблица';.Label3.Visible:=true;.Label3.Caption:='Тип';.Button1.Visible:=true;.Button1.Caption:='Добавить';.ComboBox2.Visible:=true;.Items.Clear;.Items.Add('Foreign');.Items.Add('Primary');
ComboBox2.Text:='Выбрать';;
//выбираем имя таблицы для заполнения поля
procedure TForm1.ComboBox1DropDown(Sender: TObject);, j, k, n, m: integer;(MyAction=2)or (MyAction=3) or (MyAction=4) then:=FSpisokTables;.Items.Clear;:=1;:='';i'&' then Temp:=Temp+SpisokTables[i].Items.Add(Temp);:='';;{else}(i);; {while}; {if}; {pocedure}TForm1.ComboBox2Select(Sender: TObject);(MyAction=3) then(ComboBox2.Text='Primary') then.Visible:=true;.Caption:='Primary';.Visible:=true;.Visible:=false;.Visible:=false;{if}if (ComboBox2.Text='Foreign').Visible:=true;.Caption:='Foreign';.Visible:=true;.Visible:=true;.Caption:='References';
// label4.Caption:='Foreign';.Visible:=true;;{then};{if};
.
MyFunction;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,, StdCtrls, Grids;AddTable(NameTable: string);AddField(NameTable: string; NameField: string; NameType: string; LengthType: string);AddKey(NameTable: string; Primary: string; Foreign: string; References: string; Why: string);AddIndex(NameInd,NameTable,NameField:string);InTable(NameTable: string):boolean;InField(NameTable: string; NameField: string):boolean;InKey(NameTable: string; Why: string):boolean;FPrintStr():string;PrintData(PrintStr,name:string; StringGrid1:TStringGrid);printTables(StringGrid1:TStringGrid);PrintRelations(Memo1:Tmemo);PrintIndex(StringGrid1:TStringGrid);FSpisokTables:string;FSpisokField:string;FSpisokKeys:string;AlterTable(OldName: string; NewName: string):boolean;: string='syscatalog\tables.txt';: string='syscatalog\field.txt';: string='syscatalog\keys.txt';: string='syscatalog\index.txt';: TextFile; //Файл таблиц: TextFile; //Файл полей: TextFile; //Файл ключей:TextFile;,SpisokField,SpisokKeys,Content,Temp,Temp1,Temp2, Temp3, Temp4:string;, Primary, Foreign, Column, ColumnType,SpisokPrint: string;:boolean;: integer;AddTable(NameTable: string);(Tables,PathToTables);(Tables);(Tables,NameTable);(Tables);;AddField(NameTable: string; NameField: string; NameType: string; LengthType: string);(field, PathToField);(field);:=Trim(NameTable)+'|'+Trim(NameField)+'|'+Trim(NameType)
+'|'+Trim(LengthType);(field, Temp);(field);;
AddKey(NameTable: string; Primary: string; Foreign: string; References: string; Why: string);: integer;:=false;(Keys, PathToKeys);(Keys);:='';not eof(Keys) do(Keys, Content);:=1;:='';i'&' then Temp:=Temp+SpisokKeys[i](Keys, Temp);:='';;(i);;(Keys);;AddIndex(NameInd,NameTable,NameField:string);:='';(Index, PathToInd);(index);:=NameInd+'|'+NameTable+'|'+NameField ;(Index, Temp);(Index);;
//Существование таблицыInTable(NameTable: string):boolean;:=false;(Tables, PathToTables);(Tables);:='';not eof(Tables) do(Tables, Temp);(NameTable=Temp) then Logic:=true;(Tables);:=Logic;;
//Существование поля в таблицеInField(NameTable: string; NameField: string):boolean;, j, k, n, m: integer;(Field, PathToField);:=0;:=0;:=1;:='';n2) then Temp1:=Temp1+Content[i]if Content[i]='|' then begin Temp1:=Temp1+Content[i]; inc(j); end;(Content[i]='|') and (j=2) thenTemp1[Length(Temp1)]='|' then Temp1:=Copy(Temp1,1,Length(Temp1)-
);Temp=Temp1 then inc(k);:='';:=Length(Content);;(i);;;:='';(Field);;(n);;m=k then Logic:=trueLogic:=false;:=Logic;;
//Существование ключа в таблицеInKey(NameTable: string; Why: string):boolean;, j, n:integer;:=false;(Keys, PathToKeys);(Keys);:='';(not eof(Keys)) and (not Logic) do(Keys, Content);:=1;:=0;:='';i1 then Logic:=trueLogic:=false;;(Keys);:=Logic;;
//Список таблицFSpisokTables:string;(Tables, PathToTables);(Tables);:='';not eof(Tables) do(Tables, Temp);:=SpisokTables+Temp+'&';;(Tables);:=SpisokTables;;
//Список полейFSpisokField:string;(Field, PathToField);(Field);:='';not eof(Field) do(Field, Temp);:=SpisokField+Temp+'&';;(Field);:=SpisokField;;
//Список ключейFSpisokKeys:string;(Keys, PathToKeys);(Keys);:='';not eof(Keys) do(Keys, Temp);:=SpisokKeys+Temp+'&';;(Keys);:=SpisokKeys;;FPrintStr():string;, j, k:integer;:=FSpisokTables;:=1;:='';:='';i'&') then Temp:=Temp+SpisokField[j]:=0;k<=Length(Temp) doTemp[k]='|' thenContent=Copy(Temp,1,k-1) then:=true;:=SpisokPrint+Copy(Temp,k+1,Length(Temp)-k)+'|$';;:=Length(Temp);;(k);;:='';;(j);;not Logic then:=SpisokPrint+'|||';:=SpisokPrint+'&';:='';;(i);;:=SpisokPrint;;
//Выводим данные каталога в StringGrid
procedure PrintData(PrintStr,name:string; StringGrid1:TStringGrid);, j, k, n:integer;
//Смотрим:=1;:=PrintStr;:=1;:='';i 0) then Temp2:=Temp2+Temp3[k];(Temp3[k]='|') or (k=Length(Temp3)) then begin Logic:=true; inc(j); end;
(Logic) and (j mod 2 = 0) then(Temp1'') then:=Foreign+'foreign key ('+Temp1+') references '+Temp2+' ';:=false;;(Temp3[k]='|') and (j mod 2 = 0) then begin Temp1:=''; Temp2:=''; end;(k);;:=Temp4;.Cells[0,row]:=NameTable;.Cells[3,row]:=Primary;.Cells[4,row]:=Foreign;.RowCount:=row+1;
//Собираем поля:=false;:='';:=1;n'') then ColumnType:=ColumnType+' ('+Copy(Temp,1,k-1)+')';:=Copy(Temp,k+1,Length(Temp)-k);:=0;;j=3 then k:=Length(Temp);(k);;:='';.Cells[1,row]:=Column;.Cells[2,row]:=ColumnType;.RowCount:=row+1;(row);;
(n);;;not Logic then inc(row);
:='';;(i);;;printTables(StringGrid1:TStringGrid);i,j,n,count,rows:integer;:string;:=1; j:=1; n:=1; count:=0; rows:=0;:=FSpisokTables;i'|') and (i<=length(content)) do j:=j+1;StringGrid1.Cells[0,i]=copy(content,1,j-1) then:=count+1;;;.cells[1,i]:=inttostr(count);:=0;(Field);;;
PrintRelations(Memo1:Tmemo);i,n:integer;,NameTable2,primary1