For a situation where the Length, Width and Height attributes are only
appropriate to particular entities I'd adopt a different model. Say we have
a table Objects, some of which are Balls (spheres) and some of which are
Boxes (regular hexahedrons). The size of former can be defined by the
attribute 'Diameter', the latter by the attributes Length, Width and Height.
Balls and Boxes are sub-types of objects therefore, sharing all the
attributes of the (super) type, but not those of the other sub-type. So I'd
model this in the usual way with an Objects table and Balls and Boxes tables,
each related one-to-one to Objects.
This seems to me to be conceptually more correct than the sort of approach
proffered by Steve, which I think confuses attribute types and attribute
values.
Ken Sheridan
Stafford, England
At the risk of not pulling a log out of my eye in order to see the
speck in someone else's eye, may I suggest the term "rectangular"
instead of "regular." To me, a regular hexahedron would have the same
value for Length, Width and Height and be analogous to a sphere in
having those attributes defined by a single (no pun intended) scalar.
See:
http://mathworld.wolfram.com/RegularPolygon.html
Although nonrectangular hexahedra have Length, Width and Height
attributes as well, it seems to me that the term 'rectangular
hexahedra' conveys more accurately the "shoebox" kinds of shapes that
seem to be implied by the OP.
I agree that using a single column to find the maximum is clean. Your
subquery example is almost identical to what I likely would have done.
After doing quite of bit of graphics in Access recently, I note that
attributes of the solid like Length, Width and Height are often more
conveniently expressed with a custom Type. E.g.:
Public Type Point
X As Double
Y As Double
Z As Double
End Type
Public Type RectangularHexahedron
L As Double
W As Double
H As Double
Color As Long
Origin As Point
End Type
so that I can define my solids like:
Dim Shoebox(20) As RectangularHexahedron
For I = 1 To 20
With Shoebox(I)
.L = Length(I)
.W = WidthBox(I) 'Width(I) gets confused with the Width #
Statement
.H = Height(I)
.Origin.X = OriginX(I)
.Origin.Y = OriginY(I)
.Origin.Z = OriginZ(I)
End With
Next I
Once I have such a set of solids, how do I store them in tables? If
no analysis needs to be done, then L, W, H, X, Y, Z suffices. I can
also note that I am going to need to find the maximum dimension along
with which one(s) and decide to use three records in a related table
to store the dimensions. Your idea to have the Balls and Boxes tables
"inherit" from an Objects table is interesting.
But wouldn't it be great to set up a blob type and simply save the
solids as RectangularHexahedron's? I don't actually mean the custom
Type shown above. I mean the actual CAD model for each solid. SQL
Server 2008 allows you to do just that with its Remote BLOB Store. If
the tables are not being used to generate the solids, a CAD program
could make any changes directly to the solid stored in SQL Server. It
might be worth giving up a lot of computational efficiency to have
that capability. It would also possibly eliminate the need for
separate consideration of spheres and rectangular hexahedra, depending
on the capabilities of the CAD program. It is interesting to note that
CATIA 5 under Windows allows VBA scripting.
Please excuse the desultoriness of my thoughts here.
James A. Fortune
(e-mail address removed)