Part of the problem is going to be that you have not defined the problem 
sufficiently for a "solution" to be proposed.  Based on your somewhat silly 
example one can deduce the following constraints:

With respect to "key":
 - this is TEXT (UTF-8 or something else)?
 - you specify check(length(key)) == 1  do you mean:
   - one character in some encoding (key between 0 and 0xffffffffffffffff)
   - one byte? (ie, ord(key) between 0 and 255)
   - something else entirely?
   - is it contiguous?
   - if not contiguous what are the rules defining the non-contiguousness?
 
 - what is the "rotation order" based on?
   - next arithmetic value, upper wraps to lower?
   - next used key (by some collation order?  Which collation order?)
   - based on "used" values?
   - based on "entire domain"?

The problem and its solution is rather simple, once you define problem to be 
solved with sufficient specificity to permit a solution.  

Your "example" below does not provide sufficient referents to generate a 
solution that is cohesive over any problem domain other than that covered by 
the example, and your referential constraints are inadequate to ensure 
integrity for your limited example.

Your example could be used to generate a solution set if and only if you 
changed the constraints such that:

  check(key) between '1' and '5'
and
  count(key) must be 5 (ie, there must be five records comprising exactly each 
key once).

Otherwise there is insufficient information to formulate a solution.

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.


>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of Cecil Westerhof
>Sent: Monday, 22 January, 2018 13:30
>To: SQLite mailing list
>Subject: [sqlite] Can this be done with SQLite
>
>I have the following table:
>CREATE TABLE playYouTubeVideo (
>    key     TEXT    NOT NULL,
>    speed   FLOAT   NOT NULL,
>
>    CONSTRAINT key   CHECK(length(key)  == 1),
>    CONSTRAINT speed CHECK(TYPEOF(speed) = "real"),
>
>    PRIMARY KEY(key)
>);
>
>
>Say I want to rotate a part:
>- The value by key '1' becomes the value by key '2'.
>​- The value by key '2' becomes the value by key '3'.
>​- The value by key '3' becomes the value by key '4'.
>- The value by key '4' becomes the value by key '5'.
>- The value by key '5' becomes the value by key '6'.
>
>​I suppose that I need to do this programmatically, or can this be
>done
>with SQL?
>
>And optionally also:
>​- The value by key '1' becomes the value by key '5'.
>​
>--
>Cecil Westerhof
>_______________________________________________
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to