Results 1 to 3 of 3

Thread: Polymorphism in SQL database

  1. #1
    Join Date
    Jan 2009
    Posts
    88

    Polymorphism in SQL database

    I find myself faced with a problem that can be summarized as follows:

    I have a class "box" which can contain 0-N "Crafts", "Subject" is a common interface to several other classes, with a single point in common is that they may be in the same box. Box may contain multiple instances of the same class, only one instance of several different classes or a mix of both.

    This does not pose major problems as I manage it in my program, I'm against a little taken when designing the corresponding tables: How to translate this relationship knowing that I can not create a table with FK object_1 , object_2 ... knowing that I can not know how many there will be objects in each box, create a table join box_id => object_id, as each class will have its own table (they all have separate fields).

  2. #2
    Join Date
    May 2008
    Posts
    945

    Re: Polymorphism in SQL database

    Your design object is in what language? Because my impression is that you poses problems solved by all MNOs.

  3. #3
    Join Date
    Jan 2009
    Posts
    88

    Re: Polymorphism in SQL database

    It is in Ruby on Rails web framework. Do you think its the problem of Ruby on Rails design? The least worst that I have found yet is to join a table:

    - Box_id, object_id, class_name, containing for example:

    1, 1, "Shoes"
    1, 2, "Shoes"
    1, 1, "Bicycle"
    ...

    The 1st request is beyond what is in box 1, then there would be a request by families of objects:

    select * from Shoes where id = 1 or id = 2
    select * from Bicycle where id = 1
    ...

    Given that there will not be hundreds of items per box it's still viable, but I must admit that I'm moderately excited about setting up something

Similar Threads

  1. What does polymorphism mean in OOP?
    By Khan Baba in forum Software Development
    Replies: 5
    Last Post: 06-02-2010, 02:14 PM
  2. Runtime polymorphism Vs Compile time polymorphism
    By Owen Fernandes in forum Software Development
    Replies: 4
    Last Post: 03-02-2010, 11:06 AM
  3. Polymorphism VS Inheritance
    By Taylor D in forum Software Development
    Replies: 5
    Last Post: 22-01-2010, 10:12 AM
  4. Is java supports polymorphism?
    By beelow in forum Software Development
    Replies: 3
    Last Post: 19-11-2009, 11:30 AM
  5. Function overloading with polymorphism
    By Mega Member in forum Software Development
    Replies: 3
    Last Post: 02-10-2009, 03:35 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,426,095.43476 seconds with 16 queries