home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sun-barr!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!bu.edu!dartvax!kip-sn-49.dartmouth.edu!user
- From: carl.pedersen@dartmouth.edu (L. Carl Pedersen)
- Newsgroups: comp.databases.theory
- Subject: Re: ordered collections
- Message-ID: <carl.pedersen-110992103841@kip-sn-49.dartmouth.edu>
- Date: 11 Sep 92 14:51:22 GMT
- References: <cdk.715362552@neptune> <DAVIDM.92Sep2112813@consilium.com> <cdk.716057364@neptune>
- Sender: news@dartvax.dartmouth.edu (The News Manager)
- Followup-To: comp.databases.theory
- Organization: Dartmouth College
- Lines: 42
-
- On 1 Sep 92 15:49:12 GMT, cdk@neptune.dsc.com (Colin Kelley) said:
- >
- > Is there a standard way to implement ordered collections in a relational
- > database that would allow for random insertion? You could always have a
- > sequence number field to remember the ordering, but if you want random
- > insertion, you may run out of bits in this sequence number and not be able
- > to insert a new entry between two others.
-
- I'm embarrased to say that Masterson's solution fooled me. I thought the
- only
- problem with it was that you couldn't do a bunch of inserts at the same
- time -
- something I often need to do.
-
- My solution to this is just as you imply: A floating point sequence
- number. New records get assigned a sequence # between the adjacent two. I
- tell my DBMS to require this key to be unique, so it blows up if I run out
- of bits. In one version of this, I occasionally renumbered - which isn't
- *too* hard using ORACLE.
-
- I suppose this is the "standard" technique, but it's ugly and not fully
- general.
-
- Aside from the fact that current systems don't seem to have a solution for
- this, I'm not sure there *is* a good solution that is really general and
- performs well.
-
- You need to be able to insert between this row and that row. How do you
- specify which row? Primary key? What if there is no natural primary key?
- OK, so you put it between the 4th and the 5th one already there, but now
- you have changed the ordinal positions of all subsequent records. Is that
- OK? Maybe. It's hard to see, though, how this could be efficient for
- large collections.
-
- It's easy enough to come up with a scheme for inserting efficiently, and
- finding the next record. You could just have a link to the next record,
- based on unique record id - physical address if nothing else. The problem,
- I think, is *specifying* which record you mean. If the only way to say is
- something like, "Put this after the millionth record", we have a problem.
-
- Maybe this just doesn't come up for collections that large. So far, all of
- my applications involve only a few hundred records.
-