DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on

How does database indexing of Arrays work?

This is without doubt, one of the reasons I chose NoSQL, e.g. MongoDB; but can it apply to RDBMS? Will it be simple / intuitive to maintain?

Usually one-to-many relationships, right? But I believe, 1. no relationship might be faster than one relationship; 2. what about maintenance and readability?

This only apply to easily indexable arrays, like Number or String, though.

Discussion (3)

Collapse
camdenclark profile image
Camden Clark

Not clear what you mean by this. Are you asking how arrays as column values in relational databases are indexed? I think it depends on the specific relational database and what types of queries it supports on array values.

Collapse
patarapolw profile image
Pacharapol Withayasakpunt Author • Edited

I think the answer is usually one-to-many relationships.

However, I am not sure if JSON or JSONB columns in PostGRES can be indexed. (That is, no Foreign keys needed.)

Collapse
patarapolw profile image
Pacharapol Withayasakpunt Author

The answer for MongoDB is discussed in this link.

qr.ae/pNsEOb