Hi Gilles,

> 1. what happens if I leave out "PRIMARY KEY" and just use INTEGER?

Um, then it won't be a primary key.

Integer just means a whole number. Primary key means that the database  
will treat that column as the unique identifier for each row. In  
actuality this means that SQLite will treat it the same as the  
"unique" constraint, but you can only have one primary key per table.  
A primary key can be an integer or text column (or presumable real or  
other type too). It's not integer only. If you designate an integer  
column as also being the primary key, then SQLite will auto assign its  
value incrementally each time you insert a new row, unless you assign  
a value explicitly.

See:  http://www.sqlite.org/lang_createtable.html

such as:

>> Specifying a PRIMARY KEY normally just creates a UNIQUE index on  
>> the corresponding columns. However, if primary key is on a single  
>> column that has datatype INTEGER, then that column is used  
>> internally as the actual key of the B-Tree for the table. This  
>> means that the column may only hold unique integer values.


>> If a table does not have an INTEGER PRIMARY KEY column, then the B- 
>> Tree key will be a automatically generated integer. The B-Tree key  
>> for a row can always be accessed using one of the special names  
>> "ROWID", "OID", or "_ROWID_". This is true regardless of whether or  
>> not there is an INTEGER PRIMARY KEY.


> 2. I prefer to use text to save dates and times because they're  
> easier to handle between SQLite and PHP than Julian, but does SQLite  
> handle text dates/times OK, or should I expect problems?

I wouldn't expect any problems using dates in the YYYY-MM-DD format.  
But Julian (real) format is the preferred method and uses less memory  
(less bytes) and I suspect is quicker to process. You can easily store  
as julian but pass to PHP as text by using the date function:

select date(myJulianDate)

or to convert from absolute to localtime:

select date(myJulianDate, 'localtime')

either by creating a view in SQLite (and having PHP reference it) or  
else using directly from PHP.

See: http://www.sqlite.org/cvstrac/wiki?p=DateAndTimeFunctions

Tom
BareFeet

  --
Huge range of Mac and other computer accessories, in Australia
http://www.tandb.com.au/forsale/?ml

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

Reply via email to