jasongr
10-05-2007, 01:11 PM
Hi People
I have a dilemma regarding the correct way I should allocate IDs for a new table I am designing.
The table holds information on folders that users can open in the system.
The following information is saved on each folder:
*) Folder ID
*) User ID (The ID of the user who created the folder
*) Name of the folder
... Possibly more data can be added later on
I am wondering what should be the best way to allocate IDs to the folders.
The primary key in the table is (Folder ID, User ID).
Each user can create as many folders as she wants.
When a user creates a folder, I need to add a new record to the table, and I am not sure how to allocate the ID for the folder.
I can use auto_increment for the folder ID, but would mean that if User X creates his first folder,
then the folder ID will be some number that MySQL will allocate and not the number 1.
What I WOULD like to do is to have MySQL treat the folder ID with auto_increment attributes within the user ID value.
So The first folder that each user will create will get the ID 1, the second 2 and so on.
Is this possible?
If not, what would be the best way to achieve what I want without running into duplication problems
(that I know auto_increment solves)
Thanks in advance for any help
Regards
Jason
I have a dilemma regarding the correct way I should allocate IDs for a new table I am designing.
The table holds information on folders that users can open in the system.
The following information is saved on each folder:
*) Folder ID
*) User ID (The ID of the user who created the folder
*) Name of the folder
... Possibly more data can be added later on
I am wondering what should be the best way to allocate IDs to the folders.
The primary key in the table is (Folder ID, User ID).
Each user can create as many folders as she wants.
When a user creates a folder, I need to add a new record to the table, and I am not sure how to allocate the ID for the folder.
I can use auto_increment for the folder ID, but would mean that if User X creates his first folder,
then the folder ID will be some number that MySQL will allocate and not the number 1.
What I WOULD like to do is to have MySQL treat the folder ID with auto_increment attributes within the user ID value.
So The first folder that each user will create will get the ID 1, the second 2 and so on.
Is this possible?
If not, what would be the best way to achieve what I want without running into duplication problems
(that I know auto_increment solves)
Thanks in advance for any help
Regards
Jason