|
|
|
date: Thu, 7 Aug 2008 13:58:01 -0700,
group: microsoft.public.sqlserver.server
back
Re: Table Relationship Question
On Aug 7, 4:07 pm, RAF wrote:
> What might be a better option is to not have SiteId in the equipment table;
> rather have the Site table have a FK for the equipment table. That does away
> with nulls in the siteid column.
> Roy
Then a site could have only one piece of equipment. Equipment is
likely to have only one site, location, and sub-location. They way
AkAlan had it designed was correct. SiteID probably shouldn't ever be
null in his design, but the challenge with that design is keeping the
data valid. In other words, if there is a location id in the
equipment table, it should only be a location that's within the
SiteID .
If you have a shared table as I suggested, you can have only one
location, but that location can be a site, location, or sub-location.
That removes the issue with the sites, locations, and sub-locations
getting out of sync, and you can still determine sites, locations and
sub-locations, or if a piece of equipment is in a site, with that
design. But the queries run a bit slower, as the optimizer has more
trouble optimizing the query to hit multiple levels of the same
table. But there are also a few tricks to work around these
optimization issues.
-Eric Isaacs
date: Fri, 8 Aug 2008 09:23:19 -0700 (PDT)
author: Eric Isaacs
Re: Table Relationship Question
According to the original post:
"Every tblEquipment record may or maynot have a site, location or sublocation
associated with it. "
Which I take to mean that equipment may not have a site. If, indeed, that is
the case then the siteid would have to be a null.
"Eric Isaacs" wrote:
> On Aug 7, 4:07 pm, RAF wrote:
> > What might be a better option is to not have SiteId in the equipment table;
> > rather have the Site table have a FK for the equipment table. That does away
> > with nulls in the siteid column.
> > Roy
>
> Then a site could have only one piece of equipment. Equipment is
> likely to have only one site, location, and sub-location. They way
> AkAlan had it designed was correct. SiteID probably shouldn't ever be
> null in his design, but the challenge with that design is keeping the
> data valid. In other words, if there is a location id in the
> equipment table, it should only be a location that's within the
> SiteID .
>
> If you have a shared table as I suggested, you can have only one
> location, but that location can be a site, location, or sub-location.
> That removes the issue with the sites, locations, and sub-locations
> getting out of sync, and you can still determine sites, locations and
> sub-locations, or if a piece of equipment is in a site, with that
> design. But the queries run a bit slower, as the optimizer has more
> trouble optimizing the query to hit multiple levels of the same
> table. But there are also a few tricks to work around these
> optimization issues.
>
> -Eric Isaacs
>
date: Fri, 8 Aug 2008 13:22:01 -0700
author: RAF
|
|