Subset, superset and INIT section issues
Posted: Mon May 31, 2010 1:37 pm
Hello,
I was wondering if anyone could tell me, if I have understood some things correctly and these issues, I am having, really are bugs.
For defining "foreign keys" in Tutorial D one can use subsets - defining that an attribute is a subset of a key attribute in another table?
Is it correct that if I use attribute names in a INIT section of a base variable, which also has a header definition, the attribute names are ignored and the values are added according to the attribute names of the header?
Example:
The command clearly shows that the values were added ignoring the INIT section attribute names.
Now if I add another variable
and a "foreign key"
it will fail. Which is correct, since the attributes contain wrong values.
But if I reverse the subset sign it will succeed, even though there are no common values.
...
While writing this post I found that
also succeeds even though it should be equivalent to the first constraint.
I was wondering if anyone could tell me, if I have understood some things correctly and these issues, I am having, really are bugs.
For defining "foreign keys" in Tutorial D one can use subsets - defining that an attribute is a subset of a key attribute in another table?
Is it correct that if I use attribute names in a INIT section of a base variable, which also has a header definition, the attribute names are ignored and the values are added according to the attribute names of the header?
Example:
Code: Select all
VAR Department
BASE RELATION {company_name CHAR, department_name CHAR}
INIT (RELATION {
TUPLE{department_name "Research and Development", company_name "General Electronics"
},
TUPLE{department_name "Management", company_name "Ads are Us"
},
TUPLE{department_name "Management", company_name "General Electronics"
}
})
KEY {department_name, company_name};
Code: Select all
Department
Now if I add another variable
Code: Select all
VAR Company
BASE RELATION {company_name CHAR}
INIT (RELATION {
TUPLE{company_name "General Electronics"
},
TUPLE{company_name "Ads are Us"
},
TUPLE{company_name "Sushi and Pizza place"
}
})
KEY {company_name};
Code: Select all
CONSTRAINT department_company_name_fk Department {company_name} <= Company {company_name};
But if I reverse the subset sign it will succeed, even though there are no common values.
Code: Select all
CONSTRAINT department_company_name_fk2 Department{company_name} >= Company {company_name};
While writing this post I found that
Code: Select all
CONSTRAINT department_company_name_fk3 Company {company_name} >= Department {company_name};