Fórum

Suggesting an idea: Use a jsonData text column for custom fields

thumbnail
Robert Chen, modificado 7 Anos atrás.

Suggesting an idea: Use a jsonData text column for custom fields

New Member Postagens: 19 Data de Entrada: 24/01/12 Postagens Recentes
The expando tables for configurable custom fields for user, page and organizaiton models are great. However, in my work experience, it is not easy to code for retrieving the custom field values. Also the performance to retrieve those values is not very good.

I would recommend adding a jsonData text column for the user_, layout and organization tables (instead of the expando tables). This field can store a JSON string as follows:

{
"numericProperty": 3,
"stringProperty": "stringOne",
"nullProperty": null,
"booleanProperty": true
}

The developer can then write a POJO class to retrieve the values of the custom fields in this JSON string.

Pros:
(1) Simple (easy for development)
(2) Scalable (like a mini-MongoDB database)
(3) Good performance

Cons:
(1) It is not convenient to search in this jsonData field.

I would post it here for your comments.
thumbnail
David H Nebinger, modificado 7 Anos atrás.

RE: Suggesting an idea: Use a jsonData text column for custom fields

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
The problem is the query - how do you find users with stringProperty = stringTwo? You also can't define an index on this kind of column.

The expandos apply to pretty much all Liferay entities. As frameworks go, it provides a consistent interface to expand any liferay entity without actually touching the liferay entities themselves.

The expando tables may be over-normalized, but it does support creating queries to join user against the expandos to match on specific values. Indexes on the expando values simplify search, both from a database perspective as well as from a lucene/solr/elastic perspective.

And I would argue w/ the good performance pro. It may be easier for adds/updates, but 9 times out of 10 you're going to be reading data from the database. You're going to be querying, you're going to be retrieving, and you're going to be indexing. A single json string column is going to be a penalty for you here.

Say for my json column I have favoriteFood and foodAllergy attributes but I want to find every user with a nut allergy. You cannot form a generic SQL query that would select all users that have "nut" in the foodAllergy item but not those that have "nut" as favoriteFood.

But I can handle this easily using expandos.

And remember one of the project rules - we don't care about developer pain. Seriously, if it takes a developer 4 hours for a json column or 8 hours for expandos, who cares? The only thing that matters is that we deliver the correct results. So the expandos might be the more involved development effort, but it will lead to correct results.
thumbnail
Robert Chen, modificado 7 Anos atrás.

RE: Suggesting an idea: Use a jsonData text column for custom fields

New Member Postagens: 19 Data de Entrada: 24/01/12 Postagens Recentes
Thank you, David, for your comments.

I am using this idea on a project. Let me see how it works. I believe that this hybrid idea has some value, at least for the near future.
thumbnail
Olaf Kock, modificado 7 Anos atrás.

RE: Suggesting an idea: Use a jsonData text column for custom fields

Liferay Legend Postagens: 6403 Data de Entrada: 23/09/08 Postagens Recentes
Robert Chen:
I am using this idea on a project. Let me see how it works. I believe that this hybrid idea has some value, at least for the near future.


I do remember that someone some time implemented a proof-of-concept implementation of Expandos in a NoSQL database. It's a long time ago though, and I don't remember who it was - however, it's definitely possible. That being said, there are reasons for as well as against every possible implementation of this feature.
thumbnail
Jorge Díaz, modificado 7 Anos atrás.

RE: Suggesting an idea: Use a jsonData text column for custom fields

Liferay Master Postagens: 753 Data de Entrada: 09/01/14 Postagens Recentes
Olaf Kock:
I do remember that someone some time implemented a proof-of-concept implementation of Expandos in a NoSQL database. It's a long time ago though, and I don't remember who it was - however, it's definitely possible.

It was implemented by Ray, see:

Marketplace App is only available for 6.1 and 6.2 versions