Relationship of products in models and bank

0

I'll try to be brief in my doubt.

How can I model a class scheme that suits me in some things: This is all going to be done in rails 4.1, using ActiveRecord as ORM acting on MySQL.

I will have a Person entity that will have a reference (object), for my model of Product , that is, none or many products, this will be the repository of the company, ie all clients will have a unique registry that when logged in, check the products available to that user, which marries several products with different properties related to a product.

As for example:

Product A will have the attributes:

  • color
  • size
  • weight

Product B will have the attributes:

  • timeout
  • SerialNumber

The question is, how can I model this data abstraction?

I've been thinking, that with each new product we develop we'd have to create a new class and add to that project?

resuming again ...

How to create an entity relationship in which each product will have its own attributes? and that a user might have multiple products?

It's all the same doubt, if it was not clear please ask me to edit the question! Thank you in advance!

    
asked by anonymous 02.07.2014 / 04:47

1 answer

1

I think a possible solution would be to create a table of product attributes.

Pessoas
-id
-nome

Produtos
-id
-pessoa_id
-nome

Atributos
-id
-produto_id
-nome
-valor

Where the name of the attribute can be, for example, color and the value white .

    
02.07.2014 / 13:40