Computing.Net > Forums > Database > Using letters in primary keys

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Using letters in primary keys

Reply to Message Icon

Name: chris_dee
Date: August 2, 2008 at 10:41:33 Pacific
OS: Windows XP
CPU/Ram: AMD Athlon 3500+ / 2GB RA
Product: Custom Build
Comment:

Hello,

I am wanting to create a database to store my whole music collection using MySQL.

My music collection includes music on different mediums such as vinyl and CD.

The idea is to have a record of each item of music in the databse and generate a unique ID for each item and then put this ID onto a sticker which then goes onto the actual sleeve of the music item. Then the music item will go on to a shelve in the order of the unique ID in ascending order.

My initial idea was to have all of the music items in one table (i.e a mix of mediums).

However, if i do this then, for example the first 5 records in the database could be vinyl with unique IDs of 1,2,3,4 and 5. Then if I added say 3 CDs then these IDs would be 6,7 and 8. If i added another 3 vinyl at this point then the IDs of these would be 9, 10 and 11.

Now for the fussy bit. As i said, i want to be able to store these on a shelve, one shelve for vinyl and another for CDs.

My problem now is that when i put my vinyl on the shelve, putting them in order of their IDs in ascending order, it will appear like this:

1,2,3,4,5,9,10,11

As you can see, as they are all in the same table, the IDs of the vinyl on the shelve jump from 5 to 9.

I dont want this. I want it to be continuous so that they are easier to find.

I know this may seem to be really fussy, but that is the way i would like it to be.

My idea is to generate a unique ID for each music item depending on what medium the music is. For example if i added a CD and a vinyl to the database it would generate something like; CD102 FOR A CD and VNL201 for a vinyl.

Then if i was to add another CD and vinyl the IDs would be CD103 FOR A CD and VNL202 for vinyl.

I am not sure if this is actually possible but would like to at least find out.

I could do it using a table for each type of medium. But I would really like to keep all of the music items in the one table if i can.

Hope someone can help.

Thanks




Sponsored Link
Ads by Google

Response Number 1
Name: FishMonger
Date: August 2, 2008 at 17:05:49 Pacific
Reply:

Before you decide on using a single table, you should readup on "Database Normalization"

http://en.wikipedia.org/wiki/Databa...

http://dev.mysql.com/tech-resources...


0

Response Number 2
Name: wizard-fred
Date: August 4, 2008 at 00:11:45 Pacific
Reply:

If you keep the type in another table you can have a table that has all the items.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Database Forum Home


Sponsored links

Ads by Google


Results for: Using letters in primary keys

Primary Key www.computing.net/answers/dbase/primary-key/82.html

Auto fill in data in access 2007 www.computing.net/answers/dbase/auto-fill-in-data-in-access-2007/505.html

Deleting Duplicates in MS Access www.computing.net/answers/dbase/deleting-duplicates-in-ms-access/280.html