represent organization relational database
i have collection objects database. images imitation gallery, products catalog, chapters book, etc. any vigilant represented row. i wish means arbitrarily method images, storing organization database i arrangement objects, right order.
for example, let's contend i'm minute book, any section an object. i book, put chapters following order:
introduction, accessibility, form vs. function, errors, consistency, conclusion, index
it goes editor, comes behind following suggested order:
introduction, form, function, accessibility, consistency, errors, conclusion, index
how i store organization database robust, fit way?
i've following ideas, nonetheless i'm anxious any them:
array. any quarrel an organization id, method altered (via dismissal followed an insertion), method ids updated. creates retrieval easy, given it's only
order by, nonetheless seems easy break.
// removal
update ... set orderingid=null where orderingid=removedid
update ... set orderingid=orderingid-1 where orderingid > removedid
// insertion
update ... set orderingid=orderingid+1 where orderingid > insertionid
update ... set orderid=insertionid where id=addedidlinked list. any quarrel buttress id unbroken quarrel ordering. traversal seems dear here, nonetheless there competence proceed
order byi'm pondering of.spaced array. set orderingid (as used #1) large, initial vigilant 100, second 200, etc. following an insertion happens, only place during
(objectbefore + objectafter)/2. course, need rebalanced occasionally, don't have things too tie together (even floats, you'd eventually run rounding errors).
none seem quite glorious me. does anyone have improved proceed it?
Comments
Post a Comment