> Shouldn't ticks be stored as a bigint?
I was under the impression that INT, BIG INT et al were all just
stored in the same way by sqlite. This paragraph in the docs is
somewhat ambiguous though:
"Note that a storage class is slightly more general than a datatype.
The INTEGER storage class, for example, includes 6 different integer
datatypes of different lengths. This makes a difference on disk. But
as soon as INTEGER values are read off of disk and into memory for
processing, they are converted to the most general datatype (8-byte
signed integer). And so for the most part, "storage class" is
indistinguishable from "datatype" and the two terms can be used
interchangably."
(
http://www.sqlite.org/datatype3.html)
I have stored a tick value in that INTEGER column and read it back
successfully so it must be capable of storing longs like that.
> Though I'd personally prefer to
> store the timestamp in a proper date/time field rather than as an int.
Again, from the docs:
"SQLite does not have a storage class set aside for storing dates and/
or times. Instead, the built-in Date And Time Functions of SQLite are
capable of storing dates and times as TEXT, REAL, or INTEGER values:
TEXT as ISO8601 strings ("YYYY-MM-DD HH:MM:SS.SSS").
REAL as Julian day numbers, the number of days since noon in Greenwich
on November 24, 4714 B.C. according to the proleptic Gregorian
calendar.
INTEGER as Unix Time, the number of seconds since 1970-01-01 00:00:00
UTC.
Applications can chose to store dates and times in any of these
formats and freely convert between formats using the built-in date and
time functions."
I read that as saying a datetime column in sqlite is incapable of
storing tick-precision datetimes. It looks like the most accurate you
can be is millisecond.