How important are lookup tables?

The answer depends a little if you are limited to freeware such as PostGreSQL (not fully SQL compliant), or if you are thinking about SQL (ie. SQL compliant) and large databases. In SQL compliant, Open Architecture databases, where there are many apps using one database, and many users using different report tools (not just the … Read more

Is this a good way to model address information in a relational database?

I actually use this as one of my interview questions. The following is a good place to start: Addresses ——— AddressId (PK) Street1 … (etc) and AddressTypes ———— AddressTypeId AddressTypeName and UserAddresses (substitute “Company”, “Account”, whatever for Users) ————- UserId AddressTypeId AddressId This way, your addresses are totally unaware of how they are being used, … 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

PostgreSQL – set a default cell value according to another cell value

This is not possible with a simple DEFAULT value, as the manual clearly states: The value is any variable-free expression (subqueries and cross-references to other columns in the current table are not allowed). You could use a trigger instead: CREATE OR REPLACE FUNCTION trg_foo_b_default() RETURNS trigger LANGUAGE plpgsql AS $func$ BEGIN — For just a … Read more

Relational Data Model for Double-Entry Accounting

A. Preliminary Your Approach First and foremost, I must commend your attitude. It is rare to find someone who not only thinks and works from a solid grounding, and who wishes to understand and implement a Double-Entry Accounting system, instead of: either not implementing DEA, thus suffering multiple re-writes, and pain at each increment, each … Read more

Should OLAP databases be denormalized for read performance? [closed]

Mythology I always thought that databases should be denormalized for reading, as it is done for OLAP database design, and not exaggerated much further 3NF for OLTP design. There’s a myth to that effect. In the Relational Database context, I have re-implemented six very large so-called “de-normalised” “databases”; and executed over eighty assignments correcting problems … Read more