Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

share|improve this question
up vote 7 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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