#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    1
    Rep Power
    0

    Question Concatonated autonumbers as primary key for relational database.


    Hello,

    I know I may be about to ask a cardinal sin of requests however bare with me

    I currently have a list of users stored in a table and each of these users can have multiple logs associated with them which all populate in another table using a log id as a primary key and the user id as the entity link.

    I use a computed column to concatenate the two together.
    E.g. So the concatenated logs look like

    S/000006-1
    S/000009-2
    S/000010-3
    S/000009-4
    S/000010-5
    S/000006-6
    S/000006-7 Etc...

    I would like to make a concatenated User-Log ID the primary key, and have the auto-increment reset dependant on the user id. So for example the table would actually look like this...

    S/000006-1
    S/000009-1
    S/000010-1
    S/000009-2
    S/000010-2
    S/000006-2
    S/000006-3 Etc...

    Is this possible or am I barking in the wrong park at the wrong tree?

    Regards,
    Josh
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,026
    Rep Power
    4210
    autonumbers subordinate to another column is supported by myisam tables (mysql) but not by sql server


    by the way...

    bear with me = have patience
    bare with me = let's get undressed together

    r937.com | rudy.ca
    please visit Simply SQL and buy my book

IMN logo majestic logo threadwatch logo seochat tools logo