Store data in an inconvenient table or create a derived table?

Posted by user1705685 on Stack Overflow See other posts from Stack Overflow or by user1705685
Published on 2012-09-28T08:37:23Z Indexed on 2012/10/12 9:38 UTC
Read the original article Hit count: 176

Filed under:
|

I have a certain predefined database structure that I am stuck with. The question is whether this structure is OK for ORM or I whether should add a processing layer that would create a more convenient structure every time something is inserted into the original DB.

To simplify, here's what it kind of looks like.

I have a person table:

PersonId
Name

And I have a properties table:

PersonId
PropertyType
PropertyValue

So, for person John Doe...

(1, 'John Doe')

...I could have three properties:

(1, 'phone', '555-55-55'),
(1, 'email', '[email protected]),
(1, 'type', 'employee')

By using ORM I would like to get a "person" object that would have properties "name", "phone", "email", "type".

Can Propel do that? How efficient is it? Is it a better idea to create a table with columns "phone", "email", "type" and fill it automatically as new rows are inserted into the properties table?

© Stack Overflow or respective owner

Related posts about php

Related posts about propel