%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  ENTITY-RELATIONSHIP-RELATIONAL TRANSFORMATION EXAMPLE
%  Author: Jesus Almendros and Luis Iribarne. March 2012.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% (1)

val:duplicated_attribute_name(Att1) and val:duplicated_attribute_name(Att2):-
mmA:attr_of(Data,Att1) and mmA:attr_of(Data,Att2) and mmA:name(Att1,Name1) and mmA:name(Att2,Name2)
and differentFrom(Att1,Att2) and equal(Name1,Name2).

% (6)

val:duplicated_data_name(Data1) and val:duplicated_data_name(Data2):- mmA:data(Data1) and mmA:data(Data2) and differentFrom(Data1,Data2) and mmA:name(Data1,Name1) and mmA:name(Data2,Name2) and equal(Name1,Name2).

% (7)

val:duplicated_data_container(Data1) and val:duplicated_data_container(Data2):-
mmA:data(Data1) and mmA:data(Data2) and differentFrom(Data1,Data2)
      and mmA:container(Data1,Name1) and mmA:container(Data2,Name2) and equal(Name1,Name2).
% (9)

val:duplicated_qualifier_name(Role):-
mmA:is_qualifier(Role,Qualifier1) and mmA:is_qualifier(Role,Qualifier2) and mmA:name(Qualifier1,Name1) and mmA:name(Qualifier2,Name2) and differentFrom(Qualifier1,Qualifier2) and equal(Name1,Name2).

% (10)

val:qualifier_non_keyName(Qualifier):- mmA:qualifier(Qualifier) and mmA:name(Qualifier,Name) and
mmA:key_name(_,NameKey) and makeSet(NameKey,Names) and notElement(Name,Names).

val:qualifier_non_keyType(Qualifier):- mmA:qualifier(Qualifier) and mmA:type(Qualifier,Type) and
mmA:key_type(_,TypeKey) and makeSet(TypeKey,Types) and notElement(Type,Types).

%(12)

val:duplicated_relation_name(Rel1) and val:duplicated_relation_name(Rel2) :-
                  mmA:relation(Rel1) and mmA:relation(Rel2) and differentFrom(Rel1,Rel2)
                  and mmA:name(Rel1,Name1) and mmA:name(Rel2,Name2) and equal(Name1,Name2).

%(15)

val:duplicate_role_data(Data):-mmA:data(Data) and mmA:role_of(Data,Role1) and mmA:role_of(Data,Role2)
and differentFrom(Role1,Role2) and mmA:name(Role1,Name1) and mmA:name(Role2,Name2) and equal(Name1,Name2).