1

I need to store some data in the following format:

1.2

1.2.1

1.2.2

1.3

etc..

I highly suspect that I must use varchar for this, but my guy says that it's still some kind of int. It's for a catalogue hierarchy system.

Google is leading me no where.. Anyone done this before?

1
  • 1
    a wild guess, you are sorting on this column? Commented Mar 6, 2012 at 19:19

3 Answers 3

2

I don't think there is a numeric format that works for these.

Abusing a DECIMAL won't lead anywhere, as you won't be able to tell apart 1.2.11 and 12.1.1.

I would store them in a VARCHAR.

Sign up to request clarification or add additional context in comments.

Comments

0

If you need to store "1.2.2" then its a string. If you had a table of "IDs" where you could have "itemID" and "ParentID" then you could do it with integers as then the Uid, for 1.2 could be the number 23, ergo would be integers, but it doesnt save you as you would then need recursive to find the full path.

Comments

0

When you have many of this numbers and set of numbers can be long, you can use some dictionary in other table to handle it, and carry only pointer.

But i think too VARCHAR is optimal when you DONT WANT search over this numbers eg. where second number is 13, then my solution is better.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.