Top Banner
Appendix A TURBO PROLOG PROGRAM LISTING There are three types of files in this software (i) Files with extensions ".dba" eii) Files with extensions ".txt" (iii) Files with extensions ".pro These file stores the databases generated during the dialog. system generates two types of files: ·;l (i) Database name .dba For each database des i gned by the'· system, the database name and the list of user views during the design session are stored in this file. eii) View_name .dba : For each user view and for the intermediate' as well as for the final integrated view, the databases for thel prolog representation of the EER model are stored in these files. Every time the system is used for designing a new database , these files already created should be stored in some backup medias for letter use, and should be deleted from the current di rectory.
104

SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

Jun 25, 2018

Download

Documents

truongthuan
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

Appendix A

TURBO PROLOG PROGRAM LISTING

There are three types of files in this software

(i) Files with extensions ".dba"

eii) Files with extensions ".txt"

(iii) Files with extensions ".pro

These file stores the databases generated during the dialog. The~

system generates two types of files: .~ ·;l

(i) Database name .dba For each database des i gned by the'·

system, the database name and the list of user views

during the design session are stored in this file.

eii) View_name .dba : For each user view and for the intermediate'

as well as for the final integrated view, the databases for thel

prolog representation of the EER model are stored in these

files.

Every time the system is used for designing a new

database , these files already created should be stored in some

backup medias for letter use, and should be deleted from the

current di rectory. _'_~txt ~-.fjJe~

Page 2: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

These files contains information such as examples,

introductions, etc. Which are to be displayed during the dialog.

There are txt files. These are

INSIGNIA.TXT OPEN_SCR.TXT SCREEN1 .TXT SCREEN2 .TXT SCREEN3 .TXT VIEW EG .TXT -ENT EG .TXT -ATT EG .TXT MULT EG .TXT -KEY EG .TXT BREL EG .TXT NREL EG .TXT -CARD_EG .TXT RATT EG .TXT -ROLE EG .TXT

The listing of these files is embedded in the listing of '.PRO'

files.

The files contains the TURBO PROLOG CODE.

There are .PRO files. They are listed below

UTILITY.PRO Contains utility predicates for list and set

operations, such as union, intersection, member, append,

length, etc.

SCREEN.PRO Contains predicates for performing standard screen

functions, such as display of lists, display of lists in

rowwise and columnwise, display a matrix, etc.

2

Page 3: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

VMIT.PRO Main program for the database design and menu

driven controls for the user interfaces.

VM.PRO Contalns predicates for obtaining and analysing

the user requirements to create user views. It includes other

files, such as :ENT.PRO, MULT.PRO, KEY. PRO, BREL.PRO, NRER.PRO,

CARD. PRO, PKEY.PRO, RATT.PRO.

EDIT.PRO Predicates in this file allow the user to modify

the user views.

VLPRO Master files for integrating user views to

produce a single global view. It contains files, such as

HC.PRO, SC.PRO, STA.PRO, DC.PRO, ROLEC.PRO, CARD. PRO, CARDC.PRO,

HYC.PRO, KEYC.PRO, and MERGE. PRO.

TRANS. PRO Predicates in this file implement the view

translation algorithm, to translate a view from the EER model

into the relational model.

STEPS FOR USING THE ~YSTEM

1 . Ensure that all '. PRO' and 'TXT' files are in the same directory.

2. Enter the TURBO PROLOG (Version 2.0) environment. 3. Load the f; 1 e VMIT.PRO, and Compile using memory option, and

then select the RUN option. 4. Run the program and select option -1 fro the main-menu to

create\add views. 5. Select option 2 to integrate views created so far. 6. Select option 3 to translate the view from EER model into the

relational model to produce the database schema. 7. Select option 4 to exit the system.

3

Page 4: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

1*************************************************************1 1* FILE: V"IT .PRO *1 1* *1 1* "ain Purpose: "ain program for the database design and *1 1* the menu driven controls for user interfaces. *1 1* *1 1* TOP LEVEL PREDICATE: v.it *1 1* */ 1*************************************************************/ code : 8000 include "vdo •. pro" include "utility.pro" include ~screen.pro" include "eer.pro" include "ent.pro" include "brel.pro" include "nrel.pro" include "card.pro" include "edit.pro" include "vI.pro" include "dbc.pro" predicates

go Vlit menu_ch(integer) lenu wait(integer)

Clauses go : -vlit. vlit :- clearwindow,lakewindo.(1,7,7,"" ,3,12,20,S2), file_str("open_scr.txt" ,A), .rite(A),nl,nl, .rite(" Press any key to continue .... "), readchar(_),clearwindow,file_str("scren1.txt" ,8), write(B),nl,write(" Press any key to continue .... "), readchar(_),clear.indow, file_str("scren2.txt" ,e), write(C),nl,nl, write(" Press any key to continue .... "), readchar(_),clearwindow, file_str("scren3.txt" ,0), write(O),nl, write(" Press any key to continue .... "), readchar(_),clearwindow, file_str("scren4.txt" ,E), write(E),nl, write(" Press any key to continue .... "), readchar(_),clearwindow, file_str("scren5.txt" ,F), write(F),nl, write(" Press any key to continue .... "), readchar(_),relovewindow,lenu. lenu:-Iakewindow(l,7,7, ""AIH7"ENU",S,S,20,6S), write(" ) Select your choice frol yhe following lenu :"),n1,nl,nl, write(" 1. Creat/Add views."),nl, write(" 2. Integrate VieNs"),nl, write(" 3. Translate View "),nl, write(" 4. Exit "),nl,nl, .rite(" ) Enter your choice :"),

Page 5: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

readint(I),relovewindow,lenu_ch(I). lenu_ch(l) :-lakewindow(1,7,7, "DIALOG" ,10,5,10,75), db_desn,shiftwindow(1), relovewindow,!. lenu_ch(2):- !. lenu_ch(3):- !. aenu_ch(4):- lakewindow(1,7,7,"' ,10,5,5,65), writer" The design session is cOlplete. '),nl, writer" Thank You'),wait(2000),!. lenu_ch(_) :-write(' Wrong choice. "),nl, writer" Enter-again: '),wait(2000),lenu. wait(O). wait(l) :-11 : I - 1,Nait(11).

goal go.

I*******iiii************.*.**************i************'**'***1 1* FILE: VDO".PRO *1 1* *1 1* "ain Purpose: Contains dotain and database declarations.*1 1* *1 1********************************************'***********'***1 DO"AINS list: sYlbol* strlist : string* DATABASE

vieN(string) ent(string,sYlbol) rel(string,sYlbol) key(string,sYlbol,list) att(string,sYlbol,list) edge(string,sYlbol,sYlbol,string,string) alt(string,sYlbol,list)

DATABASE-viewis viewlist(strlist) dbase(string)

DATABASE - intbase rONcol(integer,integer) sub(string,string) synonYI_ent(string,string) synonYI_rel(string,string) rel_att(string,sYlbol,list) attrib(sYlbol,sYlbol) liss_ent(sYlbol) .iss_rBl(sYlbol,sYlbol) lul_att(sYlbol,sYlbol) IIIU I_ent (sYlbol , sYlibol ) katt(sYlbol,sYlbol) role(sYlbol,sYlbol,string)

2

Page 6: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

f*************************************************************1 f* FILE: SCREEN.PRO *1 1* *1 1* "ain Purpose: Contains predicates for perforling standard *1 1* screen functions, such as: display lists in rONNise and *1 1* colulnNise, displaying latrices , etc. *1 1* *1 1* TOP LEVEL PREDICATE: display_list il 1* *1 1*************************************************************/ PREDICATES

Nriteline(integer) N rite 1 is t (1 is t)~ display_col(list) display_roN(list,integer,integer,integer) test_syn(string,string) forcol(integer,integer,integer,integer,integer) forroN(integerlintegerlintegerlinteger,integer) revise(integer,integer,integer,integer,string) wri teset(list) display_list(strlist,integer);display_list(list,integer)

clauses Nriteset([}) :-1. Nriteset([H}) :- Nrite('" IH, "'),1. Nriteset([X,YJ) :-'Nrite(,I'IX," and 1',Y,"'),l. writeset([H:T}) :- write('" IH," ,'), write(T),1. test_syn(X IX) :-!. test_syn(X , Y) :- synonYI_ent(X , V), !. test_syn(X,Y) :- synonYI_ent(Y,X), 1. forcol(_,C ,_,_,L2) :- C > L2, 1. forcol(_I_I_,COL ,_) :- COL> 80, I

forcol(R,C IRON,COL ,L2) '­cursor(RON,COL), readln(YN), upper_lower('y' ,YNf, assertz(roNcol(R,C)),!. forcol(R,C,RON ,COL,L2) :-Cl : Ctl, COLI: COLtlS, forcol(R,Cl,RON,COLI,L2),!. forroN(R,_,_,Ll,_):- R>Ll,!. forrow(_,RON,_,_,_):- RON >24,1. , forroN(R,RON,COL,Ll,L2) :-forcol(R,l,RON,COL,L2),RI : R t l,RONl : RON t2, forroN(Rl,RONl,COL,Ll ,L2). revise(Ll,L2,RON,COL, 'Y') :-retractall(roNcol(_,_)), forroN(l,RON ICOL,Ll ,L2),! . revise(_,_,_,_,_) :-1. Nriteline(O) :-!. writeline(L) :- Ll : L - l,nl , write('---------------------------------------'), write('-------------------'), writeline(LI), !. writelist([]) :-!. writelist([H]) :- write(H),!. Nritelist([H:T]) :- write(H), writer' I'), writelist(T). display_col([]) :- 1.

3

Page 7: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

displaY-COl\lH;I]):- IIrlte{ ,H},nI, IIrite('------------------'), display-col(T) . displaYJoII([],_,_,J:- !. display_roll([H:T],R,C,L) :- C> 80, Rl : R +1, display_roll([HiT],R1,C,L). display_row([H:T),R,C,L) :- Cl : C t L, cursor(R,C), IIrite(H),display_row(T,R,Cl,L),!. displayJist([],J :-!. display_list([H:L],I) II : I t l,Mrite(" ',I,') ',Hl,nl, display_list(L,Il).

/*uuuuuuuuuu*uu***uuuuuuu~uu*******/

/* FILJ : SCREHl. txt */

/* An efficient database design assures that *1 /* all the data requirelents of all the users *1 1* are stored Nithin the database and are *1 1* easily accessible. Thus 'a key cOlponent '1 1* of a database design systel is obtaining '1 1* frol the user a clear understanding of the *1 /* data requirelents. '1 j* '1 1****··*······················*·············*····*····***1

1*****'*'**"***"'*****"'****"****"**'*'*'**'***"I 1* FILE: OPEN_SCR. TXT *1

1* 1* 1*

I'

HELLO !

We are here to assist you to

design a relational schela

*1 *1 *1

*/

/* for yoor database. *1 1**··**·*··***···············*··*·····················./

1··*·······*········*····**·····**·******·**··*···**·** •••••• 1 1* FILE: UTILITY.PRO '1 I' ./ 1* Main Purpose: Contains utility predicatesfor list, set, ., 1* and string operators, such as: union, intrsection, ., 1* linus, append, length, chop strings etc. '1 1* ., 1* TOP LEVEL PREDICATE : lelber */ 1*****······**···*·**·········*·*··*··**······*·······* •• **.*/

douins llist : list.

PREDICATES lelber(sYlbol,list);lelber(string,strlist) idlelber(sYlbol) delete(sYlbol,list,list);delete(string,strlist,strlist)

4

Page 8: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

append(sYlbol,list,list);append(string,strlist,strlist) union(list,list,list); subset(list,list);subset(strlist,strlist) equal(list,list);equal(strlist,strlist) linus(list,list,list) rel(list,list,list,list) nth_elel(list,integer,sYlbol); nth_elel(strlist,integer,string) listlen(list,integer);listlen(strlist,integer) split(string;'tring,string) lastpart(string,string,string) chop_nale(sYlbol,sYlbol) splitlist(integer,list,list,list) getfile(string,string) ret_all one_card(sYlbol) least(llist,list) clauses least([],[]):-!. least((X),X) :-!. least([X,Y],X) :-listlen(X,Ll),listlen(Y,l2),ll < L2,!. least([X,Y],Y) ~-!. least([X:T],Z) :-least(T,Y),least([X,Y],Z),!. one_card(R) :-edge(_,R,_,_,"I"),!. ret_all :-retractall(view(_)), retractall(ent(_,.)),retractall(rel(_,_)), 'retractall(att(_,.,_)),retractall(key(_,_,_)), retractall(alt(_,.,_)),retractall(edge(_,_,_,_,_)), retractall(rowcol(_,_)),retractall(sub(_,_)), retractall(synonYI_ent(_,_)),retractall(synonYI_rel(_,_)), retractall(rel_att(_,_,_)),retractall(attrib(_,.)), retractall(liss~ent(_)), retractall(liss_rel(_,_)),retractall(lul_att(.,_)), retractall(lul_ent(_,_)),retractall(katt(_,_)). getfile(V,F) :-str.len(V,l),L < 8,concat(V," .dba" ,F). getfile(V,F) :-frontstr(8,V,L,_),concat(l," .dba" ,F). idlelber(X):- lelber(X,["id" ,"no" ,"nul- ,"code", "nulber", "key", "nale", "type"]). splitlist(I,[H:T),[H),T} :-!. splitlist(I,[H:T),[H:X),ST) :- II : I - I, splitlist(I1,T,X,ST),!. listlen([],O):- !. listlen([H:T),L) :- listlen(T,L1), L : Ll + 1,!. lelber(X,[X:_]). lelber(X,[_:T]) :- lelber(X,T). de 1 e te (X, [X: T] , T) . delete(X,[Y:T],[Y:Z]) :- delete(X,T,I). append(H,X,[H:X]) :-!. union([],A,A) ;- !. union(A, [],A) :-!. union(X, [H:T],Z) :- lelber(H,X},union(X, T ,I),!. union(X, [H: TJ. [H:Z]) :- union(X, T ,l). eQual([],[]):- !. eQual([H:T],Y) :- lelber(H,Y), delete(H,Y,Yl), eQual(T, Yl).

5

Page 9: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

subset([],[]):-!. subset([H:T],Y) :- lelber(H,Y), subset(T,Y). I i nus ( [J. _, []) : -! . ainus(X, [LX) :- !. linus([H:T],X,Y) :- lelber(H,X), linus(T,X,Y),!. linus([H:T],X,[H;Vj) :- linus(T,X,Y),!. rel(X, [LX, []) :-!. rel([l,Y,[],Y)' :-!. rel([H:T],S2,S3,S4):­delete(H,S2,Tl),rel(T,Tl,S3,S4),! . rel( [H:T],S2, [H:S3],S4) :- rll.(T ,S2,S3,S4),!. nth_elel( [H:J ,l,H) :-!. nth_elel([_:T],N,X) :- Nl : N - 1, nth_elel(T,Nl,X),!. split(X_Y,··,Y) :- frontchar(XJ,'_',YI.!. split(X_Y,X,Y):-frontchar(X_Y,Ch,Rest), str_char(C,Ch),sp1it(Rest,l,Y),concat(C,I,X),! . lastpart(X,Y,Z) :- strJen(X,L), Ll : L - I, frontstr(Ll, X, Y,l),!. chop_nale(LA,LA) :- str Jen(LA,L),L < 15,!. chop_nale(lA,CA) :- clearwindoN, write(") Please provide a shorter nale of length "), write(" less than 15 for ;"),n1, write(" ·,LA),nl,write(") "), read1n(Nale), upper_Iower(Nale,CA),!.

fiii**iii****i***ii***i***iii*********i********i*******f f* FILE; SCREN2.txt *f

fi This syste. autolates the process of *f f* database design by using expert syste. */ f* techniques. */ f* The stages you will go throug are: *f f* 1. View "odelling *1 1* 2. View Integration *1 1* 3. View T ransla tion * I I**********i******i****************************i****i***1

Page 10: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

1*****'**""**"*"'*'********"******'**'*'****************/ /* FILE: OBC.PRO *1 1* '1 1* Main Purpose: Contains predicates for creatr~g user ./ /* views. */

1* TOP LEVEL PREOICATE : creat_db ./

1*'*'**""*"""*""'****'*""*'*'*-'--"'**"'*" ** •• ** •• / predicates

Clauses

db_desn ask_vws ask_vws1 ask_vlls2 creat_db(strlist) disp_vlIs chk_dupv(string)

disp_vws :-IIrite(" LIST OF VIEWS :"),nl, findal1(V,vie~(V),L), display_list(L,l),!. db_desn :-nl,nl, IIrite(" ) For what do you lIish to design a database ?"),nl, IIrite(" (If you need lore than one lIord to respond, then"),nl, IIrite(" connect the lIords with underscore characters.)"),nl, write(" ) "),readln(Hale), not(Hale: ""), upper_loller(Hale,H), assertz(dbase(H),viellls), lakellindoll(2,7,7, "Oefinition" ,0,0,5,50), lakellindow(5,7,7, "EXAMPLES" ,5,0,10,50), lakewindoll(4,7,7, "",0,50,15,30), lakellindow(3,7,7, "OIALOG",15,0,10,80), aSk_vws,viewlist(L),creat_db(L), shiftllindoll(2),relovellindow, shiftllindow(3),removellindow, shiftwindow(4),relov8windoll, getfile(N,F),save(F,viellls). db _desn. creat_db( (J). creat_db((X:V]) '. vc(X),creat_db(V). ask_vIIs :.

shiftwindoll(2),clearwindow, write("User view is a specification of the content"),nl, IIrite('of a database appropriate for a single task"),nl, IIrite("that sOle users perforl. '), shiftllindoll(5),clearllindoll, file_str("viell_eg. txt" ,A),lIrite(A), shiftwindoll(3),clearllindoll,dbase(O), upper_Ioller(OU,D),

Page 11: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

write(') Enter below the views for the database' ,OU),nl, write(') Entet one nale per line. ' ), write('When done, Press Return .... ' ),nl, ask_vwsl,! . ask_vws! :-shiftwindow(4),clearMindoN, disp_vMs,shiftwindow(3), write(' ) '),readln ( HU ),not(NU :"), upper_lower(HU,HL), chop_nale(NL,H) ,chk_dupv(H) ,ask_vws!. ask_vws! :- ask_vws2. ask_vws2 ;- clearwindow, write(') Are there any lore views (Y/N) ? a), readln(AHS) ,upper _lower('Y' ,ANS), write(') Enter one nale per line .• ), write('When done, Press Return ... : ),nl, ask_vwsl. ask_vws2 ;­findall(V,view(V),L),retractall(view(_)), assertz(viewlist(L),viewls),dbase(O), getfile(D,F),save(F,viewls). chk_dupv(V) :-view(V),write(' View nale already exists. '),nl, write(' Give another nale. '),nl,ask_vwsl. chk_dupv(V) :-assertz(view(V)).

/********************************************************/ /* FILE: SCREN3.TXT */ /* u~u*uu*uu*uu */ /* * View Hodelling * */ /* nnnuuuuuuu */

/* During this stage~ User inforlation */

/* requirelents are obtained interactively */ /* */ /* and are analyzed to creat indivisual */

/* user vieNs. */ /nuuuu*****uu**uuu*****uuuun*******uuu*/

8

Page 12: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

I***i********************************************************1 1* fILE : VM. PRO il

1* Main Purpose: Contains predicates for obtaining and il

1* analyzing user requirelents to creat user vie.s. *1

1* TOP LEVEL PREDICATE : vc *1

I*******************************i**********************ii;;***1 predicates

vc(string) editl(string) prille pkey(sYlibol)

clauses vc(V)· :-retractall(vie.(_)),retractall(ent(_,_)), rstractall(rel(_,_)),rstractall(att(_,_,_)), retractall(key(_,_,_)),retractall(alt(_,_,_)), retractall(edge(_,_,_,_,_)),retractall(attrib(_,_)), retractall(liss_ent(_)),retractall(katt(_,_)), retractall(liss_rel(_,_)),assertz(vie.(V)), exp _snt, ask_at t ,exp_1a ,exp_key, askjrel s, ask_n re 1s, ex_card, eXJela, make.indo.(18,7,7, "DISPLAY_VIEW' ,0,0,25,80), dispvie.(V),editl(V), shift.indo.(18),clearwindow, dispvie.(V),editl(V), prile,shiftwindow(18),clear.indo., dispvie.(V),shiftwindo.(18), relove.indo.,getfile(V,f), savel F). editl(V):-.rite(' > 00 you want to lodify this view (YIN) ? '), readln(Ans) ,upper _lo.er('Y' ,Ans), ed_vie.(V) . editlU. prile :-entL,E) , pkey( E), hi 1. prile. pkey(E) :­findall(A,alt(_,E,A),AL),not(AL:[)),least(Al,K), retract(alt(V,E,K)),retract(att(Y,E,L)), linus(L,K,ll),assertz(att(Y,E,Ll)), asse r tz (key (V, E, K) ) , ! . pkeyU.

9

Page 13: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

1****""****'******"'**""""""'*"**********'***** ••• **/ 1* FILE: ENT .PRO .. ./ /. "ain Purpose: To obtain entities, attributes, and keys ./

/. f rOI the user. */ I' ./ 1* */ /* TOP LEVEL PREDICATE :ask_entl */ /****************************uu*******uu*******u*********/

predicates

clauses

ask_entl ask_ent2 chk_dupe(string) ask_at tl ask_att2(sYlbol) ask_att3(sYlbol) chk_dae(sYlbol,sYlbol) chk_nulle(sYlbol) exp_ent exp_att ask_at t check_ea(sYlbol) \ att_ent(sYlbol,sylbol) ask_ea( sYlbol) cae(sYlbol,sYlbol,sYlbol) addat(sYlbol,sYlbol)

exp_ent :­shiftMindoM(2),clearMindoM, Mrite(O Entities are objects about Mhich you Mant'), nl, Mrite(' to store inforlation in or retrieve'),nl, Mrite(' inforlation frol a database. O), shiftMindow(S),clearwindoM, f i le_str (0 ent_eg. txt' ,A) ,Mrite(A) ,shi f tMi ndow( 3) , ask_entl. ask_entl :- clearwindow,view(V), Mrite(') Enter beloM the objects'), write(' of interest to you in • ,V),nl, write(') Enter one nal' per line. ' ), write('When done, Press Return .... ' l,n1, ask_ent2. ask_ent2 :-shiftwindow(4),c1earwindow, disp_ents,shiftwindow(3l, write(' ) '), read1n ( NU ), not(NU :"). upper_lower(NU,NL), chop _nale( Nt, N) , chk_dupe(N),ask_ent2,!. ask_ent2 :- clearwindow,. write(') Are there any lOre objects (Y/N) ? 0), readln(ANS), upper_loMer('y',ANS),

10

Page 14: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

Nrite(') Enter one na.e per line .• ), Mrite('When done, Press Return .... • ),nl, ask_ent2, ! . ask_ent2: -! . chk_dupe( E) :-entL.E), Nrite(' Entity nale already exists ").nl, Nrite(' Give another na.e. ·),nl. chk_dupe(L) :- check_ea(E). check_ea(E) :- split(E,X,Y), idlelber(Y) , Nrite(") ',E,' is an attribute nale. '),nl, att_ent(E,X). check_ea(E) :-vieN(V),assertz(ent(V,E)). att_ent(E,X) :- upper_loNer(XU,X), upper_loNer(EU,E),clearNindoN, Nrite(' ",EU,' is a property of the object' ,XU),nl, write(' So ',XU,' Nill be added as an entity instead of • ,EU),nl, write(' Do you Nant to give another nale for " XU" • ( Y / N) ? '), readln(AN), upper _loNer('Y' ,AN), write(' ) Enter the nale : '), readln(NU),not(NU:"), chop_nale(NU,N), view(V),assertz(ent(V,N)), assertz(attrib(N,E)),clearNindow, write(' > Enter other objects: '),nl, Nrite(' > Enter one na.e per line .• ), Nrite("When done, Press Return ....• ),nl. att_ent(E,X) ~-view(V),assertz(ent(V,x)), assertz(attrib(X,E)), Nrite(' > Enter other objects. Press Retu~n for nono ...• ·),I. exp_att :-shit tNi ndoN( 2), clearNindoN, write("Attributes are characterstics or properties'), nl,Nrite('ot objects that are used to describe it.·)~ shittNindow(5),clearwindow, file_str(·att_eg.txt· ,A), wri te(A),!. ask_att:-exp_att,ask_attl,!. ask_at tl :-ent(V,E), shit twi ndoN( 3), c1earllindoll, upper_loller(EU,E), Nrite(') Enter beloll the attributes of entity ·,EU).n1, IIrite(' Enter one attribute nale per lin •. '), write("When done, press return .... '),n1, ask_a tt2( E), fail. ask_at tl~l! .

Page 15: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

ask_att2(E) :­shiftwindow(4),clearwindow, disp_atts( E), shi f twindolf( 3), ni te(" ) ')' readln(AU), not(AU :"), upper_lower(AU,Al), chop_nale(Al,A), chk_dae(E,A) ,ask_att2(E),!. ask_att2(E):-ask_att3(E),!. ask_att3(E) :- clearwindow,upper_lower(EU,E), write(') Are there any lore attributes of entity' ,EU,' (V/N) ? '), readln(ANS), upper_lower('V' ,ANS), ask_att2(E), !. aSk_att3(E);- chk_nulle(E),!. chk_dae(E,A) :­att(_,E,l),lelber(All), write(' ) Duplicate attribute nales are not allowed. '),nl, write(' Enter again ·),nl. chkjae(E,A) :-attrib(E,A), write(' ) Duplicate attribute nales are not allowed. '),nl, write(' Enter again "),nl. chk_dae(E,A) ;­ent(_,A),upper_lower(AU,A), write(' ) • ,AU, • is an object. So this will not be added as an "),nl, write(" attribute of the entity ",E),nl, write(" > Vou shall be Isked to provide a relationship between the "),nl, write(" ) entities ", E " and" ,A, • later on. '),nl, assertz(liss_rel(E,A)), write(" > Enter other attributes.·),nl,!. chk_dae( E, A) ; -spli t( A I X, y) ,idlelber( V), upper_lower(X,Xl), not(E:Xl), cae(Xl ,E ,A),!. chk_dae(E,A) ;-assertz(attrib(E,A)),!. cae(X,E,A) ;-entL,X), upper _lower(AU,A), write(' ) ',AU, • is an attrib.te of the object ',X),nl, write(" So this will not be added as an attribute of the entity' ,E),nl, write(' ) You shall be asked to provide a relationship between the '),nl, write(" ) entities " E ," and • ,X, • later on!, ."),nl, assertz(liss_rel(EIX))laddat(A,X),

12

Page 16: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

~rite(O > Enter other attributes of O,E), ~rite( Press return for none.O),nl,!. cae(X,E,A) :-~rite(O > Do you ~ant to add ., X,· as an entity (V/N) : .), readln(N), upper_lo~er(OyO,N),view(Y),

assertz(ent(Y,x)),assertz(att(V,X,[A])), assertz(liss_rel(E,X)), write(· ) Enter other attributes of ",E,·. Press return for none.O),nl,!. cae(_,E,A) :-assertz(attrib(E,A)),!. chk_nulle(E) :-retract(att(V,E,Bl)), findall(A,attrib(E,A),Al), union(Al,Bl,Cl), assertz(att(V,E,Cl)),!. chk_nulle(E) :-keyL,E,J,!. chk_nulle(E) :-attrib(E,J, findall(A,a~trib(E,A),AL),view(V), assertz(att(V,E,Al)),!. chk_nulle(E) :-edge( _,E ,_, ·ISA 0, J,! . chk_nulle(E) :-concat(E, "_id",X), chop_nale(X,XN), view(V),upper_lower(XN,Xl), assertz(att(V,E,[XL])),!. ask_ea(E) :-eKp_att,shift~indON(3), clearllindON,~ upper_lONer(EU,E), !!rite(· ) Enter be10!! the attributes of entity " ,EU),n1, !!rite(· Enter one attribute nale per line. "), !!rite(·When done, press return .••. "),n1, ask_att2(E),! • addat(A,E) :-attL,E,L), lelber(A,L),! . addat(A,E) :-retract(att(V,E,L)), assertz(att(V,E,[A:L])),!. addat(A,E) :-vie!!(V), assertz(att(V,E,[A))),!.

predicates ask_Ia ask_Ial(sYlbol,list) ask_Ia3( sYlbol) ask_Ia4( sYlbol) eKp_Ia act_Ia(sYlbol ,sYlbol ,string) check_Ia(sYlbol,sYlbo1) cony _Iul

13

Page 17: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

clauses

conv_li(sYlbol) ent_Iul(sYlbol,sYlbol) check_crs check_Iul(sYlbol,sYlbol).

exp_Ia :-att(_,_,A), listlen(A.L).l >1. shiftMindow(S).clearwindow, file_str(",ult.txt" ,C). Mrite(C),shiftwindow(3). clearMindow, write(">. Now we Mant to know which of the attribute of an entity·),nl, write(· can take several values for each instance of the entity. ·),nl, write(" (see exalple) ·),nl,nl, write(") Press any key to continue ...• ·).nl, readchar (J , ask_Ii, ! . ask_II :-att(_,E,AL),ask_Ial(E,AL),fail. ask_la:- conv_lul,!. ask_la1(E,K):-list1en(K.l), l > 1, clearwindow, upper_lower(EU.E), Mrite(· > NOM for entity: ·),n1, write(" ·,EU.· ["), wd telist( K), write("]"),n1, write(" > Enter the attribute that has several values for each ·),nl, write(" instance of the entity ·,EU),nl, write(· > Enter one attribute per line. When done, Press Return •.•.• ), n1,shiftwindow(4),clearwindow. disp_la(E),shiftwindow(3), ask_1I3(E). !. ask_1i1 L. J . ask_1i3( E) :-wri te(" ) • ), readln(NU),not(NU:··),upper_10wer(NU,N), check_la(E,N).!. ask_1i3(E) :-ask_1I4(E),!. ask_Ia4(E):-nl,att(_,E,K),listlen(K,l), l > 1, write(· ) Is there any lore attribute (yIN) ? .), readln(ANS).upper_lower(·Y· ,ANS), ask_1I3(E),! . ask_u4U. check_crs :- cursor(R._),R < 7,!. check_crs :- cursor(S,O),nl,n1,cursor(S,O),!. check_Ia(E,N) :-lul_entL,H), cursor(R,_),str_len(H,L), 11 : L +3, R1 : R -I,

14

Page 18: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

cursor(Rl, L1), ~rite(' : This is already kRONn as a lultivalued attribute. '),nI, nI ,ask_1I4(E). check_Ia(E,H) :-att(_,E,NA), lelber(H,HA),l, checLluI (E,H). check_Ia(E,H):­cursor(RR,_),str_ien(N,L), Ll : L +3, Rl : RR -1,cursor(Rl,Ll), Mrite(" : Undeclared/Misspelled attribute. "),nl, aSk_1I4(E). check_Iul(E,A) :-lul_ent(_,X),eqiv~att(A,X), assertz(lul_att(X,A)), aSk_1I3( E) , 1 • check_IuI(E,A) :- assertz(lul_ent(E,A)), aSk_1I3( E) , 1 • conv_luI:- luI_ent(E,A),ent_IuI(E,A),faiI. conv_IUI:-! . conv_la(E) :-IU I_att( E, A), assertz( at trib( E, A)), f,il. cony _la(J:-!. ent_Iul(E,A) :­split(A,X,_),upper_IoMer(AU,X), clearMindoM,vieM(V),Mrite{" Entity: "), display_ent(E,V),nl, retract(att(Y,E,Al)), delete(A,AL,Bl),assertz(att(Y,E,8l)),!, Mrite(" ) ",AU, " Mill be converted to an entity. '),nI, Mrite(" Do you Mant to give another nale for', AU,": "),nl,Mrite(") ( Enter the Hale/ Press Return for Ho thange ) : "), readln(Ans),act_la(E,X,Ans),!. ent_IuI(E,A) :-upper_IoMer(AU,A), cIearMindoM,vieM(Y),Mrite(" Entity: "), displaLent(E,Y),nl,retract(att(V,E,Al)), delete(A,AL,BL),assertz(att(Y,E;8L)),!, Mrite(" ) ",AU, " Mill be converted to an .ntity. "),nl, Mrite(" Do you Mant to give another nale for', AU," : "),nl,Mrite(" ) ( Enter the Nale/ Press Return for No change) : "), readln(Ans), act_Ia(E,A,Ans),!. act_u(E,N, "") :-vieN(Y), assertz(ent(V,N)),assertz(liss_rel(E,H)), conv_la(H),ask_ea(H),!. act_Ia(E,X,NU):-vieM(V),upper_IoMer(HU,H), assertz(ent(V,N)),assertz(liss_fel(E,H)), cony _1a(N) ,ask_ea(N),!.

predicates disp_katts(sYlbol) askJeys ask_keysl(sYlbol) ask_keys2(sYlbol) ask_keys3(sylbol,list,list)

15

Page 19: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

clausas

up_Key check_exist(sYlbol) check_key(sYlbol,list) exist_att(sYlbol,sYlbol,list,list) weakent! explk

axp_key :- lakewindow(6,7,7, "",8,50,7,30), explk,ask_keys,shiftwindow(6),relov&window,!. explk:-shiftwindow(2),clearwindow, write(:The key of an entity il the list of attributes"),nl, write("that deterlina the viiues of all other·),nl,write(·attributes of the entity. "), shiftwindow(5),clearwindow, file_str("key_eg.txt·,K),write(K), shiftwindow(3),clearwindow, write(") In genral, there lay be lore than one key for an entity, and·),nl, write(· sOlatiles the key of another entity lay be required to deterline·),nl, write(· the values of all the attributes of the entity. ").nl,n1,n1,nl, write(· ) Press any key to continue ..•. ·), readchar(J,!. ask_keys :-ent(_,E),ask_keysl(E),fail. ask_keys :-weakents. ask_keysl(E) :-att(_,E,[]),l. ask_keysl(E) :-att(V,E,[X)),upper~ower(EU,E), upper_10wer(XU,X),shiftwindow(4),c1.arwindow, shiftwindow(3),c1earwindow, write(" ) Is the attribute·, XU, • a k9y of the entity" ,EU, • (yiN) ? "), read1n(Ans),upper_lower("Y" ,Ans), assertz(a1t(V,E,[X))),l. ask_keysl(E) :- upper_10wer(EU,E), att(~,E,K),c1aar.indow, IIrite(· ) Now for entity: ·),n1, .rite(" ",EU,· [·),write1ilt(K),write(·]"),n1, shiftwindow(4),c1earwindow, dispjktyS(E), shiftwindow(3), write (" ) Enter the attributes that forls the k~y. "), n1,write (" ) Enter one attribute per line. " ), write ("When done, Press Return .... " ),nl, ask_keys3(E,Keyl, [] ), check_key(E,Keyl); check_exist(E),! . ask_keysl(E):-l. check_exist(E) :-a1t(_,E,_), ask_keys2( E), ! . check_exist( E.) :- c1ear.indow, write(" ) There lust be at1east one key for: ",E ), nl, askJeysl( E ),!. '. ask_keys2(E) :-att(_,E,A),list1en(A;L),l )1, clearwindo.,upper_lower(EU,E),

16

Page 20: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

write(' ) Are there Iny lore keys for" , EU, ' (Y/N) ? '),readln(ANS),upper_lower('Y',ANS), write(' ) Enter the other keys. '),nl, ask_keysl(E),l. ask_keys2(_):-!. ask_keys3 ( E, KI, IN ) :­shiftwindow(6),clearwindow, disp_katts(E), shiftwindow(3), write(' > ') ,readIn ( NU ), not ( NU : " ),upper_lower(NU,N), exist_aH(E,N, IN ,OUT) ,askjeys3( E, KI,OUT ),!. ask_keys3(E,[],[]):-!. ask_keys3( E, KI, IN ) :-write(' )·Any lore attributes in the key (YIN)? ' ), readln ( ANS ), upper_lower ( 'y', ANS ), ask_keys3 ( E, KI, IN ),!. askjeys3 ( _, K, K ): -! . exist_att(E,N,IN,IN) :-lelber(N,IN), write(' Duplicate attribute nales are not allowed. '), nl,! . exist_att(E,N,IN,[N:IN]) :-att(_,E,K),lelber(N,K), assertz(katt(E,N)),!. exist_att(p,N,IN,[N:IN]) :­ent(_,N),assertz(katt(E,N)),!. exist_att(E,N,IN,[N:IN]) :­split(N,X,Y),idlelber(Y), entpart(X,E),assertz(katt(E,N)), addat(N,E),!. exist_att ( _ ,_, X, X) :-write(' Undeclared/ "isspelled attribute. ' ), nl, !. check_key(E,K) :-alt(_,E,K), writer ) This key is already known'. ' ),nl, !. check_key( r, []) : -.!. check_key(E,K):-view(V),assertz(alt(V,E,K)), retractall(katt(E,J)'! . weakents :-alt(V,EI,KI),.nt(V,E2),equal([E2],KI), retract(alt(V,El,KI)), assertz(edge(V,El,E2, 'ISA'," )),fail. weakents :-aIt(V,EI,Kl),.nt(V,E2),lelber(E2,Kl), d.l.t.(E2,Kl, K ),retract(alt(V, El, KI)), assertz(aIt(V, El, K ) ), assertz(edge(V,El, E2, '10', " )), fail. weakents . disp_katts(E) :-writ.(' ATTRIBUTES Of THE PRESENT'), nl,write(' KEY OF ENTITY: ',E),nl, findall(A,katt(E,A),Al),display_list(AL,l).

17

Page 21: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

lii*iiiiiiii*.****i***i* •••• i*****.********.****************i*1 Ii FILE: BREL.PRO *1 /* */ 1* "ain Purpose: To obtain binary relationships frOt the */ 1* user. *1 /* *1 1* */ 1* TOP LEVEL PREDICATE : ask_brel2 */ /* */ 1* */ /**********************.**************************************/

Predicates

Clauses

ask_brels ask_brell aSk_brel2 askjre13 conv_r(sYlbol,sYlbol) addrl(sYlbol,sYlbol,string,string) check_syntx2( stri'ng) dO_lbe(sYlbol,sYlbol,sYlbol,integer) chk_ebe(sYlbol,sYlbol,sYlbol) chk_dr2(sYlbol,sYlbol,sYlbol) c,onvJsa ask_role(sYlbol,sYlbol) iSlelber(sYlbol) check_accept(sYlbol,sYlbol,sYlbol)

aSk_brels:- , shiftMindoM(2),clearMindoM, Mrite(' Relationships art associations bltMeen"),nl, Mrite(' tMO or lOre entities."), shiftMindoM(S),clearMindoM, file_,tr(·brel_eg.txt· ,R),Mrite(R), shiftMindoM(3),clearMindoM, Mrite(') Here Me Mant to see the different"), Mrite(' types of associations 'that exist "),nl, Mrite(' betMeen pair of entities. '),nl,nl, Mrite(') Press any key to continue ..... "), readchar(J, ask_brell,conv_isa,!. askjrell :-clearNindoN, Nrite(' Enter the binary relationships betNeen '), Nrite(' entities in the fori of :'),nl, Mrite(' EntitY_l VERB_PHRASE Entity_2 . '),nl,

Page 22: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

~rite(' Enter one relationship per line. '),nl, ~rite(· Nhen done, Press Return .... '),n1, ask_bre12. ask)re12 :-shiftwindow(4),clearwindow, disp_rels,shiftwindow(3), ~rite(' > ') , readln(NU),nl, not(NU: "),upper_lower(NU,Nl), check_syntx2(Nl). ask_bre12 :- aSk_bre13. ask_bre13:-clearwindow, write(' > Are there any lore relationships (yIN) ? '), readln(ANS),upper_lower('Y' ,ANS), ask_brel2. ask_brel3. check_syntx2(X) :- frenttoken(X,EUl,RS), fronttoken(RS,RU,EU2), fronttoken(EU2,Y,_), concat(' ',Y,EU2), upper_lo~er(EUl,El), upperJower(Y ,E2), upper~lo~er(RU,R), chk_dr2(R,El,E2). check_syntx2(_) :-~rite('*********** wrong syntax **********'),n1, write('***********see'exalple •• *********'),nl, write(' Enter again :'),nl,ask_brel2. chk_dr2(R,El,E2) :-relC,R), ~rite(' ) Relationship nale already exists'),nl, write(' > Give another nale'),nl, ask_brel2 . chk_dr2(R,El,E2) :-chk_ebe(El,E2,R),ask_bre13. chk_ebe(E,E,R) :-ent(V, E), assertz(rel(V,R)), cony _r (R, E), clearMindow. chk_ebe(El,E2,R) :-ent(V,El), Bnt(V,E2),assertz(rel(V,R)), clear~indow,ask_role(R,El), ask_role(R,E2),!. chk_ebe(El,E2,R) :-ent(_,El),

chBck_accept(R,El,E2). chk_ebe(El,E2,R) :-ent(_,E2),check_accept(R,E2,El).

Page 23: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

chk_ebe(_,_,_) :-write(" Misspelled/Unknown entities are used "),nl, write(" Enter the relationship again "),nl, ask)re13.

check_accept(R,E1,E2) :-write(" Entity ~,E2," is Misspelled/UnknONn "),nl, write(" Which of the following actions you want to take :"),nl, write(" 1) Give another nale. "),nl, write(" 2) Retain this as an entity.") ,nl, write(" 3) Discard it. "),nl, write(" Enter your choice (1/2/3) "), readi nt(I), dO_Ibe(R,E1,E2,1). check_accept(_,_,_) :-!. dO_Ibe(R,E1,E2,1) :-view(V), write(" Give another nale for" ,E2, ": "), readln(Nale),not(Nale :""),upper_Iower(Nale,Nl), chop_nale(Nl,N), assertz(rel(V,R)), askJole(R, E1), ask_fole(R,N),!. dO_lbe(R,E1,E2,2) :-view(V),assertz(rel(V,R)), assertz(liss_ent(E2)), askJole(R,E1), askJole(R,E2),! . dO_Ibe(_,_,_,_) • ask_role(R,E) :-view(V) , write(" Give the role of the .ntity ",E), write(" in the relationship : ",R),nl,nl, write(" ) Role: ·),readln(l),nl, assertz(edge(V,R,E,l, .")),!.

conv_isa:-rel(_,R), iSlelber(R),retract(edge(V,R,E1,_,_)), retract(edge(V,R,E2,_,_)), assertz(edge(V,E1,E2, "ISA" ,"")),fail,!. cony jsa. iSlelber( R) :-upper_lower(R,Rl), lelber(RL,r"is_a", "contains", "possess·)). convJ(R,E) :­shiftwindow(5),clearwindow, file_str("urel_eg.txt",T),write(T),

Page 24: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

shiftNindoN(3),clearNindoN, Nrite(' Give the roles of the entity ',~), Nrite(' in the relationship :' ,R),nl,nl, write(' > Rolel : '),readln(tl),nl, write(' > Ro1e2 : '),read1n(L2),nl, addr1(R,E,ll,l2),!. addr 1 (R, E;1, L) :-write(' The roles should be different; Enter again:' ),n1, convJ(R,E). addr1(R,E,L, "):- view(V), concat(L,E,El), chop_nale(El,N), assertz(edge(V,R,N,l, ")), assertz(ent(V,El)), assertz(edge(V,N,E, 'ISA', ")),!. addr1(R,E, ,. ,l):- view(V), concat(l,E,El), chop_nale(El,"), assertz(edge(V,R,H,l, ")), assertz(ent(Y,H)), assertz(edge(Y,H,E,'ISA' ,")),!. addrl(R,E,ll,l2):- view(Y), concat('_' ,E,X), concat(ll,X,EI), chop_nale(EI,Hl), assertz(edge(V,R,Hl,Ll,")), . assertz(ent(Y,Nl)), concat(l2,X,E2), chop_nale(E2,H2), assertz(edge(Y,R,H2,l2,")), assertz(ent(Y,H2)), assertz(edge(Y,N2,E, 'ISA', ")), assertz(edge(Y,Nl,E, 'ISA', ")),!.

Page 25: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

/*********************************************************;i*tl 1* FILE: NREL.PRO il 1* *1 1* "ain Purpose: To obtain n-ary relationships *1 1* frol the user. *1 1* *1 1* *1

. 1* TOP LEVEL PREDICATE: ask_nrels *1 1* *1 1* *1 1************************************************************tl PREDICATES

clauses

ask_nrels ask_nrell ask_nrel2 ask_nrel3 check_null(sYlbol) accept_ents(sYlbol) check_ent_duP(sYlbol,sYlbol) check_exist_ent(sYlbol,sYlbol) ask_nent3(sYlbol) check_dupr(sYlbol) dO_Iiss_nent(sYlbol,sYlbol,integer)

ask_nrels :-shiftwindow(5), file_str('nrel_eg.txt·,R),write(R), shiftwindow(3),cl.~rwindow, write(' Here we want to see the different"), .rite(" types of associations that exist "),n1, write(' along entities'),nl,nl, write(' Press any key to continue ...... ·), readchar(_),ask_nrell,!. ask_nrell :-clearwindow, write(') Enter the "_ary relationships alOng '), write(' entities in the following fori :'),n1, write(') First enter the nale of the relationship') write(' and then enter the list '),n1, write(' entities over which it is defined. '),nl, write(' Enter one relationship per line. "),nl, ask_nre12, !. ask_nre12 :-shiftwindow(4),clearwindow, disp_rels,shiftwindow(3),

Page 26: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

write(') Enter the Relationship nale : H), readln(RN),not(RN:"), upper_lower(RN,NL),chop_nale(HL,N), check_dupr(N),ask_nre12,! . ask_nre12 :- aSk_nre13,!. ask_nre13: -clearwindow, write(') Are there any lore relationships (Y/N) ? H), readln(ANS),upper _lower('Y' ,ANS), ask_nreI2. ask_nreI3: -! • ask_nent3(R) :-clearwindow, upper_Iower(RU,R), write(" Enter the entities for 'the relationship ',RU),nl, write(" Enter one entity per line. '), writer' When done, Press Return .... '),nl, accept_ents(R) . check_dupr(H) :-relL,Nl', write(" Relationship nale already exists'),nl, write(' Give another nale. '),nl,lsk_nreI2,!. _ check_dupr(R) :-view(V), assertz(rel(V,R)), ask_nent3(R) , check_null(R) . check_null(R) :- edgeL.R,_,_,J. check_null(R) :-retract(rel(_,R)). accept_ents(R) :- ~ write(" ) Entity: "),readln(EU), not(EU:'"),upper_lower(EU,E), check_ent_dup(E,R). accept_ents(R) :-write(') Is there any lore entity (Y/H) ? '), readln(ANS),upper _lower('Y' ,ANS), accept_ents(R) . accept_entsU. check_ent~dup(E,R) :- edge(_,R,E,_,_), write(' Duplicate entity nales are not all,wed'), write(' Enter again'),accept_ents(R). check_ent_dup(E,R):- check_exist_ent(E,R). check_exist_ent(E ,R) :-ent(V ,E), assertz(edge(V,R,E," ,")), accept_ents(R). check_exist_ent(E,R) :-write(" The entity ",E, ' is Undeclared/ "isspelled entity'),nl, write(" Nhich of the following actions

Page 27: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

you lIant to take :'),nl, Mrite(' 1) Give another nale. '),nl, Nrite(' 2) Retain this as an entity.·),nl, Mrite(' 3) Discard it.·),nl, Nrite(' Enter your choice (1/2/3) : '), readint(I}, dO_liiS_nent(R,E,I),accept_ents(R). dO_liss_nent(R,E,l):-viell(V), , IIrite(' Give another nale for' ,E, ': '), readln(Nale),not(Nale :"),upper_loller(Nale,Nl), chop_nale(Nl,N),assertz(edge(V,R,N," ,")). dO_liss_nent(R,E,2) :-vieN(V), assertz(edge(V,R,E,", ")), assertz (Iiss _ent (E)) . dO_Iiss_nent(_,_,_):-!.

predicates

clauses

eXJela ask_ral askra(sYlbol) ask_ratl(sYlbol) ch_dra(sYlbol,sYlbol) dra(sYlbol,sYlbol)

eXJela:-shi ftllindoll(2), clearllindoll, Mrite('Relationship attributes are properties'),nl, IIrite('of relationsftips used to describe it.'), shiftllindoll(S),clearllindoll, file_str('rel_att.txt',A), IIrite(A), shi ftlli ndoll( 3}, askJal,! . ask_ral :­rel(V,R},not(one_card(R)), askra(R},fail. askJal :-!. askra(R) :-clearllindoll, upper_lolllr(RU,R), Nrite(' > NOli for the relationship " RU, 'enter attributes if any'),nl, ~rite(' Enter one attribute nale per line. When done, press return .... ·), nl,ask_ratl(R),!. ask~ratl(R) :-shiftwindow(4),clearwindow, disp_atts(R),shiftwindow(3), Nrite(" > '),readln(AU),not(AU :"),

Page 28: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

upper_lower(AU,Al),chop_nale(Al,A), ch_dra(R,A),ask_ratl(R). ask_ratl(R) :- clearwindow, writer> Are there any lore attributes of relationship ·,R,· (Y/N) ? 0), readln(ANS),upper _lower("Y',ANS), shiftllindow(4),clearwindow,disp_atts(R),shiftwindow(3), write(" Enter one attribute nale per line. 0), write("lIhen done, press return .... "),nl, askJatl(R),!. ~ ask_ratl(R) :-retract(att(V,R,Bl)), findall(A,attrib(R,A),Al), union(Al,Bl,Cl),assertz(att(V,R,Cl)), retractall(attrib(R,_)),!. ask_ratl(R) :- findall(A,attrib(R,A),AL),view(V), retractall(attrib(R,_)),assertz(att(V,R,Al)),!. ch_dra(R,A) :-attrib(R,A), dra(R,A),! . chjra(R,A) :­att(_,R,Al),lelber(A,Al),dra(R,A),!. ch_dra(R,A) :-assertz(attrib(R,A)),!. dra(R,A) :- \' write(" ) Duplicate attribute nales are not allowed. "), nl,write(" Enter again. "),nl, askJatl (R), ! .

/**********.**************************************************/ /* FILE : DERR. PRO */ /* */ /* "ain Purpose: TO identify design errors such IS lisling */ /* entities, relationships, synonYls,conflicting hierarchi- */ /* cal links, and rectitytng thel. */ /* */ /* TOP LEVEL PREDICATE : deterr */ /* */ /* */ /*************************************************************/ PREDICATES .

CLAUSES

deterr testrol(sYlbol,sYlbol,sylbol) askrol(sYlbol,sYlbol,sYlbol) repalrl reprl(sYlbol,sYlbol,string) roles

deterr:-view(V),hc2(V,V), synJel(V,V), rhc(V,V), lakewindoll(19,3,23, "DIAlOS",O,O,25,80), roles, relovewindow,!. roles :-edge(_,Rl,E,l,_),edge(_,R2,E,l,_),

25

Page 29: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

not(Rl:R2),tlstrol(E,Rl,R2),fail. rolls:- repalrl,!. testrol(E,Rl,R2) :-edge(_,Rl,El,_,_),not(E:El), edge(_,R2,El,_,_),askrol(E,Rl,R2),!. testrolL._,J. askrol(E ,Rl ,R2) :­view(V),nl,display_rel(V,Rl),nl, display_rel(V,R2),nl,nl, write(" ) Sive different roles for", E, • in these two relationships :'),nl, writer' ) Role for' ,E,' in ',Rl,' "),readln(Nl), not(Nl :"),upper _lower(Nl,ll),nl, writer' ) Role for ',E,' in. ',R2,' '),readln(N2), not(N2: "),upper ~lower(H2,l2),nl, assertz(role(Rl,E,Ll)), assertz(role(R2,E,l2)),!. askrol(E,Rl,R2) :-writer' > You should provide different and none e.pty roles for' ,E),nl, writer' > Enter again :'),nl, askrol(E,Rl,R2),! . repalrl:-retract(role(R,E,l)), reprl(R,E,L),fail. repaIrl:-!. reprl(R,E,L) :- retract(edge(V,R,E,_,C)), assertz(edge(V,R,E,l,C)), !.

/*************************************************************/ /* FILE: EDIT.PRO */ /* *1 1* "ain Purpose: TO allow yhe user to .odify the view. */ /* */ 1* */ /* *1 1* TOP LEVEL PREDICATE : ed_view *1 /* *f 1* */ /*************************************************************/

PREDICATES disPJa5 Id_view( s tri ng) ed_lenu ed_ch( integer) ent_el do_ent( integer) rel_el chkere(sYlbol) del_att(symbol,list) delat(symbol) renat(sYlbol) rena 1 (sYlLbol ,sYlbol ,sYlbol)

26

Page 30: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

renkl(sYlbol,sylbol,IYlbol) ren_att(sYlbol,list) dOJel (integer) renrl(list) delJel(sYlbol) cher _r(sYlbol)

clauses ed_yieN(V) :-

lakeNindoN(10,7,7, "EDIT-KENU" ,0,0,25,80), lakeNindoN(12,7,7~"" ,0,34,15,45), ed_Ienu, shiftNindoN(lO),reloveNindoN, shit tNi ndoN( 12) , reloveNindoll, ! .

ed_Ienu :-shiftNindoN(10),clearwindoN, Nrite (" > Select the appropriate options frol the folloNing "),nl, Nrite (" lenu to do the lodifications. "),nl,nl, Ntite(" 1. "odify Entitiies. "), nl, Nrite(" 2. "odify Relationships. "),nl, Nrite(" 3. Exit. "),nl,nl, Nrite(" > Select your choice: "), readint(I) , ed_ch( I),!.

ed_Ienu: - ! . ed_ch(1) :-

lakeNindoN(17,7,7, "DIALOG" ,15,0,10,80), lakeMindoN(11,7,7, "EOIT-ENTITIE5",0,0,15,80), ant_el, shiftNindoN(II), ralovaNindoN, shiftNindoN(17), reloyed ndoN , ad_.anu.

ed_ch(2) :-lakeNindoN(17,7,7, "OIALOG" ,15,0,10,80), lakaNindoN(11,7,7, "EDIT-RELATIONSHIps· ,0,0,15,80), rel_el, shif t.indoN( 11), reloveNindoN, shiftNindoN(17), rellOYeNindoN, ed_menu.

ed_ch(3) :-!.

ed_chU :­wri te(· Nri ter ed_lenu.

> Wrong Choice.... "), nl, Select Again :"),nl,

ent_em :­shiftNindoN(11),

27

Page 31: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

clearwindow, writer" ) Select the appropriate options frol the following '),nl, writer" lenu to do the lodifications. "),n1,nl, writer" 1. Add Entities. "),nl, writer" 2. Delete Entities. "),nl, writer' 3. Renale entities. "),nl, writer' 4. Add attribute to Entities. "),nl, writer" S. Delete Attributes frol Entities. '), nl,write(" 6. Renale attributes of entffies."), n1,write(" 7. Exit '),n1,n1, writer' ) Select Your Choice: '), readint(I), do_ent(I) .

do_ent(1) :­exp_ent, ent_el .

do_ent(2) :­shiftwindow(17),clearwindow,nl, IIri te(· ) Enter the ,nale of the entity you want to ~elete "), IIrite(" frol the above list: "),nl,nl, shiftllindoll(12),clearwindoll, disp_ents,shiftllindow(17), IIrit~(' ) ( Enter the nale/Press Return for none) "), readln(N),not(N :'"), upper_lower(N,NL), ehkere(NL),ent_el.

do_ent(2) :- ent_el. do_ent(3) :-shiftwindow(17),clearwindow,nl,

write(" ) Select the entity frol the above list w~;c~ ":, writer' you want to renale : '),nl,nl, shiftwindow(12),clearNindow, disp_ents,shiftwindow(17), Nrite(" ) ( Enter the name/Pres~ ~eturn for none) "), readln(Name), • not(Name : '"), uppe" _lower(~2me,~:, ent (v, N),,, I, writer" . E~ter t~e new name; H), :e', :;n(M), "-"("- ") , \'~. -I ~; .,

upper_lower(M,L), , ren_ent(V ,N,L) ,do_ei,t(3).

d03nt(3) :-cleanlindow, ent_elll. do_ent(4) ;-

exp_at~,

ent_eu.. do_ent(5) :-

shiftwindow(17), ent(_,E),

28 '

Page 32: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

delat(E), fail. do_ent(S) :­

clearNindoN, ent_ell.

do_ent(6) :­shiftNindolj(17), ent(_,E) , renat(E) ,fail.

do_ent(6) :­clearNindolj, ent_el.

do_ent(7) :-!. do_entU : -Ihi ftwindOtj( 17) ,c}earNindoN, nl-,

Nrite(" ) Nrong Choic •... ~ "),nl, write(" Select Again :"),nl, ent_el.

renat(E) :­att(_,E,(J),!.

renat(E) :-att(_,E,K), clearwindOlj,nl,upper_lower(EU,E), write(" ",EU," ("), writelist(K), write(T),nl, write(" ) Do, you want to renale attributes of ", EU ," (Y!H) ? "), readln(Ans), upper_lower("Y" ,Ans), ren_att(E,K),l. ~ renat(_) :-clearwindow,!. ren_att(E,[]) :-!. ren_att(E,[H:T]) :-cursor(3,O),nl,nl,nl,nl,cursor(l,O), upper_loNer(HU,H), write(" ) Renale the attribute" ,HU,· ? "),nl, write(" ) (Enter the new nale! Press Return for no change) : .), readln(AHS),not(AHS : ."), upper_lower(ANS,H),retract(att(V,E,AL)), delete(H,AL,Bl),!, assertz(att(V,E,(N:Bl))), renal(E,H,N),ren_att(E,T),l. ren_att(E,[_:T)) :- ren_att(E, T),!. renal(E,H,H) :-alt(_,E,K),lelber(H,K), renkl(E,H,H),fail. renal (E,H, N) :-kev(V,E,K),delete(H,K,Kl), assertz(key(V,E,[N:Kl])),!. renalC,_,J :-!. renkl(E,H,N) :-retract(alt(V,E,K)), delete(H,K,Kl), assertz(alt(V,E,(H:Kl])),!. delat(E) :-clearwindow,nl,upper_lower(EU,E),

29

Page 33: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

att(_,E,K),write(" ",EU," [OJ, writelist(K),write("]"),nl, write(" ) 00 you want to delete attribut.s frol ., EU ,. (YIN) ? "), readl n( Ans), upper _lower("Y" ,Ans), att(_,E,AL), del_att(E,AL),!. delatU ;-!. del_attL [J) ;"-!. del_a t t( E, [H: T]) ; -cursor( 4,0) ,nl ,nl ,nl ,cursor{-4 ,0) I upper _lower(HU,H), writer" ) Do you want to delete" ,HU," (yIN) : "), readln(Ans), not(Ans:""), upper_lower("Y" ,Ans), retract(att(V,E,AL)), delete(H,AL,BL), assertz(att(V,E,Bl)), deI_att(E, T),!. del_att(E,LPJ) ;-del_att(E,T),!. chkere(N) :-edge(_,R,N,_,_), writer" > The entity can not be deleted as it participates "), writer" in a relationship. "),nI,!. chkere(N) ;-edge(_I_,N, "ISA",_), writer" > The entity can not be deleted as it is a generic entity. "),nl,!. chkere(N) :-edge(_,_,N, "10",_), write(" > The entity can not be deleted as it is a Strong entity."),nl,!. chkere(N) ;-retract(ent(_,N)), retractalI(att(_,N,_)), retractall(alt(_,N,_)), retractall(key(_,N,_)),!. chkereU; -! .

reI_el ;-shiftwindow(11), clearwindow, nI, writer" > Select the appropriate options frol the following "),nl, write(" lenu to do the lodifications. "),nI,nl, write(" 1. Add Relationships. "),nl, write(" 2. Delete Relationships. "),nl, write(" 3. Renale Relationships. "),nl, write(" 4. Add attributes to Relationships "),nl, write(O S. Delete attributes frol Relationships. "), nI,write(" 6. Renale attributes of relationships. "), nl,write(" 7. Exit this Kenu. "),nl,nl, writer" ) Select Choice ; "), readint(I), do_rel(I),!. dOJel(1) .;-ask_brels,ask_nrels,

30

Page 34: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

ex_card, eXJela, rel_el,!. do_rel(2) :-lhiftMinda.{17),cliarMinda.,nl. Mrite(" ) Enter the nale of the relationship you Mant to delete "),nl, tHite(" frol the above list: "),01.01, shiftMindoM(12),clearMindoM. disp_rels,shiftMindoM(17). Mrite(" ) (Enier the nale/Presl Return for none) : "), readln(RN), .-riot(RN : " "). upper_loMer(RN.R), rel(_.R).cher_r(R), del_rel(R). rel_el, !. dOJel(2) :- . clearMindoM, rel_el,! . dOJel(3) :-shiftMindoM(17).clearMinda., findall(R,rel(_,R),RL), renrl(RL), . rel_el.! . dOJel(4) :-

. ex_rela. rel_el,l. do_rel(4):- clearMindoM.rel_el.l. dOJel(S) :-shiftMindow(17). relL,E). delat(E), fail. dOJel(5) :-clearwindoM. reI_". dOJel(6) :-shiftwindoM(17). relL.E). renat(E), fail. dOJel(6) ;-clearwindoM. rel_al. do_rel(7) :-shiftwindOM(17),clearMindoM,!. do_rel(_) :- shiftMinda.(17),clearMindow, Mrite(" > Wrong Choice ..•. "),nl. Mrite(" Select Again :").nl, reI_". disPJas :-.rite(" LIST OF ATTRIBUTES OF "),nl, .rite(" RELATIONSHIPS: ").n1.fail. disPJas :­rel(_.R).att(_,R,A).not(A:[)), Mrite(" ".R," [OJ, Mritelist(A),

31

Page 35: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

.Hite("]"), nl, fail. disPJas ;-!. renrl([J) :-!. renrl([HIT]) ;-upp8r _lower(HU,H),nl, writer' > Renal! the relationship' ,HU, '. ') ,nl ,nl, write( ' > (Enter the new nale/Press Return tor no change) readl n( ANS) , not(AHS : ~~),

upper _lower(AMS,H), ren_rel(V,H,N),! . renrl(UT]):- renrl(T),!. cher J(R) :-edge(_,R,E,_,_), edge(_,Rl,E,_,_), not(R:Rl),! . del_rel(R) ;-retract(rel(V,R)), retractall(edge(_,R,_,_,_)), retractall(att(_,R,_)) ,!.

.,":

'J.

1**··*·········************··**·****·*******************.*** •••••• *.****./ /* VIEII INTEGRATION *t.

/. The ' phases through which you will go through are; */

/* 1) Select Views; You will be asked to select two views */ /* frol a list of views for integration. */ /* 2) Conflict Resolution : */ /* In this stip various conflicts will b. identified */ /* and resolved. * I /* 3) "erging : The two conflict free views will be lerged into a '1 1* single view. */

1***'*'*'**"**'*'*******'*'**'***'*'*'*"***""'**"*"*""**"**'*"'1

32

Page 36: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

1*************************************************************1 1* FILE: VI.PRO *1 1* *1 1* Kain Purpose: Kain progral for integrating user views by *1 Ii identifying and resolving various conflicts and lerging *1 1* thel thel into a single global view to produce the conc-*/ Ii ptual schela of the required database. *1 1* */ 1* TOP LEVEL PREDICATt : vlit */ 1* .- */ 1*************************'***********************************/ include ·hc.pro· include ·sc.pro· include ·sta.pro· include "hyc.pro· include "rolee.pro· include ·carde.pro· include ·keyc.pro· include ·Ierge.pro· predicates

CLAUSES

vi vint(strlist) vil(string,string,string) vintr checksell(strlist,integer,integer) checkse12(strlist,integer,integer,int.ger) check_vn(string,string) getview(string,string,string)

checksell(L,I1,N) :-write(" first Vilw (1-· ,N,') : '), readint(I1),nl,I1 ( N t I,!. checksel1(L,Il,N) :-write(·) You should select a nUlber frol (1-",N, ·)"),nl, write(") Please s.lect the first view again. '),nl, checksel1(L,Il,N). checkse12(L,Il,I2,N) :- write(' Second Viaw (1-",N,") : "), readint(I2),nl,I2 ( N t 1, 11 () 12,!. checkse12(L,Il,I2,N) :-write(") The nUlber should be frol (1-· ,N, ")"), write(" and different frot ",11," ."),nl, writer") Please select the second view again."),nl, checkse12(L,Il,I2,N). vintr :-file_str("vintl.txt" ,A), wri telA) ,nl ,nI, write(" ) Press any key to continue ..... "), readcharU. getview(K, Y ,I) :-shi f twindow(1), clearwindow, write(" ) Give the nale of the integrated view: "), readln(N),check_vn(N,I).

33

Page 37: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

check_vn(N,N) :- str_len(N,L),L ( 15. check_vn(N,Z) :- frontstr(15,N,l,_). vi :- lakewindow(1,2,11, 'OIALOG' ,0,0,25,80), vintr, viewlist(F),vint(F),!. vi :- write(') No views are there for integration. '), write(') first create sOle views and then integrate thel:), relovewindow. vint([X)) :- ret:.all, getfile(X, F), consu It (f) , shiftwindow(I),clearwindow, dispview(X), relovewindow. vint(L):- laklwindow(6,2,11, 'SELECT VIEWS' ,0,0,25,80). retract(viewlist(_)),listlen(L,H),clearwindow, write(') Select any two views frol the'). write(' following list for integration: '),nl, display_list(L.l), checksell(L,Il,H). checkse12(L.Il.I2.H). nth_elel(L.Il.Vl). nth_elel(L.I2,V2), v i1 ( VI. V2 ,Z) , delete(Vl,L,Ll), delete(V2,Ll,L2), append(Z,L2,L3), assertz(viewlist(L3),viewls), vint(L3),! . vil(X,Y,Z) :-retractall(view(_)); retractall(ent(_,_)), retractall(rel(_,_)), retractall(att(_,_,_)), retractall(keY(_'_'_))i retractall(alt(_,_,_)), retractall(edge(_,_,_,_,_)), getfile(X,fl), getfile(Y,F2), consul t( Fl), consu It (F2), getview(X,Y,Z), hcl(X,Y),hc2(X,Y),syn_ent(X,Y), syn_rel(X,Y),syn_att(X,Y),dc(X,Y), card_conf(X,Y),roll~c(X,Y), hc(X,Y),sthc(X,Y),key_conf(X,Y),I.rge(X,Y), ren_view(X,Z) , getfile(l,f), retractall(att(_,_,[])), save(F), ! .

Page 38: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

liii.*iii*i*ii* •• *.* ••••• *****.* ••••••• *.* ••• ** ••••••• * ••••••• 1 I' FILE: He,PRO ./ Ii ./ I' "ain Purpose: To identify and resolve hOlonYI conflicts .• , I' */ I' ./ I' TOP LEVEL PREDICATE : hcl *f I' *1 I···**i*.** •• * •• * ••••••••••••• ** •••••• i ••••• * ••• * •••••• * •• ****/

PREDICATES

CLAUSES

hcl(string,string) hcll(sYlbol,string,string) act(sYlbol,string,string,integlr)' ask_ent(sYlbol,sYlbol,string,string) .

hcl(Sl,S2) :­ent(Sl,X),ent(S2,X), hcl1(X,Sl,S2),fail. hcl(_,J :-

ask ... ent(X, Y ,Sl ,S2 h­upper_loMer(XU,X), upper_loMer(YU,Y), shi fhindoM(2). clearMindoM, display_ent(X,Sl),nl. shiftMindoll(l) , clearllindoM, display_ent(Y,S2),nl, shifhindoll(4). clearllindoll, Mrite(') Nhich of the follolling relationship holds for these entities '), nl, Mrite(" of the tllO vieMs :'),nl, Mri te(" 1) The enti ties arB exact! y sale in both the viells, ')' nl, Mrite(' 2) The entity" ,XU,' of I' ,Sl,"' is I su~set of the entity"),nl, IIrite(" ",YU,' of the ',S2,',"),n1, llrite(' l) The entity ·,YU,. of I' ,52," is a subset of the entity"),nl, Mritl(" ',XU," of the ',Sl,', "),nl, IIrite(' 4) Both the entities ", XU, " and' ,YU), IIrite(" have a cOllon dOlain,'), nl, IIrite(' 5) None of the above are true, "),nl,nl, IIrite(') Enter your choice (1-5) : "),!,

hcll(X,S1,S2) :­lakellindoM(2,7,7,SI,O,O,6,80), lakellindoll(l,7,7,S2,6,0,6,80), makellindoM(4,7,7, "DIALOG" ,12,0,13,80),

35

Page 39: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

ask_ent(X,X,Sl,S2), readint(Choice), act(X,Sl,S2,Choice), shiftMindoM(2),reIOVeMindoM, shiftMindoM(3),reIOVewindoM, shiftMindoM(4),relovewindow,!.

act(X,Sl,S2,1):-!. act(X,Sl,S2,2):­get~ent(Sl,X,NX1,ren_.nt(Sl,X,NX),asserta(sub(NX,X)),!. act(X,Sl,S2,3):­get_ent(S2,X,NX),ren_ent(S2,X,NX),asserta(Iub(NX,X)),!.

act(X,Sl,S2,4):-get_ent(Sl,X,XNl),ren_ent(Sl,X,XNl), get_ent(S2,X,XN2),ren_ent(S2,X,XN2), asserta(sub(XNl,X)), asserta(sub(XN2,X)),!.

act(X,Sl,S2,S):­get_ent(Sl,X,XNl),ren_ent(Sl,X,XN1), get_ent(S2,X,XH2),ren_ent(S2,X,XN2),!. act(_,_,_,_) :-!.

PREDICATES

CLAUSES

hc2(string,string) hc21(SYlbol,string,string) ask_rel(sYlbol,sYlbol,Itring,string)

hc2(Sl,S2):- rel(Sl,X),rel(S2,X), hc21(X,S1,S2),fail. hc2L,J :- !. ask_rel(X,Y,Sl,S2):- upper_lower(XU,X), shiftMindow(2),clearwindow, display_rel(Sl,X),~l,nl, shiftwindow(3),clearMindow, display_rel(S2,Y),nl,nl, shiftwindow(4),clearwindoN, write(") Is the leaning of the relationship ", XU),nl, write(" sale in both the views (YIN)?: "),!. hc21(X,S1,S2) :- lakewindo.(2,7,7,S1,O,O,6,80), lakeMindow(3,7,7,S2,6,O,6,80), lakewindow(4,7,7,"DIALOG" ,12,0,13,80), ask_rel(X,X,S1,S2),readln(Reply), upper_lower("N" ,Reply),ren_rel12(X,S1,S2), shiftMindow(2),relovewindoM, shiftwindow(3),relovewindow, shiftwindow(4),relovBwindow,!. hc21(_,_,J :- !.

Predicates

CLAUSES

hc3(string,string) hc31(sYlbol,string,string) hc311(sYlbol,string,string) hc32(sYlbol,string,string) ask31(sYlbol,string,string) ask32(sYlbol,string,string) check_renl(sYlbol,string,string,Itring,string)

36

Page 40: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

hc3(Sl,52):- ent(SI,E), rel(S2,E), hc31(E,SI,S2),fail. hc3(Sl,S2) :- rel(SI,R), ent(52,R), hc32(R,51,S2), fail. hc3(_,_) :-reloveMindoM,relovewindoM, reiovelii ndoM, ! . hc31(E,Sl,S2):- ask31(E,Sl,S2), readln(ReplY),upper_lower("H",Reply), hc3ll(E,Sl ,S2). hc31(_,_,J :- !. hc32(R,Sl,S2) :. ask32(R,51,S2), readln(ReplY),upper_lolier("N",Reply), hc311 (R, S2, SI) . hc32(_,_,_) :-!. hc3(R,Sl,S2) :-shiftliindoli(2),clearliindoli, lirite(" Schela : ",SI),nl, nl, display_ent(Sl,X),shiftMindoM(3), clearliindoM,lirite{" Schela : ",S2),nl, display_rel(S2,X),shiftliindoli(4), lirite(") Is the leaning and dolain of the EHTITV ",X), lirite("the sale as "),nl, lirite{" the leaning and the dOllin of the RELATIONSHIP ",X), lirite(" (yIN) ? : ",). hc311(X,Sl,S2) :- . write(") Renale the entity or the relationship,,"), liri te(" Heli nales should be different .. : .• "), nl, nl, lirite(") Do you liant to renale the entity '",x,"'"),nl, lirite(" in", 51, " (Y/H) ? "),readln(Rl),upper_lolier(RUl,Rl), renale_ent(X,Sl,RUl),nl, write(") Do you liant to renale the relationship '",X,"'"),nl, llrite(" in ", S2: (yIN) ? "), readln(R2),upper_lolier(RU2,R2), renale_rel(X,S2,RU21,check_renl(X,SI,S2,RUl,RU2),l. hC311L._,J :- l. check_renl(X,SI,S2,"H", "H") :- nl, lirite(") Please confirl whether the leaning and dOlain of the"),lirite("EHTITY ",X), Nrite(" the sale as the leaning and the dOlain of the RELATIONSHIP ",X),liriteC" (v/H) ? : "), readln(YN), upper_lolier("N",YH),nl,clearliindoli, lirite(") You should rena Ie at least the entity or the relationship"),nl,hc311(X,Sl,S2). check_renl(_ ,_,_,_,_). ask32(X,51,S2) :-shiftNindow(2),lirite(" Schela : ",SI),nl, nl, display_rel(Sl,X),shiftliindoll(3),lirite(" Schela : ",52),nl, display_entCS2,X),shiftliindoli(4), write(") Is the leaning and dOlain of the RELATIONSHIP" ,X), IIrite("the sale as "),nl, write(" the leaning and the dOlain of the ENTITY" ,X), Nrite(" (Y/H) ? ; "J.

37

Page 41: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

1**********U*********U*UU*U***U*UUUU**U*U****~U**1 1* FILE : SC .PRO . *1 1* *1 1* "ain Purpose: To identify and resolve synonYI conflicts. *1 1* *1 1* ·1 1* *1 1* TOP LEVEl PREDICATE :..5cl *1 1* *1 1* *1 1*********************·"*·"*******·*************************1 PREDICATES

CLAUSES

add_syn_ent(string,string) add_sub(string,string) syn_ent(string,string) add_syn(sYlbol,sYlbol,list,list) case_scl(sYlbol,sYlbol,string,slring) act_syn(sYlbol,sYlbol,string,string) dochoice(sYlbol,sYlbol,string,slring,integer) dosubchoice(sYlbol,sYlbol,string,string,integer)

syn_ent(Sl,S2) :-ent_set(Sl,El), ent_set(S2,E2), rel{El,E2,ESl,ES2), add_syn(Sl,S2,ESl,ES2),l. add_syn(Sl,S2,ESl,ES2) :-delete(X,ESl,ES3), lelber(Y,ES2),case_scl(X,Y,Sl,S2), test_syn(X,Y),delete(Y,ES2,ES4), add_syn(Sl,S2,ES3,ES4),!. add_synC,_,_,J :-!. case_scl(X,Y,Sl,S2) :- synonYI_ent(X,Y),!. case_scl(X,Y,Sl,S2) :-sub(X,Y),add_syn_ent(X,Y),!. casl_scl(X,Y,Sl,S2) :-sub(Y,X),add_syn_ent(X,Y),!. case_scl(X,Y,Sl,S2) :-sub(X, E), sub(Y, E) ,add_syn_ent(X, Y), 1 . case_scl(X,Y,Sl,S2) :- sub(X,E);edge(S2,Y,E,"is_a" ,_), act_syn(X,Y,Sl,S2),!. case_scl(X,Y,Sl,S2) :- sub(Y,E),edge(Sl,X,E, "is_a" ,_), act_syn(X,Y,Sl,S2),!. case_scl(El,E2,Sl,S2):­eqiv_key(El,E2,Sl,S2),act_syn(El,E2,Sl,S2),!. case_scl(El,E2,Sl,S2):- eqiv_nale(El,E2) ,act_syn(El,E2,Sl,S2),!. case_scl(El,E2,Sl,S2) :- not(synonYI_ent(El,_)), not(synonYI_ent(_,E2)), eqiv=rel(El,E2,Sl,S2),act_syn(El,E2,Sl,S2),!. act_syn(X, Y ,S1 ,S2) :­lakeNindow(2,7,7,Sl,O,O,6,BO), lakewindoN(3,7,7,S2,6,O,6,BO), lakewindoN(4,7,7,"DIALOG",12,O,13,BO), ask_ent(X,Y,Sl,S2), readint(Ch),

38

Page 42: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

dochoice(X,Y,Sl,S2,Ch}, shiftwindow(2},ralovawindow, shiftwindON(3},relovlwindow, shiftwindow(4},relovewindow,!. dochoice(X,Y,Sl,S2,l} :-clearwindol, write(") Renale both the entities as • IX, " or' ,Y,", "), nl,nl,write(" Which nale you lant to use? "},nl, writer" 1) ", X),nl, writer" 2)'",y),nl, writer" Entar your choice (1/2): "), readint(Choice), dosubchoice(X,Y,SI~S2,Choice),!. dochoice(X,Y,SI,S2,2) :- add_sub(X,Y), add_syn_ent(X,Y),!. dochoice(X,Y,SI,S2,3) :- add_sub(Y,X), add_syn_ent(X,Y),l. dochoice(X,Y,Sl,S2,.) :- sub(X,'E), a4d_sub(Y,E),!. dochoice(X,Y,Sl,12,.) :- sub(Y,E),add_sub(X,E),!. dochoice(X,Y,Sl,S2,.) :-clearwindow, split(X,Xs,Xe), write(") Is the entity'" ,Xe, " genlralization of both the entities"), nl,write(" ", X," and", Y, ' ?(Y/N) "),readln(YN), upper _lower("Y" ,YK), add_sub(X,Xe), add_sub(Y,Xe),n1,!. dochoice(X,Y,Sl,S2,4) :-write(") Give the nals of an entity which is a generalization of '), write("both the entities "),n1, write(" ", X," and ", Y, ' : "),n1, write(" It should be different frol the folloNing entities .••... "),n1, display_entset(SI),ni, display_entset(S2',nl, write(") 0), readln(Nale),add_sub(X,Nale), add_sub(Y,Nale), add_syn_ent(X,Nale), add_syn_ent(Y,Nale), add_syn_ent(X,Y),! . dochoice(X,Y,Sl,S2,5) :-!, dosubchoice(X,Y,SI,S2,1) :­ren_ent(S2,Y,X), add_syn_ent(X, y),!. dosubchoice(X,Y,Sl,S2,2) :­ren_ent(Sl,X,Y), add_syn_ent(X,Y),!. dosubchoice(X,Y,Sl,S2,Ch) :- Ch < 1, writer" The choice should be 1 or 2 only. '),n1, write(" Enter your choice again (1/2) :"), readint(Chl}, dosubchoice(X,Y,Sl,S2,Chl), !, dosubchoice(X,Y,Sl,S2,Ch} :- Ch ) 2, write'," The choice should be 1 or 2only."),nl, writer' Enter your choice again (1/2) :'), readint(Chl), dosubchoice(X,Y,Sl,S2,Chl), I

-addjyn_ent(X, Y) :- synonYI_ent(X, Y),!.

Page 43: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

add_syn_ent(X, Y) :- synonYI_ent(Y ,X), l. add.syn_ent(X,Y) :- asserta(synonYI_ent(X,Y),intbase), asserta(synonYI_ent(Y,X),intbase),l. add_sub(X,Y) :- sub(X,Y),!. add_sub(X,Y) :- asserta(sub(X,Y),intbase),!.

PREDICATES

CLAUSES

add_syn_rel(string,string) syn_rel(string,string) syn_2(sYlbol;sYlbol,list,list) caSe_sc2(SYlbol,sYlbol,string,ltring) act_synrel(sYlbol,sYlbol,string,string) do_relsyn(sYlbol,sYlbol,string,string,string) dosubch(sYlbol,sYlbol,string,string,integer) ask_relsyn(string,string,list,list) get_rs(list,list,string,string) rel_ren(string,string,sYlbol,sYlbol,string) repeat_relsyn(string,string,list,list,integer,integer)

syn_rel(SI,S2) :­lakewindow(12,7,7,··,O,O,17,20),

lakewindow(13,7,7, ·DIALOG",17,O,8,80), rel_set(SI,Rl), rel_set(S2,R2), rel(Rl,R2,RSl,RS2), syn_2(SI,S2,RSl,RS2), \ shiftwindow(12), relovewindow, shiftwindow(13), r ellovew i ndow, 1 • syn_2(SI,S2,(),RS2) :-!. syn_2(SI,S2,RSl,()) :-l. syn_2(SI,S2,RSl,RS2):-delete(X,RS1,RS3), delete(Y,RS2,RS4), case_sc2(X,Y,SI,S2),svn_2(SI,S2,RS3,RS4),!. syn_2(SI,S2,RSl,RS2) :-lakewindow(14,9,27, ·Rllationship_synonYI assertion",O,20,17,60), get_rs(RSl,RS2,Sl,S2), shiftKindow(14), reloveKindow,! .

case_sc2(X,Y,SI,S2) :- synonYI_rll(X,_),!. case_sc2(X, Y ,SI,S2) :- synonYIJel(_, Y),!. case_sc2(Rl,R2,Sl,S2) :­rel_ents(SI,Rl,ES1),rel_ents(S2,R2,ES2), eq_entset(ESl,ES2), act_synrel(Rl,R2,Sl,S2),!. case_sc2(Rl,R2,SI,S2):- eqiv_nale(Rl,R2) ,act_synrel(Rl,R2,Sl,S2),!. case _sc2 (R I, R2 ,S I, S2) : - !. act_synrel(X,Y,SI,S2) :-ask_rel(X,Y,Sl,S2), readln(Ch), upper _lower(UC,Ch), do_relsyn(X,Y,SI,S2,UC),!. do_relsyn(X,Y,SI,S2, .y") :-clearwindow,

40

Page 44: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

write(") Renale both the relationships as ",X, " or"), write(Y,". "),nl,nl, . write(" Which nale you want to use ? ")~nl, llrite(" I) ", X),nl, IIrite(" 2) ",Y),nl, IIrite(" Enter your choice (1/2): H), readint(Choice), dosubch(X,Y,SI,S2,Choice),! . do_relsyn(X,Y,SI,S2,_) :- !. dosubch(X,Y,SI,S2,1) :­ren_rel(S2,Y,X), add_syn_rel(X,Y),!. dosubch(X,Y,Sl,~2,2) :­ren_rel(SI,X,Y), add_synJel (X, Y),! . dosubch(X,Y,SI,S21Ch) :- Ch < I, IIrite(" The choice should be I or 2 only. "),nl, write(" Enter your choice again (1/2) ;"), readint(Chl), dosubch(X,Y,Sl,S2,Chl), !. dosubch(X,Y,SI,S2,Ch) :- Ch ) 2, write(" The choice should be I or 2 only. "),nl, IIrite(" Enter your choice again (1/2) ;"), readint(Chl), dosubch(X,Y,Sl,S2,Chl), !. add_syn_rel(X,Y) ;- synonYI_rel(X,Y),!. add_syn_rel(X,Y) :~

asserta(synonYI_rel(X,Y),intbase),!. get_rs([],_,_,_):-!. get_rs(_,(],_,_):-!. get_rs(RSI,RS2,Sl,S2):­listlen(RSI,ll),listlen(RS2,l2), repeat_relsyn(SI,S2,RSI,RS2,ll,l2). repeat_relsyn(SI,S2,RSl,RS2,ll,l2) ;- LI )4, L3 : II - 4,splitlist(4,RSI,RH,RT), repeat_relsyn(SI,S2,RH,RS2,.,L2), repeat_relsyn(Sl,St,RT,RS2,l3,l2), !. repeat_relsyn(Sl,S2,RSI,RS2,ll,l2) ;- l2 >4, l4 : L2 - 4, spiitlist(4,RS2,RH,RT), repeat_relsyn(Sl,S2,RSI,RH,ll,4), repeat_relsyn(Sl,S2,RSI,RT,ll,l4),! . repeat_relsyn(Sl,S2,RSI,RS2,ll,l2);­upper_loller(SUl,Sl), upper _10Iler(SU2,S2), shiftwindoll(12),clearllindoll, write("Relationships of"),nl, write(" Viell : "),nl, IIrite(SU2),nl, write("------------------"), display_col(RS2), shiftllindow(14),clearllindoll, write(" Relationships of View: ",SUI),nl, write("------------------------------------------------­---------"), nl,display_row(RSI,2,I,lS),nl,

41

Page 45: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

write("------------------------------------------------­---------"), writeline(L2), shiftwindow(13),clearwindow, write(") If the pair of relationships in the row and coluln "),nl, write(" are synonYls then enter (Y), otherwise enter (N):),nl, shiftwindow(14), retractall(rowcol(_,_)), forrow(1,4,3,L2,Ll),~ shiftwindow(13),nl,nl, write(" ) Do you want to revise again ?(Y/N) :"), readln(Again), upper _lower(AU,Again), shiftwindow(14), revise(L2,Ll,4,3,AU), ask_relsyn(Sl,S2,RSl,RS2). ask_relsyn(Sl,S2,RSl,RS2) :- rowcol(R,C),clearwindow, nth_elel(RSl,C,A),nth_elel(RS2,R,B), write(") Which of the following Relationship you want to use :"), nl, write(" 1) ",A),nl, write(" ~)" ,B),nl, write(" Please enter your choice (1/2) :"), readln(I), rel_ren(Sl,S2,A,B,I),fail,!. ask_relsyn(_,_,_,_) :-clearwindow,!. rel_ren(SI,S2,A,B, "I") :-ren_rel(S2,B,A),!. rel_ren(SI.S2.A.B. "2") :-ren rel(Sl.A.8). 1_

42

Page 46: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

1*************************************************************1 1* FILE : STA. PRO *1 1* *1 1* Main Purpose: To identify attribute_attribute, attribute_*1 1* entity type conflicts between pair of views and to *1 1* resolve thel. *1 1* *1 1* TOP LEVEL PREDICATE: card_conf *1 i* *1 1* */ Il*************************************~**********************1 predicates .

CLAUSES

add_attrel(string,string,sYlbol,sYlbol,sYlbol) str _entatt(string,string) add_rel_att(list,list) cOlp_entsl(list,list) cOlp_ents3(string,string) cOlp_attent(string,list,sYlbol,list) cOlp_relatt(string,string,sYlbol,list,sYlbol) add_rel(string,sYlbol,list) eqiv_entatt(string,sYlbol,sYlbol,sYlbol)

str _entatt(Sl,S2) :- ent_set(Sl,ESl),ent_set(S2,ES2), add_rel_att(ES1,ES2), findall(E,rel_att(Sl,E,_),ES3), findall(F,rel_att(S2,F,_),ES4), rel(ES3,ES4,X,Y),colp_entsl(ES3,Y), cOlp_entsl (Y ,ES3) ,COlP _entsl (ES4, X) , cOIP_entsl(X,ES4),retractall(rel_att(_,_,_)), cOlp_ents3(Sl,S2),colp_ents3(S2,Sl),!. cOlp_entslC,[]) :- !; cOlp_entsl(ES,[H:T]) :-rel_att(S,H,AL), cOlp_attent(S,AL,H,ES), cOlp_entsl(ES,T),!. cOlp_ents3(Sl,S2) :-rel(Sl,R}, att(Sl,R,L), delete(H,L, T), cOlp_relatt(Sl,S2,R,T,H), fail,! . cOlp_ents3(_,_) :-!. cOlp_attentL. [] ,_,J '- I

comp_attent(S,AL,E,[H:T]) '-test_syn(E,H}, cOlp_attent(S,AL,E,T),!. cOlp_attent(S,AL,E,[H:T]) eqi v _entatt(S;AL, E, H), cOlp_attent(S,AL,E, T},!. cOlp_relatt(Sl,S2,R,[],A):- ent(S2,E) eqiv_attent(A,E), retract(att(Sl,R,_)), copy_ent(S2,E,Sl),

43

Page 47: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

asserta(edge(Sl,R,E,·" ,"I")),!. cOIP_relatt(Sl,S2,R,Bl,A):- ent(S2,E), eqiv_nale(A,E), copy_ent(S2,E,Sl),retract(att(Sl,R,_)), asserta(att(Sl,R,Bl)), asserta(adge(Sl,R,E,·" ,"I")),!. cOIP_relatt(_._._._._) :-!. eqiv_entatt(S2,[A:l],E,H):-ent(Sl,H),not(Sl:S2), test_sqiv(Sl,S2,A,E,Hl,eqiv_antatt(S2,l,E,H),!. test_eqiv(Sl,S2,A,E,H):-eqiv_attent(A,H), add_attrel(Sl,S2,H,E,A). test_eqiv(Sl,S2,A,E,H):-key(S2,E,K), lelber(A,K), add_attrel(Sl,S2,El,E,A),! . add_attrel(Sl,S2,El,E2,A) :-att(Sl,El,AL), delete(A,Al,Bl), retract(att(Sl,El,_)), asserta(att(Sl,El,Bl)), addJell(Sl,S2,El,E2),!. \ add_attrel(Sl,S2,El,E2,A) :­retract(key(Sl,El,Al)), delete(A,Al,Bl), asserta(key(Sl,El,Bl)), add_re12(Sl,S2,El,E2,Bl),!. add_rel_att([],[]) :-!. add_rel_att([],[H:T]) :-att(S,H,Al), add_rel(S,H,Al), add_rel_att([],T),!. add_rel_att([H:T],(]) :-att(S,H,Al), add_rel( S ,H ,Al), addJel_att( [], T), l. add_rel_att([H:T],ES2):­delete(H,ES2,ES4),att(Sl,H,Al), att(S2,H1 Bl),not(Sl :S2),!, rel(Al,Bl,AS,BS),addJel(Sl,H,AS), add_rel(S2,H,BS),add_rel_att(T,ES4),l. add_rel_att([H:T],ES2):­delete(E,ES2,ES4),synonYI_ent(H,E), att(Sl,H.,Al),att(S2,E,Bl), rel(Al,BL,AS,BS),add_rel(Sl,H,AS), add_ram(S2,E,BS),add_rel_att(T,ES4),l.

add_rel(_,_,[]) :-!. addJel( S, E ,AS) :. assarta( rBl_att(S, E ,AS)),!.

44

Page 48: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

li"'*"********"**'*'***'***'*"'*********"***'********ii'il 1* FILE: HYC.PRO *1 1* */ Ii Main Purpose: To identify and resolve hierarchical */ 1* conflicts. *1 1* *1 1* */ 1* TOP LEVEL PREDICATE : rhe *1 1* *1 1* *1 I**********'*'*************!**********************************1 predicates

. rhc(string,string) ask_rhc(string,string,SYlbol,sYlbol) act_rhc(string,string,sYlbol,sYlbol,string) isa(sYlbol,sYlbol,string) testrhc(string,string,list,list) testeh(string,string,sYlbol,sYlbol)

clauses rhc(51,52) :­lakewindow(2,7,7,51,O,O,6,80), lakewindow(3,7,7,S2,6,O,6,80), lakewindow(4,7,7, ·DIA~OG",12,O,13,80), findall(E,edge(Sl,_,E, °ISA" ,_),EU), findall(F,edge(51,F,_, °ISAo ,_),EL), testrhc(Sl,S2,EU,EL), shiftwindow(2),relovlwindow, shiftwindow(3),relovlwindow, shiftwindow(4),relovewindow,l. testrhc(Sl,S2,EU,EL) :- lelber(E1,EL),lelber(E2,EU), testeh(S1,S2,El,E2),fail. testrhc(_,_,_,_) :-!. testeh(Sl,S2,El,E2) :~ isa(El,E2,Sl), isa(E2,El,S2), ask_rhc(Sl,52,El,E2),!. isa(E1,E2,S) :- edge(S,E1,E2,OISA",_),!. isa(E1,E2,5) :- edge(S,E1,E3, "ISA",_), i sa (E3, E2 ,S) , l . ask_thc(Sl,S2,El,E2):-shi ftwindow(2), c lea rwi ndow, display_ent(El,Sl), shiftwindow(3), clearwindow, display_ent(E2,S2), shi f hi ndow( 4 ) , clearwindow, nl, write(") Which of the following relationship holds for these two entities"), write(" (1/2) :.), cursor(R,C),nl,nl, write(" 1) • ,E1,· is a subset of the entity", E2, •. ·),nl, write(· 2) • ,E2,· is a subset of the entity·,

45

Page 49: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

El, '.'), nl,cursor(R,C),readln(Reply), act_rhc(Sl,S2,El,E2,Reply),!. act_rhc(Sl,S2,El,E2, '1'):­retract(edge(S2,E2,El,'ISA' ,_)), asserta(edge(S2,El,E2,'ISA', ")),!. act_rhc(SI,S2,El,E2, '1'):­edge(S2,E,El, 'ISA' ,_),isa(E2,E,S2), retract(edge(S2,E,El, 'ISA',_)), asserta(edge(S2,El,E2,'ISA', ")),!. act_rhc(SI,S2,El;E2, '2'):­retract(edge(SI,El,E2,'ISA' ,_)), asserta(edge(SI,E2,El, 'ISA', ")),!. act_rhc(SI,S2,El,E2,'I'):­edge(SI,E,E2,'ISA' ,_),isa(El,E,SI), retract(edge(Sl,E,E2, 'ISA' ,_)), asserta(edge(S2,E2,E1, 'ISA', ,oJ),!.

Predicates

clauses

reltype(sYlbol) sthc(string,string) testhc(string,string,sYlbol,sYlbol) testhcr(string,string,sYlbol,sYlbol,sYlbol) act_hc(string,stringisYlbol,sYlbol,sYlbol) ask_hc(string,string,sYlbol,sYlbol) . choicehc(string,string,sYlbol,sYlbol,sYlbol,string)

sthc(SI,S2) :-edge(Sl,E1,E2, 'ISA',_), not(edge(S2 ,E1,E2,'ISA' ,_)), testhc(Sl,S2,E1,E2),fail. sthc(Sl,S2) :-edge(S2,El,E2, 'ISA',_), not(edge(S2,E1,E2, 'ISA' ,_)), testhc(S2,Sl,E1,E2),fail. sthc(_,_) :- !. • testhc(Sl,S2,E1,E2) :­edge(S2,R,E1,_,_), edge(S2,R,E2,_,_), testhcr(Sl,S2,[1,E2,R),!. testhc(Sl,S2,£1,E2) :­lakewindow(2,7,7,Sl,0,0,6,80), lakewindow(3,7,7,S2,6,O,6,80), lakewindow(4,7,7, 'OIALOG' ,12,0,13,80), ask_hc(Sl,S2,E1,£2), shiftwindow(2),relovewindow, shiftwindow(3),relovewindow, shiftwindow(4),relovewindow,!.

testhcr(SI,S2,El,E2,R) :­lakewindow(2,7,7,Sl,O,O,6,80), lakewindow(3,7,7,S2,6,0,6,BO), lakewindow(4,7,7, 'OIALOG',12,O,13,80). rel_ents(S2,R,ES), eQual([£1,E2],ES), act_hc(Sl,S2,El,E2,R),

46

Page 50: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

shiftNindoN(2),reloveNindoN, shiftwindoN(3),reloveNindoN, shiftNindoN(4),reloveNindoN,!. testhcr(Sl,S2,El,E2,R) :­retract(edge(S2,R,El,_,_)), asserta(edge(S2,El,E2,'ISA', .')),!, act_hc(SI,S2,El,E2,R) :·reltype(R), retract(rel(S2,R)), retract(edge(S2,R,E2,_,_)), retract(edge(S2,R,El,_,_)), asserta(edge(S2,Er,E2,·ISA· , •• )),!. act_hc(Sl,S2,El,E2,R) :~rel_ents(S2,R,ES), upper_loNer(EIU,El), upper_loNer(RU,R), clearNindoN, shi f twindow( 2) , clearNindoN, display_ent(El,SI),nl,nl, NrHe(· ',51), shiftNindoN( 3), clearNindoN, writer· • ,RU, ·(·,El,·, ·,E2,· )'),nl, Nriter \ • ,S2) , shiftNindoN(4),clearwindow, write(·) Which of the following Inforlation do you like to keep·), n 1 , writer· within the Oatabase Application (1/2) :.), cursor(RoN,Col),nl,nl, writer· 1) The relationship • ,RU, 'between the entities ·),nl, writer" ·,El,· and ·,[2:·,·),nl,nl, Nri te(· 2) The .enti ty ., E1, • is a subset of the entity ·,E2,·:), . cursor(Row,Col),readln(Reply), choicehc(Sl,S2,El,E2,R,Reply),!.

choicehc(Sl,S2,El,E2,R, ·1') :. asserta(rel(SI,R)), edge(S2,R,El,ll,Cl), edge(S2,R,E2,l2,C2), asserta(edge(Sl,R,El,ll,C1)), asserta(edge(S2,R,E2,l2,C2)), retract(edge(SI,E1,E2,·ISA·,_)),!. choicehc(S1,S2,El,E2,R,'2') :- retract(rel(S2,R)), retract(edge(S2,R,El,_,_)), retract(edge(S2,R,E2,_,_)), asserta(edge(S2,El,E2,'ISA',")),! , choicehc(Sl,S2,El,E2,R,N):- . cursor(4 ,0), write(" ) It should be '1' or '2"),nl, II!rHer· ) Phase enter again (1/2) :.)' readln("),choicehc(S1,S2,El,E2,R,"),!.

askJc(SI ,S2, El ,E2) : -upper )ower( EIU, El),

47

Page 51: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

upper_Iower(E2U,E2), clearwindoN, shiftNindow(2), clearNindoN, display_ent(El,Sl),nl,nl, writer" ",Sl), shiftwindow(3), cleafldndow, display_.nt(E2,S2),nl,nl, write(" ",52), shit twindow( 4), clearwindoN, nl, write(") Is the entity" ,E1U," is a subset of the entity ",E2U ," (yIn) :"),. readln(YN), upper_Iower("N" ,VN), retract(edge(51,El,E2, "ISA" ,J),!. ask_hc(51,S2,El,E2):-asserta(edge(S2,El,E2, "ISA" ,")),!. reltype(contains). reltype(instance). reltype(colponent_of). reltype(possesses). \ reltype(have). reltype(has) • reI type( is_a). reltype(instance_of).

48

Page 52: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

/*************************************************************/ /* FILE : CARDC.PRO */ /* il /* Hain Purpose: To identify cardinility conflicts between */ 1* pair of relationships of two views ~nd to resolve them. *1 /* il /* il /* TOP LEVEL PREDICATE card.conf */ 1* */ /* *1 /**************************-**********************************/

Predicates

CLAUSES

testc( list ,list, list, list, integer) card_conf(string,string) check_card(string,string,sYlbol) act~card(string,5tring,sy.bol,string) ask_card(string,string,sYlbol,list,list,integer) diffcard(string,string) repcard(string,string,sYlbol,list,list,!tring) repcheck(string,string,sYlbol,list,list,integer,integer,string) ren_card(string,sYlbol,sYlbol,string,string) resol_rc(string,string,~Ylbol) findcs(integer,integer,strlist) setcard(string,sYlbol,list,strlist) inter(list,11st,list,list) subcard(string,sYlbol,list,strlist)

subcard(S,R,(],()) :-!. subcard(S,R,(E:T),[CIH)) :- edge(S,R,E,_,C), subcard(S,R,T,N),!. inter((l._,(],(]) :-1. interL;[],(].[]) :-!: inter([H:T),X,[H:V],(E2:Z)) '­;elber(E2,X),test_syn(H,E2), delete(E2,X,ESJ), inter(T,ESJ,V,Z),!. inter((H:T),X,Y,Z):- inter(T,X,Y,Z),!. card_conf(Sl,S2):- rel(Sl,R),rel(S2,R), check_card(Sl,S2,R), resol_rc(Sl,S2,R),fail. card_conf(_,J :- !. check_card(Sl,S2,R) '­edge(Sl,R,El,_,Cl), edge(S2,R,El,_,C2), diffcard(Cl,C2),!. check_card(Sl,S2,R) :­edge(Sl,R,El,_,Cl), edge(S2,R,E2,_,C2), test_syn(El,E2), diff~ard("l",C) :- C <> "I",!. diffcard(C, "I") :- C <> "I",!.

49

Page 53: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

reso1_rc(Sl,S2,R) :-shi ftllindow(8), clearwindow, display_re1(S1,R),n1, display_re1inf(S1,R),nl,nl, write(" • ,S1), shiftwindow(9), clearwindow, disp1ay_rel(S2,R),n1, display_relinf(S2,R),nl,nl, write(· • ,S2), shiftwindow(10),elearwindow, .rite(·) Is the leaning and dOiain of the relationships the sale (yIn)? .), cursor(Ro.,Col), Row1 : Ro. + 3, cu rsor( RO.1, 5), write(· The notation (1:1) stands for ONE-ONE·),n1, .rite(· The notation (1:N) stands for ONE-"ANY·), n1, .rite(" The notation (":N) stands for "ANY-"ANY·), cursor(Row,Col), read1n(YN), upper_Iower(RY,YN), act_card(Sl,S2,R,RY),!. act_card(S1,S2,R, .y.,) :­rel_ents(Sl,R,ES1),rel_ents(S2,R,ES2), inter(ES1,ES2,ES3,ES4), testc(ES1,ES2,ES3,ES4,K), ask_card(S1,S2,R,ES3,ES4,K),!. act_tard(S1,S2,R, ·M"):-c1ear.indow,ren_rel12(R,S1,S2),!. act_card(Sl,S2,R, "M") :- act_card(Sl,S2,R, "Y·),!. testc(ES1,ES2,ES1,ES2,1) :-!. testc(ES1,ES2,ES1,ES4,2) :-!. testc(ES1,ES2,ES3,E~2,3) :-!. ask_card(_,_,_,(],(],_) :-!. ask_card(S1,S2,R,ES1,ES2,1):-clearllindoll, subcard(S1,R,ES1,CS1),listlen(CS1,L), subcard(S2,R,ES2,CS2), IIrite(") Select a proper Relationship type (1-3): .), cursor(RolI,Col),nl, IIrite(" 1) "),writecard(CS1),nl, IIrite(· 2) .), IIritecard(CS2),nl, IIrite(" 3) None of the above. "), cursor(RolI,Col), readln(I),' repcard(S1,S2,R,ES1,ES2,I),!. ask_card(Sl,S2,R,ES1,ES2,2):-shi Ulli ndoll( 9), c lear.indOll, upper )ower(RU, R), write(" Relationship :",RU),.rite("( "), IIritelist(ES2),.rite(· )·),nl,n1, subcard(S2,R,ES2,CS2), write(" Relationship type is : ·),.ritecard(t~2), nl, nl, . write(" ",S2),

50

Page 54: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

shiftwindow(lO),clear.indow, subcard(Sl,R,ES1,CS1),listlen(CSl,l), write(') Select a proper Relationship type (1-3): "), cursor(Row,Col),nl, write(' 1) '),writecard(CS1),nl, write(' 2) "), writecard(CS2),nl, write(' 3) Hone of the above. "), cursor(Row,Col), readln(I), repcard(Sl,S2,R,ES~,ES2,I),!.

ask_card(SI,S2,R,ESl,ES2,l):-shiftwindow(8), clearwindow, upper _lower(RU,R), write(' Relationship ':',RU),write(" ( '), writelist(ESl),write(' )'), nl,nl, subcard(Sl,R,ESl,CSl), write(' Relationship type is : 'j,writecard(CSlj, nl, nl,' write(" ",51), shiftwindow(lO),clearwindow, subcard(S2,R,ES2,C52),listlen(CS2,l), write(') Select a proper Relationship type (l-l): "), cursor(Row,Col),nl, \ write(' 1) '),writecard(CSl),nl, write(" 2) '), writecard(CS2),nl, write(' 3) Hone of the abov •. '), cursor(Row,Col), readln(I), re~c~rd(SI,S2,R,ESl,ES2,I),!.

repca'rd(SI,S2,R,ES1,ES2, '1') :­subcard(SI,R,ES1,CS1), setc~rd(S2,R,ES2,CSl),:. repcard(SI,S2,R,ESl,ES2, "2') :­subcard(S2,R,ES2,CS2), setcard(Sl,R,ESl,CS2),!. repcard(Sl,52,R,ESl,ES2,"3') :- listlen(ES1,Lj,l : 3, write(") Select a proper Relationship type (1-8): "), cursor(Row,Col),nl,nl, write(" 1)'),findcs(l,l,CSl),writecard(CS1), write(' 2)'),findcs(l,2,CS2),writecard(CS2), write(" l)"),findcs(L,l,CS3),writecard(CSl), write(" 4)"),findcs(L,4,CS4j,writecard(CS4),nl,nl, writel' S)"),findcs(l,5,CSS),writecard(CS5), write(" 6)"),findcs(L,2,CS6),writecard(CS6), write(" 7)'),findcs(L,7,CS7),writecard(CS7), write(" 8)"),findcs(L,8,CS8),writecard(CS8), CUrsor(Row,Col), readln(H), repcheck(SI,S2,R,ESl,ES2,3,9,H),!.

repcard(Sl,S2,R,ESl,ES2, "3") :- clearwindow, write(") Select a proper Relationship type (1-4): "j, cursor(Row,Col),nl,nl, write(" 1)'),findcs(2,l,CSl),writecard(CSl), write(" 2)"),findcs(2,2,CS2),writecard(CS2),

51

Page 55: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

Mrite(" 3)"),findcs(2,3,CS3),Mritecard(CS3), Mrite(" 4)"),findcs(2,4,CS4),writ.card(CS4), cursor(RoM,Col), readln(H), repcheck(Sl,S2,R,ES1,ES2,2,5,N),!.

repcard(Sl,S2,R,ESl,ES2,f) :- cursor(4,1), Mrite(" > It should be 'I' or '2' or '3' "),nl, Mrite(" > Please enter again (1/2/3) :"), readln(A) i

repcard(Sl,S2,R,ESl,ES2,A),!. repcheck(Sl,S2,R,~l,ES2,L,I,N) :-str jnt(N,SN), SM > 0, SM < I, findcs(L,SH,CS), setcard(Sl,R,ES1,CS),setcard(S2,R,ES2,CS),!. repcheck(Sl,S2,R,ES1,ES2,L,I,H) :-nl,nl, 11:1-1, Mrite(" > It should be Mithin 1-" ,Il),nl,nl, Mrite(" > Please enter again (1-",11,"): "), readl n( J), repcheck(Sl,S2,R,ES1,ES2,l,I,J),!. setcard(S,R,_,[]) :-!. setcard(S,R,[E:F1 ,[Hn)) :- rltract(edge(S,R,E,L,J), assertz(edge(S,R,E,L,H)), setcard(S,R,F,T),!. ren_card(S,R,E,L,C) :-retract(edge(S,R,E,L,_)), assert~(edge(S,R,E,L,C)),!. findcs(L,l,["l", "I")) :- L < 3,!. findcs(L,2,["1" ,"N"]) :- L < 3,!. findcs(L,3,["H" ,"I"]) :- L < 3,!. findcs(L,4,[""","H")) :- L < 3,!. findcs(3,1,["1", "1", "~")). findcs(3,2,["1", "I" ,"H"]). findcs(3,3,["1", "H" ,"I"]). findcs(3,4,["1" ,""", "N")). findcs(3,5,[""", "1","1"]). findcs(3,6,[""", "I" ,"H"]). findcs(3,7,["M", "H" ,"I"]). findcs(3,8,["M", "H", "PO)).

52

Page 56: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

/*************************************************************/ /* fILE : ROlEC.PRO */ /* */ /* "ain Purpose: To identify role conflicts for entities */ /* participating in sale relationships and to resolve thel. */ /* */ /* */ /* TOP LEVEL PREDICATE: role_c */ /* */ /* */ /*************************************************************/ Predicates

ClAVSES

role_c(string,string)~ rca(string,string,sylbol,sYlbol,string,string) res_rc(string,string,sYlbol,sYlbol,string,string) ren_role(string,string,sYlbol,sYlbol,string,string,string)

role_c(Sl,S2) :­edge(Sl,R,E,ll,_), edge(S2,R,E,l2,_), not(Ll : l2), rca(Sl,S2,R,E,ll,l2),fail. role_cL,J :- !.

rca(Sl,S2,R,E,ll,l2) :-edge(Sl,R,E,l2,J,!. rca(Sl,S2,R,E,ll,l2) :-edge(S2,R,E,Ll,_),!. rca(Sl,S2,R,E,ll,L2) :-edge(Sl,R,Ejl3,_), not(LI : L3), res_rc(Sl,S2,R,E,Ll,l2),!. rca(SI,S2,R,E,LI,L2) :-edge(S2,R,E,l3,_), not(L2 : L3), res_rc(Sl,S2,R,E,Ll,L2),!.

rca(Sl,S2,R,E,ll,L2) :- edge(SI,RI,E,_,_), not(R : RI), resJc(5I,S2,R,E,Ll,l2),!. rca(SI,S2,R,E,l1,l2) :- ,edge(S2,RI,E,_,J, not(R : RI). res_rc(SI,S2,R,E,Ll,l2);!. rca(Sl,S2,R,E,Ll,l2) :- retract(edge(SI,R,E,lI,C)), asserta(edge(SI,R,E," ,C)), retract(edge(S2,R,E,L2,CI)), asserta(edge(S2,R,E," ,CI)),!. res_rc(SI,52,R,E,lI, •• ) :- retract(edge(S2,R,E, ",e)), asserta(edge(52,R,E,LI,C)),!. res_rc(SI,S2,R,E, ",l2) :- retract(edge(SI,R,E, ",e)), asserta(edge(SI,R,E,l2,C)),!. res_rc(SI,S2,R,E,ll,L2):- shiftwindow(S), clearwindow, display_rel(SI,R),nl, write(' Roll of ',E, • : " LI),nl,nl, write(' • ,51), shit twindow( 9), clearwindow, display_rel(S2,R),nl, write(' Roll of ',E, • : " L2),nl,nl, write(' • ,52), shiftwindoN(IO),clearwindow,

53

Page 57: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

Nrite(") Which of the folloNing Rolls you Nant to use for entity '",E, ",a), nl, Nrite(" in the relationship '", R, "' in both the vieNs ~ "),n1, Nrite(" 1) ., L1),nl, Nrite(" 2) ", L2),nl,nl, Nrite(") Please enter your choice (1/2) :"), readln(I), ren_role(Sl,S2,R,E~L1,L2,I),!,

ren_role(Sl,S2,R,E,L1,L2,·1"):­retract(edge(S2,R,E,L2,C)), asserta(edge(S2,R,E,L1,C)),!,

ren_role{Sl,S2,R,E,L1,L2, °2°):-retract{edge(Sl,R,E,L1,C)), asserta(edge(Sl,R,E,L2,C)),!, ren_role(Sl,S2,R,E,Ll,L2,CH) :-nl, Nrite(") The choice should be '1' or '2' ,O),nl, Nrite(o) Please enter your choice again :0), readln(NCH), ren_role(Sl,S2,R,E,ll;L2,HCH),!,

Page 58: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

f********"*""'*"*""***"""*'*"""""""'"""**"f I' FILE: DC. PRO *1 1* *1 1* Kain Purpose: To identify and resolve degree conflicts. ;f f* */ f· */ f. TOP LEVEL PREDICATE: dc */ f* */ f""""'****"""""""'*"*"****"'**'***'*""'***'*"f

predicates ~

clauses

de(string,string) dcl{string,string,list,list,sYlbol,string) ask_dc(string,string,sYlbol,sYlbol) res_de(string,string,sYlbol,list,list) check_dc(string,string,sYlbol,sYlbol,sYlbol) reI2(list,list,list,list)

dc(Sl,S2) :- rel(Sl,R), rel(S2,R), rel_ents(Sl,R,ESl), "rel_ents(S2,R,ES2),reI2(ESl,ES2,ES3,ES4), not(equal(ES3,[])),not(equal(ES4,[])), ask_rel(R,R,Sl,S2),readln(Reply),upper_lowar(RU,Reply), dcl(Sl,S2,ES3,ES4,R,RU),fail. de(_,J :-!. del(Sl,S2,ES3,ES4,R, My") :-res_dc(Sl,S2,R,ES3,EI4),!. dcl(Sl,S2,ES3,ES4,R, "N") :- clearwindow, ren_reli2(R,Sl,S2),!. dcl(Sl,S2,ES3,ES4,R, "H") :- dcl(Sl,S2,ES3,ES4,R, "Y"),!. res_dc(Sl,S2,R,[],[E]) :- ask_dc(Sl,S2,R,E),!. res_dc(Sl,S2,R,[E],[]) :- ask_dc(S2,Sl,R,E),!. res_dc(Sl,S2,R,[E],[Rll) :- rel(S2,Rl), check_dc(Sl,S2,R,E,Rl),!. res_de(Sl,S2,R,[Rl],[E)) :- rel(Sl,Rl), cheek_dc(S2,Sl,R,E,Rl),!. res_dc(Sl,S2,R,[E2,E3),[Rl]) :- rel(S2,Rl), edge(S2,Rl,E4,_,_),test_syn(E2,E4), edge(S2,Rl,E5,_,_),test_syn(E3,E5), retract(edge(S2,R,Rl,_,_)), edge(Sl,R,E2,ll,Cl),asserta(edge(S2,R,E4,Ll,Cl)), edge(Sl,R,E3,l2,C2),asserta(edge(S2,R,E5,L2,C2)),!. res_dc(Sl,S2,R,[Rl],[E2,E3]) :­res_dc(S2,Sl,R,[E2,E3],[Rl]),!. check_de(Sl,S2,R,E,Rl) :-retract(edge(S2,R,Rl,L,C)), edge(S2,Rl,X,_,_),test_syn(X,E), asserta(edge(S2,R,X,L,C)),!. ask_dc(Sl,S2,R,E) :- edge(S2,R,E,_, "I"),!. ask_dc(Sl,S2,R,E) :- rltract(.dge(S2,R,E,l,_)), asserta(edge(S2,R,E,L, "I")),!. reI2(X,[],X,[]) :-!. reI2([],Y,[),Y) :-!. reI2{[H:T),S2,S3,S4):­del_ent(H,S2,Tl),r'12(T,Tl,S3,S4),!. reI2([H:T),S2,[H:S3),S4) :- reI2(T,S2,S3,S4),!.

55

Page 59: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

/*************************************************************/ /* FILE : KEYC. PRO */ /* , */ /* Hain Purpose: To identify key conflicts between pair of */ /* equivalent entities of two views and to resolve thel. */ /* */ /* */ /* TOP LEVEL PREDICATE: key_conf */ /* */ /* .. */ /*************************************************************/

Predicates

CLAUSES

key_conf(string,string) testkey(string,string,sYlbol,sYlbol) keychoice(string,string,sYlbol,sYlbol,list,list,string) addalt(string,sYlbol,list,list) kc(string,string,list,list)

key_conf(Sl,S2) :- ent_set(Sl,ES1), ent _set( S2, ES2) ,kc( Sl,S2, ES1, ES2 r. kcL,_,[J.J :-!. kc(_,_,_,[]) :-!. kc(Sl,S2,[HIT],ES) :- delete(H,ES,EL), testkey(Sl,S2,H,H),kc(Sl,S2,T,EL),!. kc(Sl,S2,[H\T],ES) :- delete(E,ES,EL),test_syn(H,E), testkey(Sl,S2,H,E),kc(Sl,S2,T,EL),!. kcL_,_,J :-!. testkey(Sl,S2,El,E2) :- key(Sl,El,K), key(S2,E2,K), !. testkey(SI,S2,EI,E2) :~ ident(Sl,EI,K), ident(S2,E2,K),!. • testkey(SI,S2,EI,E2):- upper_Iow8r(EIU,El), upper_Iower(E2U,E2), clearwindow, shit twi ndow( 2) , clearwindow, display_ent(EI,Sl),nl, ident(Sl,El,Kl), write(" Key: "), writekey(Kl),nl, write(" ",51), shiftwindow(5), clearwindow, display_ent(E2,S2),nl, ident(S2,E2,K2), write(" Key: "), writekey(K2),nl, write(" ",S2), shi f hi ndow( 4). clearwindow, nl, write(") Select the key you want to use for both the entities (1/2):"),

56

Page 60: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

cursor(R,C),nl, write(" 1) .), writekey(Kl),nl, write(" 2) "), writekey(K2),nl, cursor(R,C),readln(Reply), keychoice(Sl,S2,El,E2,Kl,K2,Reply),!. keychoice(SI,S2,El,E2,Kl,K2, "I") :­retract(key(S2,E2,K)),asserta(key(S2,E2,Kl)), addal t(S2, E2, K, K1 y,! . keychoice(Sl,S2,El,E2,Kl,K2, "2") :­retract(key(Sl,El,K)),asserta(key(SI,El,K2)), addalt(SI,El,K,K2),!. keychoice(Sl,S2,El,E2,Kl,K2,S) :-cursor(4,O), write(" ) It should be 'I' or '2'"),n1, write(" ) Please enter again (1/2) :"), readln(A),keychoice(SI,S2,El,E2,Kl,K2,A),I. addalt(S,E,K,Kl) :- retract(att(S,E,AL)), union(AL,K,BL), linus(BL,Kl,CL), asserta(att(S,E,CL)), asserta(alt(S,E,K)),!; addalt(S,E,K,Kl) :- asserta(alt(S,E,K)),!.

57

Page 61: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

attos(Sl,El,Al),attos(S2,E,Bl), linus(Bl,Al,Cl),addatt(Sl,E,Cl), ident(S2,E,K), asserta(key(Sl,E,K)),!. add_ent(Sl,E,S2) :- Int(Sl,El),sub(£l,X),sub(E,X), asserta(edge(Sl,El,X, "ISA" ,"")), asserta(edge(Sl,£,X, "ISA", "")), asserta(ent(Sl,E)), asserta(ent(Sl,X)),attos(Sl,El,AL), attos(S2,£,Bl),rel(Al,Bl,Ol,El),linus(Al,OL,CL), asserta(att(Sl,X,Cl))~ addatt(Sl,El,Ol), addatt(Sl,E,El), ident(S2,E,K), asserta(key(Sl,E,K)), asserta(key(Sl,X,K)),!. add_ent(Sl,E,S2) :- copy_ent(S2,E,Sl),!. add_rel(Sl,R,S2) :- rel(Sl,R),!. add_rel(Sl,R,S2) :- asserta(rel(Sl,R)),!. add_edge(Sl,S2,R,E,l,C) :- edge(Sl,R,E,L,_),!. add_edge(Sl,S2,R,E,L,C) :- edge(Sl,R,£l,_,_), sub(El,£),retract(edge(Sl,R,El,_,_)), asserta(edge(Sl,R,E,L,C)),!. add_edge(Sl,S2,R,E,l,C) :- edge(Sl,R,El,_,_), sub(E,El),!. add_edge(Sl,S2,R,E,l,C) :- edge(Sl,R,El,_,_),sub(El,X), sub(£,X),retract(edge(Sl,R,El,_,_)), assBrta(edgB(Sl,R,X,l,C)),!. add_edge(Sl,S2,R,E,L,C) :-asserta(Bdge(Sl,R,E,l,C)),!. addatt(Sl,E,()) :-retract(att(Sl,E,_)),!. addatt(Sl,E,(]) :-!: addatt(Sl,E,CL):­retract(att(Sl,E,_)),asslrta(att(Sl,E,CL)),!. addatt(Sl,E,AL) :- asserta(att(Sl,E,AL)),!.

59

Page 62: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

1*******************************-*****************************1 1* fIlE: TRANS. PRO *1 1* *1 1* Rain Purpose: To translate a view frol eer schela into a *1 1* relational schela. *1 1* *1 1* TOP LEVEL PREDICATE: translate *1 1* *1 1*************************************·****************i*i·***1 PREDICATES

CLAUSES

writeJel write_id(string) testelpty(list) convn(string,sYlbol) translate(string) transes(string) transrs(string)

translate(S) :- trans.s(S),transrs(S). transes(S) :- ent(S,E), atts(S,E,T),ident(S,E,K),linus(T,K,L), asserta(ent_rel(E,K,L)),fail. transesU : -!. transrs(S) :- rel(S,R),convn(S,R), tot_att(S,R,T),ident(S,R,K),linus(T,K,L), asserta(rel_rel(R,K,L)),fail. transrs(J :-!. convn(S,R) :- edge(S,R,E,L,C), not(C : "1"), retract(edge(S,R,E,L,C)),asserta(edge(S,R,E,L,"N")),fail. convnL,J :-!. writeJel :-write(" RELATION SCNE"ES :"),nl, write(" (With keys shown in capital letters.)"),nl, write(" « Entity-Relations »"), nl, ent_re1(R,k,A),write(" ",R, "("),writek.y(k), testelpty(A),writelist(A),write(")"),nl,fail. write_reI :- nl,write(" « Relationship-Relations »"),nl, rel_re1(R,K,A),write(" ",R,"("),writekey(K), testelpty(A),writelist(A),write(")"),nl,fail. write_reI :-nl,readchar(_),!. write_ideS) :- clearwindow, write(" «( Inclusion Dependencies »>"),n1,nl, edge(S,El,E2, "ISA" ,_),ident(S,E2,K), write(" ",El,"( "),writekey(K), write(") ", "belongs to ",E2,"( a), writekey(K),write(" )"),nl,tail. write_ideS) :-rel(S,R),edge(',R,E,_,"N"), ident(S, E, K ),wri te(" " ,R, "( ") ,writekey(K), write(") ., "belongs to ",E,"( a), writekey(K),write(" )"),nl,fai1. writejd(J :-!. testelpty(()) :-!. testelpty(_) :- write(","),!.

60

Page 63: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

APPENDIX-B

Page 64: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

SC1(E£N .. 1

r'~-------" -·--~--·--··PFrl Jt1IlfARIES,·--,-,~~~,-----,~-"··---,-_v1

I ---------,------ I I HEUO ! I

I J

f I

design & relational schema

Presf.; anI.:' key tu t:mr!;'nue ..•.

\

I I I

I ~-..... ____ . .,. ... .>(.--.... --...-----.............. __ ........ _ .. _"" ______ .,~_ ... __ .f._~I0\, ...... ,. ... _ .... ~" ....... __ ......................... _

Page 65: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

q,C'RE.£f'i-!1 1,---,-,--"·-~,---"....pRElIMINfIR IES ----,-- '-~----"'II

I ---,--.-,~- .... -.--.~--,-~ ---------. f An eff i ci €lOt. database des r SCi

ali the data r'equirelilenh of all the user's

are stored Itithin the dah.base and are

easny acces~ible. Thus a I((~y component

ufa database design s'Jst~ro is obtain itl9

from the u{;er a cleaf' I.mdersh:fld ing a'r the

data requirements.

Press al19 key to coot i nue, ..•

, -.. -~-.---.-~-..,..------ f --............... _ .. _--_._ ... -.-_------_ ... ----;---!>" ..... _------_., ~

Page 66: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

SCREW-a ..... ~.--... _. "-" ------PRELlf1II'fARI£S--------·---,·,· , ....

techn i ques: .

Press any key t.o continue ....

I I

_~~~._. h,.. .• ' ..... _tooo""-"' .. _~_~ _____ if "Tr " .. ' _ _ -..-,, ___ , _____ _____

Page 67: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

SC.R£e.N- Lf

.-----------~PRELI111IiARl£S------,-----.

******************** * View f10dell ins * **********~~********

requiremeflt~ are ubtained interactively

and are analyzed to cr'eat ind ivisuC!i

IJser' vi ebJS •

Press am; key to cant i nile •..•

Page 68: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

SC'R..€(;.rJ~4r

-----, ---I--PRELIMHtfiRIES,-----------""l

1f;:**lIi~****'J!.(It,;l;:.*****''*'~'*!f: .\I( View Integration * *t*:f~***:t********.tI*)};***

In this stage an the usel~ views generated in

the previous st,a~e wi 11 be integrated into a

single global viet;: that wi 11 represent the

over'aU ~'Chema of the f'equ ired dah:base. The

global view is knoklfl as the Conceptual Schema

Pr'ess 009 key tCi cont inue •• , •

~----------------------------------~

--.-.-... ,--..... - ..... ---.... ---~-

Page 69: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

SC.'R€E..N - 6 r------'--.--.. ---·--ffiElli1ItfARIES,-----------.

, ..•. - .~.------.----------. J ' **********,n****lI:*:ti¥.U

It. 'View Translai hm *' *****1:*********)i::.t***:M:

Dur·ing this stage t.heconceptual schema

wi 11 be translated from E£R model ifrto a

Relational Schema of the requif'ed dat.abase.

'-__________ ~ ....... _ ?1 _ ... ll_

Page 70: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

~REU M1 liAR IES

~ ~ ~ -MAIN-MENU

} Select YOl.lrchoice from the following menu:

1. Creat/Add views. 2. Integrate fJlews 3. Translate Viet.) 4. Exit.

} Enter \lour' cho.i ce :1

Page 71: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

$C'J(cEN-8

i--------t'PP£Llt'lINAR![:,

r---~

I --, -,-----DlfiLOG.---·-..... ------·----n--.

J } For !;Jhat do you wish to design il dat.abase! (? (1 f Ij(iU need ffitlr'e than (me In(Wd ,to respond I t.hen (:r.:rmect the t,,(wds wHh underf.i:core characters.)

) TRANSPORT_SYSTEM

'-_____ P' __ .. _______ • _' __________ , ___ • ___ ~_~ ___ __

Page 72: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

t;,CR£EJ\l q

··---------[~ef ini t ion--·-"-'~·----·-·Jl·"----·~-------·l User Vtf:Hi.t is Il t~pedfi(;atiun of the canient .... lISTOf" VIEWS :. . t of a dal~base!l41r.WQpriah~ for- a ~ingle ta~tt 1) tt"ip_vielil

I that. }'-OIDe usef'~ p~dorm. 2) ~chedule;vie'~t L--___ ~_-__ . __ ~ _____ .__ 3) drivel'_flle

. --~---.. --£XAt1PlES.~.-,,--,----, 4) bus_ file BM'fHU1G H'lFORI1ATWN SYSTEfi I

Ule vieth'S might fne tude I ClfSt!Jt!l1er'~.y't;'iI! ! Br~m:~h viel,;.! I

, Tel h~I"';~vic::~ I

L~·-V'~_--1 r;-E;~:'b:i C~;;~-\~;i;';" f()~th~'d;t:~!~C~-;SPORT~SV~TEtt -----.. --... ---} [ntet" one n~.rtle per I1ne. l4heo dune, Press R~tu'·n ...•

> tr ip_viel.t! ,. Schedtll!!:_vle~

l \.>, DriverJlle 1 0"", t, ~ 1'" j WAll_! J ~~

,;

~--.---",----""",-",,---,,"'-~I( ;pq __ • ___ , .. .....--..-___ ~~ __ .... _ .. ~ ...

Page 73: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

,--------Definit ion,------___, ,-----------.... Enti ties are objects about hlh i ch you want to store information in or retrieve information from a database.

,..---------t ~:XAMPLES,------___, Airline-reservation

The entities might include: Fl ight Passenger Aircraft Person Ticket

LIST OF ENTITIES : 1) da iJ ~tr" ip 2) rQute_seg 3) cl ient 4) passenger

r------------DIALOG~-- ---------, > Ar"e ther"e any more objects ('y'/tH ? y > Enter one name per line. When dons, Press Return ....

> agenc:!:Lno

,-------Def inU lonr-------., ,-----------., Entities Bt'e objects about which yOU want to store information in or retrieve information from a database.

~------------------------~ .--------:EXANPLES----

Airl ine-reservation I·' The entities might include:

Fl ight Passenger Aircraft Person

LIST OF ENTiTIES : 1) dail,~t"rip 2) f'oute_seg 3) cl ient 4) passenger

Ticket I '------_-----.I 1 _______ -----'

,-------------------DIALOG,--""..--------------, AGENCY_NO is a property of the object AGENCY So AGENCY will be added as an ent. ity instead of AGENCY_NO Do you want to give another name for AGENCY (YIN) ? y

Page 74: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

sc.'RE.E:f'i -12-

De /'}· 't' .------,- T 1111 100--------. r------------, Attributes are characterst i cs or proped ies of objects that are used to describe it.

r-------tEXAMPLES--------. The attributes for the entiyies might include: Ent it.y AHri butes

fl ight Passenger Aircraft Person

Number,cit9-from,city-to Name,sttus ID,Type,make-passengers Name, Address, PhclOe

LIST or ATTRIBUTES OF : daily trip

1> trip_no 2) clep_city 3) arr_city 4) type

,..-------------D,IALOll· .... ·-----------...., ) Enter below the attributes of entity DAIlYTRIP

Enter one at t.r i bute name per Ii ne. fdhen done, pf'es:~ &; t'eturn •... > t.rip_Ro

> Do you klant to add trip as an .entity (YIN) : n > dep_tity ) arr _city > type >

Page 75: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

r"-"------Dei' ini ticn·~'----­AU,dbllites ar'e; chaf'acterstic~ ~r' p!~{!j)ertie:;: (ft obJect!.;' that art1 uiOeu to describe it.

j ..... \ . __ ,_ ...... _. __ , _____ - __ .. _. = ~"' ___ ...8

r-----.----.--.------LIST OF ATTRiBUTES Of : d$ilytrip

1) t.l"iP_M Z) dep_dt.y 3) arr_diy 4) type

r . ' .. " . ... ." EXAt1PLES··,·· --~:l' . .fi.The aHribt.'te$ fet,>. the aUii.Y.ies; ftiighi: include: .' , £ntH~ AHribute~ , 1--.. ___ -_.... ___ ..--__ ..... _.-1 __ ..., .... ______ .-_"""' ..... ___.

night Nmnber pc i 1,1.1.-tf'om, ci ty-i..o Pa~,r.tJ:nger Warne, sU.us Aircraft m, T';pe,make"'pas-seogers Person Hamt: 1 Mckess ,Phone

__ ..... _ .. __ .. c ••• ,.., .... _ .... __ ............ _........ ._ ......... ~"' ___ "--______ ._ .. i_-__________ .......

·---~·----·--D(ALOG--~-----,--~··--. > Are there anlJ mot'c attributes of entity DAILYTRIP (VIM) '? y

'" .> lrii'.~no ) Dup UCi:.h~ ~ttr ibute names l.!f'C not aIJcfwed.

Enter" again >

L_. ______ . _. ___ ... _, ....... ________ --"

Page 76: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

Sc.R.6..E..N- 14

~---.. ···-"'·'Q"Def inHion- ." '-' Attributes are diarad.er's'tit;s crt prfJpert ir.:s of IJbjeci$ that af'e used to descr ibe it.

'--._----_._-----

night Passengel~

Aircf'aH Pel~soll

Number J C i t.y-from, (; i t.g-to Harne, st. ·tlJl~ ID" Type,make-p;;ssengers Hame, Address, Phcfie

lIS.T Of ATTRIBUTES Of : t'out.e_seg

t) seS_flU 2) date 3) to l.a t seats 4) reserve_~e~.ts

_____ ~ ___ :Ijl! _w..~_ ... __ "", _____ ,, _____ _______ ". ______ .....

h £nt~': Ltlo~J the att~ib~t;s ofenti~!~~TE~SEG··-··· ... ~---'---l'

I f..n.ter o.ne at.tribute name per' Br..,e.When dOnf:!l. press rehJJ"fl"" > se9_no

} Do yo\! want h~ add seg as anent i t.y (Yili) ; n ) dat.e ) totatsea1.s ) r'eserve_se~.b )

____ , ___ ,-____ ...... _____ ;<....... I _. __ • _~_0jI,j_'_" __________ ....

Page 77: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

r.Aitri~tes~:!~!:::-er ~r.p~rt!.s llf LisT OrATTR!IlUTES

IOf f)~Jects thad, at'e used to descnbe i Lor; ageo(:!';! 1) a!)t'lflc:':IJIO

-. - .----.~ .' __ ---1 2) flO

--.---- , ---fXA!1PLES . 3) credit._limit STUDENT TABlf.

RollJit'i is 16

wur-se_ taken DBttS~AI,ICS PL,AI, CC

Heal" .each sludent can take a numher of cour.~!:$. So cOI..lf'se~_taken is a f1ulUvalut;d alklbute. --_ ..... '----~-.-~.--

,-----"---DIALOG-",-" --, , ) titrtttwe want to km)~t ~hith of t.he aUdbute of an entit!J

(;.:.111 t<tke ue\,'eral lJedues fol" each instance of the ent.it.':J. (see exalllp Ie )

J > Press any key tel can t i nue ••.•

L~ _______ , __ .~~.~ ___ .". __ . ___ . ___ _ . -----

Page 78: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

SC.£E.f"'- 16

[. Hear" each student. cantah .. a numbm' of c(lur~e~. ; "1 . St} c\.fUr ... e8J:af~en is s. f1uHivatued eUf'Hl'JJt~. . . 1. ;~:~ --....... - ... ,.,¥ -~--.-~ ... -.......-.~~",-.... -..,.-.---",-- .... -"""-~-~~-~''''.---- ...... ,.~ ;.~~~~ i~

r·-·----·..-....,..~-" -··---·-!)!rd...Q1;·-,,· ....... ---~··----· .. · ' .. ,~~

} Ho!;] 'fvf' ent i lIJ : • DAIlYTRIP Uri.Ullhdep_.dt'::Jtat"r_c:H!J1t~peJ .. ,. I:,: > tute:' the ath-Um'ie Und; hat $~M~f'td ",ahHt~ ~Ot~ each .. : ~ I (nstanc* of the enHtq DA1LYTRll' ,-'

l,En:= __ .\.:r.iW:in~:=:R.t~~ __ J;

Page 79: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

r;;:::-f.~:7~·:::~::-I' o::"-bta'-::I~~:''';~~:I~ I ~:ll:~~:::~-·f·:··::::-. '::.:'J-;w~·:.--::~:-·-··----·-----l

lr ;,1'. ~':l""" U f.J.*1J1 ,,,'H,,.. ..... ft~\~:::e :f./;.it 1hlJ1·". ~~~'ttAIii. ,., .. ~~ 1\·.,t~1 I~'l ~'l 1 .. ,~'t; .1.lI"~i! o:..u.u i

""tJll."f·t. !"iC.<· ·i/-i. ~.'!l!}-f J~llllth'"'' el~.I·I' H'~ IW't.l b/, !'f'(lul"ed lU ,11.>I!r'>'''liflf' I ..-" • ..., ·"~· ...... i· 1>' t .. .l' • .... ~7' _'\;oj ~ 10,..' ~ ... ~:, '14" .. , /iO-- \":~', 'i' IV e</-", ... l. olt ' f.., I 11.;" 'iall'''''''' (.1' J>ll ~I"" ,,' t.,:L .. ~ ........ j' ·H·.~, <'i'~ :.\, ' I (.,k" ."' ... '" .·1 Mi , .• \;1 .... ,., .!J .... ,.~." I)T ,,, .... k ,\,. ,.). 'j!

I } P,'os. any .'0' to cwl 'n"." " I t,.~_ .. _,~ __ ~._~ __ ... ~,. __ ~ __ . ___ . ___ ._ .. _ .. __ .. _ ... __ .. _. __ ..... __ .. _ .. ____ ._, .. ___ ._ .. 1

Page 80: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

.... --. ".".~. ' ...... ~--'--.-.• Df.f in i i l on------~.-~-~--]-.. r-'--. -'-~-~"-'.~--'--.-Th~ k~1J of em tlutHy it Hie list t)f (tUdbutes LIST (IF KEYS OF 'i.het deter':'flane U~fJ \t~lues. of all ~ther nnn'i : da~ 19tdp

,aHr'ibuhlS of ihe errUtiJ. . , ",..--. ...... --..... "' ............. -~-~~~.------~----.. -r-----~fl~Hf:TAi~j1PLES----·~-··--~-·l

I. if! 1 gI~ lJlulOber 0 ity-fI'Oill c ity-tq i ! ,

t 47 Bou-;bay Ltmdon . -----~----" .. - .. 707 Ue!;.! lie 1 hi Par i $

1f7 BttlrdJay Hew-'{ot"k ~""'_~"'."' ____ ' .• !I_W!_''''''''''Ii1!O' __ 1'+ __ t}¥I> __ '-____ ''''''' ___ <!'''''''''

Here Jf1 i3htJt~l.fllbf'· , t'S, lin iqlle: fur all the entt'ie$ in this table .• H~nt;e U~If[lbel' i~ 1.1 Ke~,

. f) TTRI BurtS Of THE PRESEHT KEY Of EJHlTY : d8.i !ytdp

I _, _ .... _________ ,---1 .

·I---~·-.. ·--"-.... --. ;-'.'-. '''--'-.-''--.-''-~-D Ird.os:---.. ------'----·~-·-'-·--:-l . } t<!f,.ilt,l hw tefl't. d~~J :

DJ1ILYTRIP r tpip~p!,hdej:.U,;d·1.:1,. at'f'_C it,tJt t-tJpeJ I } £u'C er the dUX Hwhs: Hart· fO:~lli$ tht1 key. t i Enter i]!'It ~.ttdbute p~f" ) ine. t!fhen done, Pn~':$~ Rehlt'n ..•.•

> tr ip_rK~

Page 81: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

'.SCR(EN- 1 q

~·T· 1.- '(-e:-~f" '."~,~ :'I~;l:~ef ,~n :~~fJ~~':;-:~ ~, !'~b";:-]' 'r' ~";~;-;;-·~cv~"·~;'''--~--·--~''I he ), ;? 0 a" .... I, .. ~ ".' ... 1<", L. '';;'. ". ~~' ...... :'. ... t·e~ :., ..... '.;I. '. :!f . '\L. I ': VI' I H~at . deh·t~~HlIi: "ht:'. 'JlllU/;;$ (ff all ::the:~ I £H!l n' : c ~ umt I i].Hf'lb'Jtf:s of the 6'ntd';l. i client. ( Hv 1

r-"~-~L£S~J··II I, i ~n ight.J~ullibe(~ cit'rf'rt'tfll i,;:H'rbl t .

747 tkrrnba'J b:mdtm --,'" -~-----"---' 797 Helt! Delhi Par-is ATTfHBUT£S ~*" THE PRESENT I 717 Bomba'} Net~-'{tJ('k kEY or EtnTf'l ! d; ent

Ii t~~~'~--:r;~;~;~;'~~~:'~:'~'-~~'~~:i~:;-~':;":~ 1 -the ~ ~ ~i:~l:nu j etlii' ie~ in Uds tabl~. Hence NUfuher' hi a I<~·;. ___ .,... ___ ~_ ... ______________ .. 1 ... ___ ~ ... ____ . ___ ... ___ ........._.

r'-'---'--'-"-"-~'--"-DrA! fIC---.. -------.. -·---------J } N',)~J fl.:1l" ent. Hy : ..... ~

I", i)JEHT trw~Il~\!;el tet.m.d ) [ntt:!" the ~HdhtlteS' l.h.)t fOr'lllS the !\ty. ) Enlt'r~ tine e:tkibute Pf.'f' llnt. l.4hen uam!. Press:' R~tttl"n •...

I > fiallle J I > ttd_nD: I

lJ ~9 _~~'e_~:trjbote: in U~~(Y!~~n _-__ "_J

Page 82: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

r--------Defin ition------~ r-----.-----Re 1 at i onsh ips are associ at ions beh.Jeen two Of~ nmre ent i ties.

~XAMPLESi-----------1 Airline]eservatioo_$ystem

Re 1 at i onsh i p : Passenger reserves-f (If' Fl i ght

Here ··reservs-for" assoc iat.es the hilI.) ent it i es: PASSENGER and flI GHl.

LIST OF KEYS OF ENTITY: agency l

Hence reserve$-for is a binar'J relationship. '--_--:-_____________ ._J L __________ ~_~

.-------------- DIALOG,---------"----· ) Here we want to see the different typesQf associations t.hat exbt

betttleen pa i r of ent it ies.

> Press an9 ket; to continue ..•••

~------~------~----------------------~--------------

Page 83: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

D f i . t· r---- - '8 n 1 1011--------. r------------. R.e I a.t i oosh i P$ are a~·soc i at i OilS betlJ.\een tt.110 or IllUf'e ent it i es •

r------....,EXAf1PlES ...... · --.-----.--,.

Re 1 at. i oO$n i p : Pas1;,enger reserves-for night

Here "reser'v£-for" aSSOt iates the tttlO

el1t it i es: PASSENGER and F'LI GHT .

Hence fMerves-for is a binar9 relationship.

LIST Of RELATlOHSHIPS : holders ( client,route_ses

J

~---------------.------------------~~-----------------~ ....----------... '·-DIALOG·--~--- -, _. --_._---._-} Are there any more rila.iionships (YIN) ? ~ > cl ient is_()n~.board r1)ute_seg

~-~.. Definition.--------I ....... -----------

Relationships are associations between UST or RELATIONSHIPS : . twa at"' t1ICII~e entities. holders [ c1ient.,rf;lu1.e_~e9

1 ---­r------~--EXAJ1PLES -•. -------

Air 1 ineJeservat ioo_Syst.em

Hef'''' ., 'e "". -.... tC!ru --',..1. 110 .... '$ ... rv~-, 1· assac l .... \·e~

ent ities:PASSEttGER and fUfiHT.

Hefll:;e f'eserves-ffJr is a binat"Y relationship. "--________ .. __ ------......-1 -----.. __ . _______ ---' Give the ~~-:;-;;;:nt i t; cl i'e~·t.DI~~le··I~~;io~;·i~~· i~;;j;~;l

> R{)le :

Give the 1~lJle of th~ ~fltit!.J r(ltl'te~s.~g in ~.he f'1~le:lioMhip hU:.mJ1QRf'dl

> Rale ~

Page 84: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

·Ir;:;:~· I' (In::': ..... "I:-'::::,:;;:}~~:'~~"~::~~::"::'-----~'I' -l·-I~~T·-;;-;;-I. i'I. -T~';'~:;~;~~-::-"~l" 'r-'t~"'<':\ .. ' ;t< 1'-'11 j"'l"~ ~..J W" 'V;s!'~"#""~"':.At,,,!to:u~ .... t~;.~w~~ ..... t' .'" \,; .. ic·' ..... '-M '~'1\o..<i1i·r.j 'f

t h!o i.)l' more ent.Hies. J holders [ d ient:t'QlJh.!~.se9

t ____________ , __ . __ '_ .. ____ ~ ... ~h __ .. _"._ " ] i~ tom bDar'U [ cl ~entrr(H.ri,e t--.---'M .. --.-~£X('.tiPLES---~--... -~ ... -.1 ! ~e~iM] " -

I Hence f'eser'ves,-f'fJt' !~; ~ blnr.lry f·elaHonsh!p. '. isa, ( p~s~engel'~.t;li(~nt 1 ,RelaU~n:,hip ; EtIPl.OYE£ ~~ORl\JH DEPf'lRTIiENT Piil't_\)f ( ageflC';hd ierrL 1

fHe."" .... ".'.lll "mf'·lO\I~ .. t:f1:I·'''' H."".,,,, 1:..... u) " f.' • ~.' ... t1~ " ...... ,.. ~ ~ .. ,. ,.... ... d .. "'... .. v' I I e'!el"~~ department rand ' I

lm1'::J nne department is ther'e hr:1 I

evet"J eUiplol,Jt:t:. ,I i ' .. ~_. __ .. _._~ __ ,._.,. ___ . ______ . __ . ___ . __ I t. __ ~ ___ ._~ __ .~ __ ... ~ ____ .J r~-'-'--'-""~~ .--. ·"~···-~---"·-~·-·-,-~-·DIHtJ)~·-------·--"'··-----·-~"·-----

I ) At'e th(:.we (.my m(we l'f:lt'ttiotls!dl}:;' ('11m 7 ;. fw the f'elaUfJIlSnirJ : hulde-Pt

Is 'thel~€ m~JI~ t Bent fot' eVtrl'~ rot1tt_se~'1 (V/1~)

I __ .... __ ~.,_~ __ ..... __ .... __ _._-_ ... _u ___ , ___ .,.~~ .. _fl ... __ ~"'_ •• _ .. "'"i""",_ .. _ ... , .. ~_ .. -.,_ .... _I

Page 85: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

r-------Definitian--·-----e------------. Relat ionship attributes are properties of re 1 atiom.;h ips used hi de$crlbe it..

..----~--.. -. ......rEXAl1PLES-----··-··-· -'''''i .Relat iOllShip:

SUPPL fER SUPPLY ITEM [Quant i t~)

.Hef'e Quant.it~ is !nattr!bute of the f'elatif)m~hip ! SUPPlY tAhich specifies the quanti\.9 of an ITEM supplied hy a par-ticular' S'fPPUER.

LIST OF ATTRIBUTES OF : ho 1 def's

Page 86: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

5~RE.e:.tJ -~--

r . . ~- , . -DISPLAY~OIEW «< Etlti Ues »>

Eflt it ies AttdiJt~tes J dai lytrip tt'ipjIQ,deV.,.cit~/'arr'_dty, type

I r!:t~t.e_se9 Se!Lno,date, tot&l~seats,resel'w!_seats cl umt no/nrune,tei_M passenger passenger -:flO 1 fIl i I eage 1 st.atus agency agenC!LftUJll1hCredH,Jimii

Page 87: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

SCJ.(2E N-aU r------.------:DISPlA'CVl£f4-,------------, « ( Re 1 ati ooshi ps }) )

Relat.ionships Entities holders client,ru,ute_seg i~_on_bt.iard cl :ent,r6utt:.u:eg i~a passenger,c1 ient part_of agerl!~l!IIClie!1t

Pre~s any key to continue ..• , rorJt!!;_~ea m daHlJtdp

, "

J:~ i~

;. ~

'---~----------.. ----...... ---~----...-.-~--~~- ' ~

Page 88: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

sc..ReEf'J -2'1-,-------~,-·_I:·£DIT-I1EMU~----------__,

} Select the apprQpriate opt.ions from 'the follol).!ing r~nu to dQ the modifications.

1. Mod if!; Ent i ti i es • 2. Modify Relationships. 3. Exit..

> Select yourchtiice '~ 1

Page 89: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

Sod<, E £ rJ ~ 2-2t

....--------------1:. ~:DIT-Ef'lTlTlES,----------__. > Select the appropriate options from the following

menu to do the modifications.

1. Add Entities. 2. Delete Entities. 3. Rename entities. 4. Add attribute to Entities. 5. Delete Attributes from Entities. 6. Rename attributes of entitles. 7. Exit

> Select Your Choice: 3

.--------------DIALOG(-i--------------.

Page 90: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

-'>~S-e' led -U-;e-r:-",p-p-,'o-p-r-ia''te {) li·s·r···Of-£'-N-T-H-I-ES~-:-----'-1 menu t.o do the modificai H dai hl~;rip I

2) route_seg

I I

1. Add Entities. J) client 2. De lete Errtii i,es. 3. Rename entities. 4. Add at. tr ibute to Ent, i 5, De lete Aiir'ibutes ~'PIJ 6. Rename aUribu{~es of (. Exit

> Se leet Your Choh~e

4) pas~eflgel" 5) 8.gency

L---_____________________ ~ ____________________ __ ------..11 DIAlOG,-----------· ---1'

> Seled the f,nt-ity fr'Ofil t.he above list which you wan't, to r'eflame

I } ( Enier the name/Press Return for no".) : daily trip I > Eflt·er ihe n." name : dally_ ir ip

L_, ____ . ____ ~ ________ , __________________ ___ J

Page 91: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

-:;L.RtEN~3.0

.-------------t.DlT-EiiT1TIES-·------------, > Select. t.he appropriat.e opth.f \1S from the fcllowing

menu to do the modifications.

1. Add Entities. 2. De lete tnt it. ies. 3. ReMJile ent.ities. 4. Add attribute to Entities. S. Delete Attf'ibutes from Ent.ities. G. Rename at.tributes. of entities, 7. Exit

> Selt~t Your Choice: 5

·---------DIALOGr----------------,

AGEtiCY [f1gef!c!J_nD 1 fifl: cred it._limi tJ > Do ~.!OU b.lant to de let.e attributes from AGE~C,( (Vim 1 iJ

[ you ... nt to delete NO {Yilii : y

.......... -----._._.,. .. _. __ • __ ----l

Page 92: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

View: trip_view Entities Attributes

dai 1 y_.tri p route __ seg c 1 i ent passenger agency

TRIP_NO, dep_citY,arr_citY,date DATE,SEG_NO, total_seats,reserv_seats

NO, credit_limit PASSENGER_NO, name,tel_no,status,mileage

AGENCY_NO, credit_limit

Press any key to continue ....

Relationships Entities

holders is_on board

passenger agency isa

client,route_seg client,route_seg

isa client client

Press any key to continue ....

Page 93: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

View : schedule view Entities Attributes

trip TRIP_NO, dep_citY,arr_citY,weekdays,type,event ord_route_seg SEG_NO, dep_city,dep_time,arr_city,arr_ti~ pop_route_seg SEG_NO, dep_citY,arr_city,dep_timre,arr_t-

Press any key to continue ....

Relationships

ord_with_in pop_with_in

Entities

ord_route_seg,trip pop_route_seg,trip

Press any key to continue ....

Page 94: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

sc:.R6. e. N -3.3 View: bus_file Entities Attributes

bus bus __ prob daily_trip

BUS_ID, lic#,seats,last_chk PROB_CODE, description

TRIP_NO,DATE

Press any key to continue ....

Relationships

bus,bus_prob daily_trip,bus

Press any key to continue ....

View: driver file Entities Attributes

date,cause

Entities

driv_abs driver daily_trip

DRIVER_ID, name,address,phone TRIP_NO, DATE,

Press any key to continue ....

Relationships Entities

daily_trip,driver

driv abs isa driver

Press any key to continue ....

Page 95: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

r DIALOG-·------

The phase$ through !.dh iell you I,.1i I} go through ar'e :

1:- Seled·'..'iews : You will be asked to seled hm views from CI. list of vielllS for' inte~waHon.

2) Coni 1 i c-t ResQ 1 ut.i Of! :

In this step various conflicts will be identified and resolved.

3) f1erg i"9 : The h10 conn i d. fr'es yo i ews t\ti 11 be merged i n{:o a ~dngle view.

) Press any key to continue .••..

1 ___ --__ ----------__ _ J I SELECT ')I[I·1S-------I} Seled ar.~l t.wo vielJJs from the feith-jilting list for integration:

1\ t r: p .. ~ e'" : '" J. "_01"' W

2) schedule_vie\IJ 3) driver_file A) -b £. I '"It US_.dle

f jr"'t III "",'1 (1-4) a iJ.. 'Ij .. ti,;.'.v I

Page 96: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

. SEtEci~'In~S-,--------

Ih Select: any hAO viet-.ts from the following I ist for integration: i} tr'ip_ view

i 2! sched, U lc .. ;s i eM 3) dr'iver f de

I 4) bus_file I First View (1-4) 1

Second ',' ieU} (1-4) : S

> The number s;hould be fl~om (1-4) and diHerentfrom 1. ) PI ease se leet lhe f:e.:.:ond vie\i! age:. in.

$j;cQndlJ i e~d (1-4) : 2

,-, .. ----~----,-.------~---- ------------'

,..---------------. DIALOG------··--·--------t > Give the name of Ute int.egra.ted viet ... : trip_,~chetiui

Page 97: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

SLR.<=..e~';~

&' • f--··· .. _·_-_·· __ ······_··-_···_·· __ ···_ .. --_···_···_···--~r I P _ ','1 ettl-.-'".-.. --~--.• --.-.. -h·-·-·--·-·--· .. ~l I DAIUTR I P ( dep _ci iy, arr _ ci I'!, d.l ", tl' lp .,no ) I J

'---_. ...~.--.. -.--.-.---.---.-.------.-.--.. --.. -... --.-----... --.---.--~.-j

r--·-- ·-----·---·--~C'h~d.':..·l e I} i elil'--·---.. ---·-'··---~---~--·'1 TO' P···I . t . . ! .. '-. " . I' .. , .... , 'I "'''''fl'' 1" , ~,·",·"~· ..... ·,·t,, "';;'I~/'!1"!!"" ""n,;; """;:'11·' ~rln l"li'i J "" ..... , ._" ..... t nJ- ~ 1.,..li-I r " _1 .",t.1It '_I.""'4':/U'''·\..-\\J'U'7~''\''.t''''''''!,;,'·''W ("IIl- f<" ,fw I - -., ... !

I I L __ ._ .. _ .. __ .. __ ~._. _____ .. __ ._. __ , .. __ ._. ____ . __ J r-·-----· .. -----·--·----· .. -----D I ALOG-------·-·-----·-.. -···~-·--·--·----·-til' Hhicb of the f'cllol.!dn£l reiElJionship hold$ hi¥' these entitie:s I

of the hJu I.liei).!$ ; ! i 1) The entities are e:,hdh; ~aille inut1th the Vif:";W;;:. f 2! The enU't:1 DAILYIRIP [;f' !tdp_yiew' is a sljbs~t of the efrI:.HI~; »

t

I :-.n .. Tho 1'J,·,·t l"~" i.RIP n·t ',.,,,,1·,,,,,,,1 .. 1,,, 1""It .• ~ I ... ,'~ :..Itt t._:: ..... , .,.., ':'·_"~\o.II .. ' ';".0._" I\. '.:1 Ie,.:.

DAILYiPIP of the t,l- ip ... '/iet..r. 4) Both the entities MILYTRIP and TRIP 5) lione (If the abDve ar'e t.r·uti .

I 1

\ r.!'lh~r '..I'·"lr ,...1..'("'1',,·,,· {1··r.) . "'I. I ~. ~. 'oJ . v'\. \.II. -.,; \""J'. o.J I' 'I • J ... ---:.-... --.-.-----.-... - .. -----.. -----..... -.~.-.--.. " .•.. --------.-.-.... ~~.-.-.j

r·----·-·----·-.... -----"··nIj~\..OG_--,-··---·---.. -·-rl.-.-"--1 Ii' .;. !.lh 1 (,I-, pCI ~·I·"e· f .. · 'Il fi l ,,; "1'1 ~,~ 1 ''If ; ,. ..... r. .• ~.;" 1",1,1",. [:r •• ' ",-I,"!'!"'" ""r,'} j·t I' eo' I' I I·U' .. I~'..J \. 1 I ........... ·t.:'~'ll~::..f 1 Li \O!''''';.. .... ·~twil4''tJ' '~'<i'At.t;.;· "VII \- ,...,~ ... \...>~t':. J;" J.'

I ~f th~ lwo vie~8 : t I 1) The eilt.iii~s .11"8 exact.l~ s,::rme in both the ')i!:..~W;L i l 2) The enUty R0UTE_S:EG of ~l~dp._"i'ii:t;.l! is a $:..rk!1ei: of' the entih) I ! OPDJ~OIJTE_SEG of t.ht:, s;chedule_.viet,J. t I 3) Th!: ent.it'~ ORD_ROU1E_.~}EG IJf 'st:htduli3_':ielL1' is Ii suo$et of tbe entHy J J p'nUTE c'Er f' i., f·,. '. .' i I, .~ _ . .;, 30 IJ.le ,.,lp_,.le1.11. J

,!'I B'"'t~· /.I~<. ,",,,Hf,:,,,.·. Dr.!lTC" (rci "' .... ,-i !I1':m pnurr. ~r.c h:tv" 13 -"'om'ncr niH"""" ! I i; N~:n~ ~f~'th~"'~l~~~; ~;:;'i~~;· WI" '-"'~-"'~' a,_" ... ,. "'J l ~ III" .. ".... 1.1.

, :> Erd:.8:·· ~~O\.ll" c.:hQi.'::'.i! (i-S) : '3 .. --... -.------.--.-.-.. --.•. __ •. -. ____ . ________ ._. _._._. ____ ... _____ • ____ ..J

Page 98: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

~Ret.N ~ 1ft>

...... ----·----------idriver _f i le--·----~---,

IDAILY_TRIP( t.rip_no,dale )

L ~-------------------------DIALO~-~-·--------------------~ > ~\Ihich of the follol!ting relalionship hulds for t.hese entities

of the t.wo 'v'ielt.!s : 1) The entities are e:(actly saffle in both theviel.l.ls. 2} The entity DAILY.JRIP of 'driver.Jile' i11: a subset of the entity

DAILY TRIP of the bus file. 3) The eoUty DAllY_TRIP-of 'bus._file' is a subset. of the entity

DAILY_TRIP of the driver_file,. 4) Both the entities DAILY_TRIP and DAILY_TRIP hav.~ a common demain. S) None of t.he above are t.rue

> Enter' your choice (1-5) : ~I----------------------------------.-"-,------------.------.--~

Page 99: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

I SC. HEDULEJ-'I EI1 Attributes at I

Cr .... ' t ... I ..... ". ':} . I

1 ~~~~------··-------i I __ ~::~~:~~--------I type

date

---------------.--- -----------------..... -----------------------------------------.

~----------- ~'-----------, .-----.-r --- .. DIALOGi---" -----------> If t.he pail' of attributes in t.he ('01.1.1 and column l' ,"

M'e !J9nonyms thtm entef' (Y), othenl.lise enter Hi).

·L _____________________ , _J s~~rJ-4~

[ , ' 'l~' ,AHribute.)~ynonyfrl assedion' l

SCHEDULE_ V I £1.1 TR I P _VI EN ('lAo t I" q. ".j. '"'''' ot I At J. "1' b .. te<, of ::'nt l'tll • RnuITC' e'Er- ' ~ "d .. · ~ J. .. J·..t,.~~·v • ,l~1 \.i ..... ..:.. to.... ':I'" .. \.I" llt._..) ~' 1 lEnt i .~~ : I -.-----------------------------------.~---.~ .. -----------------1 r,i;)fl P, '!I JiE ~~r.; dat e J·o.t a I "eat<' "'e""ef"'V "e,"'t~ i

It~i,\,.~_t\';J_. -~' .. " •. t, -I~ J,_~ , ..,,:. I ~ -.~ iA .... . I --~;;-:~~~-------- ---~--------------~---.----.. ------~------------------------ .

I--~;::;;~--------I ---;;------------~-------------:------------------'­I--:;;.~~~;,~--------' I---;;--------------~--·------------;-------------------I ------------------ ----------------------------------------~-----------------

arf'_t.lme

L __ -.-J

n n

---------------.--------------~---==~----J

I I I

Page 100: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

r-'---_. -----·-----tr !p_'.'iettl---jPASSEHGER( name 1 te tno, status" mil e.lgt't pi.~~:senger _no )

I I . ..--------------,-,--··~chedtll e __ '-li et..t--------------ClIC"I,JT( .. -, ,. *- ", ~ I

i . -'

I ----.. -----,-~

Page 101: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

View: trip_schedule Entities Attributes

pop_route_seg dep_citY,arr_citY,dep_time,arr_time ord_route_seg dep_citY,dep_time,arr_citY,arr_time trip TRIP_NO, dep_citY,arr_citY,weekdays,type,even daily_trip dep_citY,arr_citY,type route_seg DATE,SEG_NO, total_seats,reserv_seats client NO, credit_limit passenger PASSENGER_NO, name,tel_no,status,mileage agency AGENCY_NO, credit_limit

Press any key to continue ....

Relationships Entities

pop_with_in ord_with in holders is on board

trip,pop_route_seg trip,ord_route_seg

client,route_seg client,route_seg

passenger isa client daily_trip isa trip pop_route_seg isa route_seg ord_route_seg isa route_seg agency isa client

Press any key to continue ....

Page 102: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

View: driv bus_file Entities Attributes

bus_prob bus driv_abs d ri ver daily_trip

PROB_CODE, description BUS_ID, lic#,seats,last_chk

date,cause DRIVER_IO, name,address,phone

TRIP_NO,DATE

Press any key to continue ....

Relationships

used_for with driven_by

bus,daily __ trip bus_prob,bus

daily_trip,driver

Press any key to continue ....

Entities

Page 103: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

View : transport Entities Attributes

driver DRIVER_ID, name, address, phone dr;v abs date,cause bus BUS_ID, lic#,seats,last_chk bus_prob PROB_CODE, description pop_route_seg dep_city,arr_citY,dep_time,arr_time ord_route_seg dep_city,dep_time,arr_city,arr_time trip TRIP_NO, dep_citY,arr_citY,weekdays,type,event daily_trip dep_citY,arr_citY,type route_seg DATE,SEG_NO, total_seats,reserv_seats client NO, credit_limit passenger PASSENGER_NO, name,tel_no,status,mileage agency AGENCY_NO, credit_limit

Press any key to continue ....

Relationships

driver,daily_trip bus,bus_prob

Entities

driven_by with used_for pop_with_in ord_with in holders is_on board

daily __ trip,bus trip,pop_route_seg

trip,ord_route_seg client,route_seg

client,route_seg

passenger isa client daily_trip isa trip pop_route_seg isa route_seg ord_route_seg isa route_seg agency isa client

Press any key to continue ....

Page 104: SCREEN3 .TXT ATT EG .TXT KEY EG .TXT BREL EG .TXT …shodhganga.inflibnet.ac.in/bitstream/10603/16108/14/14_appendices.pdf · Appendix A TURBO PROLOG PROGRAM LISTING There are three

seK.68\l - 44-

RELATION SCHEMES

(With keys shown in capital letters.)

« Entity-Relations » agency (AGENCY_NO,credit_limit) passenger (PASSENGER_NO,name,tel_no,status,mileage)

, client (NO,credit_limit) route_seg (DATE,SEG_NO,total_seats,reserv_seats) daily_trip (TRIP_NO,dep_citY,arr_citY,type) trip (TRIP_NO,dep_citY,arr_citY,weekdays,type,event) ord_route_seg (DATE,SEG_NO,dep_city,dep_time,arr_citY,arr_time) pop_route_seg (DATE,SEG_NO,dep_citY,arr_citY,dep_time,arr_time) bus_prob (PROB_CODE,description) bus (BUS_ID,lic#,seats,last_chk) driver (DRIVER_ID,name,address,phone)

« Relationship-Relations » is_on_board (NO,DATE,SEG_NO) holders (NO,DATE,SEG_NO,smok_opt,seat_num) ord_with __ in (TRIP_NO,date,seg_no) pop_with_in (TRIP_NO,date,seg_no) used_for (TRIP_NO,bus_id) with (BUS_ID,PROB_CODE) driven_bY (DRIVER_ID,TRIP_NO)

«< Inclusion Dependencies »>

passenger ( NO) belongs to client ( NO ) daily_tril ( TRIP_NO) belongs to trip ( TRIP_NO) pop_route_seg ( DATE,SEG_NO) belongs to route_seg ( DATE,SEG_NO ord_route_seg ( DATE,SEG_NO) belongs to route_seg ( DATE,SEG_NO agency ( NO) belongs to client ( NO ) driven_by ( TRIP_NO) belongs to daily_trip ( TRIP_NO) driven_by ( DRIVER_ID) belongs to driver ( DRIVER_ID ) with ( PROB_CODE) belongs to bus_prob ( PROB_CODE ) with ( BUS_ID) belongs to bus ( BUS_ID ) pop_with_in (TRIP_NO) belongs to trip ( TRIP_NO) ord_with_in ( TRIP_NO) belongs to trip ( TRIP_NO) holders ( DATE,SEG_NO) belongs to route_seg ( DATE,SEG_NO,) holders ( NO) belongs to client ( NO ) . is_on_board ( DATE,SEG_NO) belongs to route_seg ( DATE,SEG_NO is on_board ( NO) belongs to client ( NO