Suppose a relational database has employee
and company
entity with workFor
relation, such as
employee
(ssn, first_name, last_name), where ssn is the key.
company
(company_name, location), where company_name is the key.
workFor
(ssn, company_name), where ssn and company_name are foreign keys.
Suppose the database is huge, and we need to query the number of employees for a company very often. Rather than request a query each time, we decide to add a attribute of number_of_employ
somewhere in the relational schema for performance consideration. My question is that if we add the number_of_employee
to the company(company_name, location, number_of_employee)
relation, does it still satisfy the Boyce–Codd normal form (BCNF)? And is it a good design?
Intuitively, I do not think it still satisfies the BCNF because the company_name
alone can not determine this attributes (and it is not a key any more). Is there any term for this "aggregation" attribute of number_of_employ
, which is determined not by a specific value but by the whole workFor
relation? What would be a good schema design for it if I have to add this attribute somewhere in my schema?