| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Are redundant fields ever appropriate?
> > Is this something I'd ever want to do?
> No.
I disagree. The join is implicit in the foreign key reference, but sometimes when three tables are frequently joined, one of the tables should be clustered by a key which isn't naturally a foreign key in that table. The data is denormalised, but that's necessary for the DBMS to produce appropriate clustering. Here's an example simplified from one I used recently with MS SQL Server. It records Organisation Units as SDOU (Site/Domain/OrganisationUnit) using X.500 DNs, then records Computers belonging to those SDOUs, then records Occurrences of known Software objects on those computers. The catch is that the most important query is to summarise over a single SDOU. The query is easy to write without the non-normal SDOUID in SoftwareOccurrences, and fairly efficient to perform, but clustering the SoftwareOccurrences records by SDOU makes it more efficient. Clustering by ComputerID isn't as big a win. Any thoughts on this?
Apologies for using SQL-Server extensions in the form of IDENTITY fields - this reduces the keys to a manageable size. What equivalent support is there in other DMBSs (Oracle?) or in the SQL standard for this sort of thing (apart from allocating unique IDs manually)?
create table SDOU (
create table Computer (
create table SoftwareVersion (
create table SoftwareOccurrence (
/*
* FK to OU of Computer. This is denormalised, since it's
* dependent on the ComputerID in this row, but useful for
* clustering!
*/
ComputerOUID int NOT NULL
CONSTRAINT FK_SoftwareOccurrence_ComputerOU
REFERENCES SDOU(OUID)
-- other fields...
on SoftwareOccurrence(SoftwareId, ComputerOUID, ComputerID, UserID);
-- Clifford Heath, ManageSoft CorporationReceived on Tue Nov 13 2001 - 20:55:32 CST
![]() |
![]() |