Database structure

  • I'm setting up a database to store dimensions of material. The material could be cut into quadrilaterals. What is the best way to store this information. There will be an unknown number of sides.

    Thanks in advance.

  • Are you asking how to design the Material dimension table and the Material has number of sides?

    What is the problem that you have when you design this table? I don't understand your question.

  • I may be misunderstanding your question, and also the best way to store the information often depends on what you intend to do with it.

    The obvious answer if you are storing the dimensions for arbitrary quadrilaterals is to have each side numbered clockwise from the smallest and then store the value in a smallint.

    ---
    Timothy A Wiseman
    SQL Blog: http://timothyawiseman.wordpress.com/

  • Thanks for your quick replies.

    The problem is I don't know how many sides the material will have. The material could be retangular shaped, L-shaped, + shaped. For a square you have the height and width. Would I need to calculate the dimensions of the quadrilateral into rectangular/square shapes so there is only a height and width, then have a parent table and child tables to combine all the rectangular/square shapes? For example, a rectangle would be in one table, an L-shaped would be in the parent once and the child once (for 2 rectangular shapes), and a plus would be in the parent once and in the child table 3 times? I'm not sure if this is how databases would normally store this information or not.

    timothyawiseman,

    I'm not following what you are meaning by your statement of:

    "The obvious answer if you are storing the dimensions for arbitrary quadrilaterals is to have each side numbered clockwise from the smallest and then store the value in a smallint. "

    How would I get the size of material from the number of sides?

    Thanks again.

  • Quadrilaterals always have four sides, so your table would never need more than four columns to completely describe each side, and by having some standard way of numbering them you could ensure that a given piece is always numbered and described in the same way.

    Now, if you need something to describe an arbitrary polygon then things are more complicated, and it depends on what you need to do how you would do it. One option is to simply use a varchar field and describe it in text. Another option is to use one column per side. For instance, your table could look like :

    Create Table Polygon

    ( ShapeNum smallint;

    SideNum smallint;

    length numbers

    )

    This gives each side its own column that are tied together by the shape number and will permit any number of sides for a given shape.

    ---
    Timothy A Wiseman
    SQL Blog: http://timothyawiseman.wordpress.com/

  • You're right, it's not a quadrilateral, it would be a polygon.

    Your solution sounds like it would be the best. I think that I will set up a parent table with the shape number, a child table as you showed, and number the sides clockwise as you suggested.

    Thanks again.

  • To describe an arbitrary polygon, you will also need to include information about the angles between the sides in order to exactly define the shape.

    There can be polygons with the same length sides with different shapes and areas. For example, a shape with sides of 6, 6, 2, and 2 can describe two different polygons.

  • Michael, thanks for the reply.

    Whey they cut the material, it is always cut in right angels. So I believe I will have everything that I will need with just the length of the sides.

  • J Sitz (2/3/2008)


    Michael, thanks for the reply.

    Whey they cut the material, it is always cut in right angels. So I believe I will have everything that I will need with just the length of the sides.

    Unless there are additional constraints that you haven't mentioned, it is still possible to have shapes with only right angles and the same length for all sides that are different.

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply