Page 1 of 1

Subset, superset and INIT section issues

Posted: Mon May 31, 2010 1:37 pm
by berg
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:

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};
The command

Code: Select all

Department
clearly shows that the values were added ignoring the INIT section attribute names.

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};
and a "foreign key"

Code: Select all

CONSTRAINT department_company_name_fk Department {company_name} <= Company {company_name};
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.

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};
also succeeds even though it should be equivalent to the first constraint.

Re: Subset, superset and INIT section issues

Posted: Mon May 31, 2010 2:52 pm
by Dave
berg wrote: 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?
They're not supposed to be ignored. The header definition and the INIT section must match, and the tuples in the INIT section should be mapped to match the defined header. It appears you've found a bug! :roll: This will be fixed in the next update. I suspect this bug is affecting how the <= and >= operators work, but will do some testing to make sure they behave correctly once the bug is fixed.

Re: Subset, superset and INIT section issues

Posted: Fri Jun 04, 2010 8:22 pm
by Dave
This bug has been fixed in the version 1.0.0 beta update.

Re: Subset, superset and INIT section issues

Posted: Fri Jun 04, 2010 9:39 pm
by berg
Thanks, Dave!
Keep up the good work!