I'm building a sqlite database for an android app which will hold a list of items, each of which have different characteristics.

Some of the characteristics are available for all objects, some are only relevant for a subset of objects.

For example, all my items have a name, a description, an image. Some items will also have an expiration date, others wont. Some will have a size, some wont. Etc...

How should I build my Database, as I don't know how many characteristics may be added in the future, and knowing I should be able to filter the list by any characteristic ?

1 Answer 1


You must consider the particular pressures that apply to your situation and decide based on that. The general truths are:

  • If you put every possible attribute into your definition of 'item' as a field, many items will have redundant fields, which might waste space if you are very constrained on space.
  • Also, introducing a new attribute will require a database schema update rather than just an update of application code.
  • On the other hand, if you put attributes into their own table, you don't have these problems, but you will have to employ a JOIN every time you filter items. This could take longer than retrieving and filtering things from just one table.

Therefore, without knowing more about your situation, we can only tell you that you are looking at a time/space tradeoff, and possibly an ease-of-deployment tradeoff. But only you can know whether which of these considerations has more weight for your concrete project.

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.