Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Storing an ordered list, then modifying the order.

gcnetworkgcnetwork Member Posts: 1
I'm making a database that has to store user details (table: users), item details (table:items) and i need to allow each user to choose up to 100 items each.

I could make a table that references user_id and item_id, but i have another requirement. Each user needs to be able to change the order of the items on their list, not alphabetically or by date added, but any order they wish.

At first i though of adding a 'position' field, but things get messy when the user wants to move items around because every change would require two queries, and if for any reason one query didn't happen, the db would be broken.

Any ideas guys? I'd appreciate any input you can give me.

Garry

Comments

  • JonathanJonathan Member Posts: 2,914
    : I'm making a database that has to store user details (table: users),
    : item details (table:items) and i need to allow each user to choose
    : up to 100 items each.
    :
    : I could make a table that references user_id and item_id, but i have
    : another requirement. Each user needs to be able to change the order
    : of the items on their list, not alphabetically or by date added, but
    : any order they wish.
    :
    : At first i though of adding a 'position' field, but things get messy
    : when the user wants to move items around because every change would
    : require two queries, and if for any reason one query didn't happen,
    : the db would be broken.
    I'm still looking for a really good way to do this, but the position field is currently the best I have too. It's not all that bad if one UPDATE query doesn't fire anyway; if you're doing an ORDER BY position in the SELECT query then the data will still come out, maybe just not as intended, but it's still easily fixable through your admin UI I'd guess.

    : Any ideas guys? I'd appreciate any input you can give me.
    Linked lists crossed my mind, but when I thought about the implications they moved out again pretty quick. I'll think it over some more 'cus I seek a good solution to this one too.

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.