S
Saso Zagoranski
Hi,
I'm making a simple application which will store different items (in a SQL
server 2000 - MSDE database).
Each item has a unique ID in this form:
[max 2 characters][max 5 characters] / [max 4 characters] / [max 1
character] / [max 1 character]
an example:
AZ12345/1234/1/A
or
A 5/1/1/G
My question is, what would be the best way to store this in the database. A
way that I wou
Have a column for each part of this ID? Or store the entire string in one
column?
Here are my thougts on both of these options:
Option A (column for each part)
GOOD:
- easy sorting. If I wanted to sort by column2 I would just add "ORDER BY
column2"
BAD:
- All columns put together form a unique id. But sometimes some columns can
be NULL. And I'm
not allowed to do that if I make all columns Primary Keys (so they will be
Foreign Keys in related tables)
- it's not very practical passing 5 strings in the application
Option B(entire string in one column)
GOOD
- only one string in the application
- only one column
BAD
- sorting. I have to use substrings for sorting.
- sorting: e.g. sometimes column2 will be only 2 characters long, sometimes
5. So again,
problems with substrings
These are just my ideas... Please advise me on this one
thanks,
saso
I'm making a simple application which will store different items (in a SQL
server 2000 - MSDE database).
Each item has a unique ID in this form:
[max 2 characters][max 5 characters] / [max 4 characters] / [max 1
character] / [max 1 character]
an example:
AZ12345/1234/1/A
or
A 5/1/1/G
My question is, what would be the best way to store this in the database. A
way that I wou
Have a column for each part of this ID? Or store the entire string in one
column?
Here are my thougts on both of these options:
Option A (column for each part)
GOOD:
- easy sorting. If I wanted to sort by column2 I would just add "ORDER BY
column2"
BAD:
- All columns put together form a unique id. But sometimes some columns can
be NULL. And I'm
not allowed to do that if I make all columns Primary Keys (so they will be
Foreign Keys in related tables)
- it's not very practical passing 5 strings in the application

Option B(entire string in one column)
GOOD
- only one string in the application
- only one column
BAD
- sorting. I have to use substrings for sorting.
- sorting: e.g. sometimes column2 will be only 2 characters long, sometimes
5. So again,
problems with substrings
These are just my ideas... Please advise me on this one
thanks,
saso