Classless tables possible with Datamapper?

Posted by barerd on Programmers See other posts from Programmers or by barerd
Published on 2012-10-19T22:04:33Z Indexed on 2012/10/19 23:19 UTC
Read the original article Hit count: 184

Filed under:
|
|

I have an Item class with the following attributes:

itemId,name,weight,volume,price,required_skills,required_items.

Since the last two attributes are going to be multivalued, I removed them and create new schemes like:

itemID,required_skill (itemID is foreign key, itemID and required_skill is primary key.)

Now, I'm confused how to create/use this new table. Here are the options that came to my mind:

1) The relationship between Items and Required_skills is one-to-many, so I may create a RequiredSkill class, which belongs_to Item, which in turn has n RequiredSkills. Then I can do Item.get(1).requiredskills. This sounds most logical to me.

2) Since required_skills may well be thought of as constants (since they resemble rules), I may put them into a hash or gdbm database or another sql table and query from there, which I don't prefer.

My question is: is there sth like a modelless table in datamapper, where datamapper is responsible from the creation and integrity of the table and allows me to query it in datamapper way, but does not require a class, like I may do it in sql?

© Programmers or respective owner

Related posts about ruby

Related posts about database-design