Whats is efficient database design in sqlite when I only need to insert and retrieve smallest entry in an integer column?
Basically I need a min-heap functionality with sqlite as my data storage. Lets say I need a table with 2 columns. 1st is unique ids and 2nd is integer value. I always need the the id with smallest integer value.
Any suggestions ??
You get that for free on indexed columns
CREATE TABLE table( one INTEGER PRIMARY KEY, two INTEGER ); CREATE INDEX table_two ON table(two); INSERT ... SELECT MIN(two) FROM table;