Results 1 to 11 of 11
  1. #1
    Join Date
    Feb 2004
    Posts
    134

    Unanswered: Shape table (s), how do I set this up?

    I need to all a user to create and store cross sections of some shapes. Some shapes can be represented by the following tables.

    Code:
    tbRectangular
    Entry | SectionName | Width | Height
    
    tbDoubleTee
    Entry | SectionName | Width | Height | Flang | Legs
    
    tbTSection
    Entry | SectionName | X1 | Y1 | X2 | Y2
    
    tbISection
    Entry | SectionName | X1 | Y1 | X2 | Y2 | X3 | Y3
    
    tbCircular
    Entry | SectionName | Diamter
    I have posted a similar question here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=33396.

    Are there any thoughts on ways this should be done?

    Mike B

  2. #2
    Join Date
    Feb 2004
    Posts
    134
    Is this really that strange of a scenerio? Basically, all I want to do is create a solid and expandable structure that would allow the user to create section templates. What I have so far is:


    Code:
    tbShapes
    Shape | ShapeName    | TableName
    1     | Rectangular  | tbRectangular
    2     | Double T     | tbDoubleTee
    3     | Flat Panel   | tbFlatPanel
    
    tbRectangular
    Entity | SectionName | X | Y
    
    tbDoubleTee
    Entity | SectionName | Width | Height | Flange | Legs
    
    tbTSection
    Entity | SectionName | X1 | Y1 | X2 | Y2
    The above is one approach that I can think of but it is probably not recommended. Reason being that if you need to add a new shape, well that means a new table has to be created. Functions have to be created etc....

    Any thoughts on How I can do the above differently?

    How about:
    Code:
    tbShape
    Shape (PK) | ShapeName
    -------------------------------
    1                | 24" X 24" Column
    
    tbShapeProperties
    Property | Shape(FK) | PropertyName |PropertyValue
    --------------------------------------------------------------
    1            | 1              | Width             | 24 
    2            | 1              | Height            | 24
    There just doesn't seem to be any control with the above for formulas

    Mike B

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    If you expect to be able to apply formulas to this data, then you are going to need to store different shapes in different tables.

    If you are adept at recursive table design, then you may benefit from storing all shapes as either triangles or the sum of triangular components.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  4. #4
    Join Date
    Feb 2004
    Posts
    134
    [SIZE=1]Originally posted by blindman
    If you expect to be able to apply formulas to this data, then you are going to need to store different shapes in different tables.
    Interesting comment, I was thinking about that through the whole night. Would you say the table structure I have shown above is the right way to go? Is having the table pointing to the table the right way? How could I have the user add his own section tables?

    Mike B

  5. #5
    Join Date
    Feb 2004
    Posts
    134
    [QUOTE][SIZE=1][i]
    Code:
    tbShapes
    Shape | ShapeName    | TableName
    1     | Rectangular  | tbRectangular
    2     | Double T     | tbDoubleTee
    3     | Flat Panel   | tbFlatPanel
    
    tbRectangular
    Entity | SectionName | X | Y
    
    tbDoubleTee
    Entity | SectionName | Width | Height | Flange | Legs
    
    tbTSection
    Entity | SectionName | X1 | Y1 | X2 | Y2
    Here is my solution so far. I have used the above table strucutre and included a stored proc that will return an empty recordset for the selected table:
    Code:
    CREATE PROCEDURE usp_GetShapePrompts
    
    @cTableName varchar(255)
    
    AS
    
    EXEC('SELECT *
                 FROM ' + @cTableName + '
                 WHERE Entry IS NULL')
    GO
    I called this GetShapePrompts because this is called from within the application (Front End written in C++). I get all the field names from this empty recordset and set up a ListCtrl to match as the user selects different types. This ListCtrl can then take input for each property.

    Any thoughts?

    Mike B

  6. #6
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    A lot depends on why you are storing this data and what it is being used for.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  7. #7
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  8. #8
    Join Date
    Feb 2004
    Posts
    134
    Originally posted by Brett Kaiser
    Cross Post?

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=33396

    I have already referenced it in my first post.

    Mike

  9. #9
    Join Date
    Feb 2004
    Posts
    134
    Originally posted by blindman
    A lot depends on why you are storing this data and what it is being used for.
    For estimating product for a precast concrete manufacturing company. Values such as concrete costs are calculated by cu.m but the estimating department wants to enter the product in linear or square mesurements, so to figure out the rest I would need the cross sectional area of the product which would fit into the generic shapes. The would select a product which would link to a specific shape. The application would prompt for the required values, width, height, etc... and set this as a template. They would enter so many square feet/linear feet of prodcut and the application would figure out the rest...

    Mike B

  10. #10
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Then I think the most robust solution would be to store complex shapes as the sum of a collection of basic shapes (rectangular blocks, triangular blocks, and cylinders for example). Even then a genral solution for all possible shapes will be very difficult. What about vertical trapezoids, semi-circles, and other curves?

    Are you planning to use this to spec out costs? If you get it to work, more power to you, but I'd recommend you reconsider the scope of your project and store only the precalculated volume. I mean, aren't there CAD programs available that will do this for you?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  11. #11
    Join Date
    Feb 2004
    Posts
    134
    [SIZE=1]Originally posted by blindman
    Even then a genral solution for all possible shapes will be very difficult. What about vertical trapezoids, semi-circles, and other curves?
    This would have been handled by having a Special shape where no properties but the cross section would have be request from the user by the application.

    The more I think about this and see from this posting and other postings on the linked cross post, this is far too difficult of a problem to solve in any short amount of time. Maybe having the table structure I have shown where each shape was represented by a table isn't such a bad solution. After all, if a new shape was added, that would mean manually adding a new shape table, functions as required to figure out volume, and a reference to that table in the Shapes table. Probably no more then half a days work, where as trying to do this dynamically now seems to be overkill.

    Mike B

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •