luis.ap.uyen
luis.ap.uyen

Reputation: 1364

Tinyint vs varchar to identify types of entities

We're going to use a table to include sort of different entities which have most fields in common (i.e. "order", "invoice", "estimate", "dispatch"...). We decided to have them all in the same table for some reasons, but this is not the question.

This table will have a special field which will hold the identifier of the entity. We've been using varchars in the past, like the ones described above.

Would it be recommendable to use a tinyint instead, so that 0 means "order", 1 means "estimate" and so on?

Upvotes: 0

Views: 270

Answers (1)

davejal
davejal

Reputation: 6133

Depending on what your goal is.

For performance:

  1. tinyint uses less space, so it would be better if you wanted to save space
  2. queries could become faster

For readability (by db users with less experience)

Keep using varchar

Upvotes: 1

Related Questions