Why use an auto-incrementing primary key when other unique fields exist?

Auto-incrementing primary keys are useful for several reasons: They allow duplicate user names as on Stack Overflow They allow the user name (or email address, if that’s used to login) to be changed (easily) Selects, joins and inserts are faster than varchar primary keys as its much faster to maintain a numeric index As you … Read more

Convert JSON to SQLite in Python – How to map json keys to database columns properly?

You have this python code: c.execute(“insert into medicoes values(?,?,?,?,?,?,?)” % keys) which I think should be c.execute(“insert into medicoes values (?,?,?,?,?,?,?)”, keys) since the % operator expects the string to its left to contain formatting codes. Now all you need to make this work is for keys to be a tuple (or list) containing the … Read more

How many significant digits should I store in my database for a GPS coordinate?

WGS84 datum are usually given as coordinates in a fully decimal notation, usually with 5 decimal places, so for latitude (-90 to +90) you could use decimal(7, 5) (-90.00000 to 90.00000), for longitude you could use decimal(8, 5) (-180.00000 to 180.00000). .00001 gives an precision of around a meter at the equator The DECIMAL/NUMERIC data … Read more

Why does no database fully support ANSI or ISO SQL standards?

In the software industry you have some standards that are really standards, i.e., products that don’t comply with them just don’t work. File specifications fall into that category. But then you also have “standards” that are more like guidelines: they may defined as standards with point-by-point definitions, but routinely implemented only partially or with significant … Read more