dbase(cd,[tab,attr,assoc,sub,cons]).
table(tab,[id,name,abs:bool]).
table(attr,[id,name,ptype,attrof:tab]).
#ptype = primitive type int, float, bool, dbl, str, qstr
table(assoc,[id,name,class1:tab,role1,atype1,min1:int,max1:int,class2:tab,role2,atype2,min2:int,max2:int]).
#atype1, atype2 = DIAMOND(0,1), BLACK_DIAMOND(1,1), BLANK(0,32000), CUSTOM(0,0), UNKNOWN(0,0);
#class1, role1 = primary table, primary role
#class2, role2 = secondary table, secondary role
#name = association table name (needed only for NM associations)
table(sub,[id,suptab:tab,subtab:tab]).
#suptab, subtab = supertable, subtable
table(cons,[id,name,"constraint"]). | dbase(cd,[tab,attr,assoc,sub,cons]).
table(tab,[id,name,abs:bool]).
tab(Pet,Pet,false).
tab(Dog,Dog,false).
tab(Cat,Cat,false).
tab(DogBreed,DogBreed,false).
tab(Person,Person,false).
table(attr,[id,name,ptype,attrof:tab]).
attr(Pet_id,id,str,Pet).
attr(Pet_name,name,str,Pet).
attr(Pet_age,age,int,Pet).
attr(Dog_id,id,str,Dog).
attr(Cat_id,id,str,Cat).
attr(Cat_friendly,friendly,bool,Cat).
attr(DogBreed_id,id,str,DogBreed).
attr(DogBreed_name,name,str,DogBreed).
attr(Person_id,id,str,Person).
attr(Person_name,name,str,Person).
attr(Person_city,city,qstr,Person).
table(assoc,[id,name,class1:tab,role1,atype1,min1:int,max1:int,class2:tab,role2,atype2,min2:int,max2:int]).
assoc(db,db,DogBreed,breed,BLACK_DIAMOND,1,1,Dog,examples,BLANK,0,-1).
assoc(po,po,Person,ownedby,CUSTOM,1,1,Pet,owns,CUSTOM,0,5).
table(sub,[id,suptab:tab,subtab:tab]).
sub(Pet_Dog,Pet,Dog).
sub(Pet_Cat,Pet,Cat).
table(cons,[id,name,"constraint"]). |