0

I have a table with lots of redundant data.

I'd like to change some of the VARCHAR values to some sort of "AUTO_LOOKUP" data type, that automatically maintains and resolves values from a look-up table.

MySQL does this partially with the ENUM datatype, but it requires ahead-of-time definition of all known values. I would like the list of values to dynamically grow.

Does this exist?

Related questions:

Alex R
  • 11,364
  • 15
  • 100
  • 180

1 Answers1

0

Yes, it's called a foreign key, and it's supported by virtually all relational databases.

You define your set of varchars in a lookup table, with one row per value. Associated with the string is a more compact primary key, typically an auto-increment integer.

Then in your large table, just reference the entry in the lookup table by integer.

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828