I've been thinking on how to store data efficiently in database tables, I'll give the examples in visual look. See pictures below.

I've come to think to store data in database using compressed values row with the thinking of to save a lot of rows to remove duplicate page_id's

enter image description here

The other one is the usual that I've seen, I separate row_id's per page_id's.

enter image description here

The one I'm concerned is, which is the best way or am I doing it wrong on my first way storing data.


1 Answer 1


Definitely, in a Relational Data Management System, you SHOULD use relationships between your entities.

A simple example query where you will be stuck by using the first option :

Select all users and role name with roles 1 or 11

You will have to perform character to character searches and comparisons that are much less efficient than relational integer search and comparisons beacause the latter are indexed, and algorithms to perform them are much more sophisticated than pure string compare.

Unless you are really constrained (and even if so I would say...) use table relations, referential integrity constraints, indexes and so on, they will save your time !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.