Posts

Showing posts with the label database design

OLTP and OLAP

Image
Introduction In Postgres , OLTP and OLAP are two completely different database system design philosophies serving distinct purposes. Postgres itself is an extremely powerful relational database management system (RDBMS). By default, it is highly optimized for OLTP  and thanks to its rich ecosystem of extensions, Postgres can also fully support OLAP workloads. Here is the detailed difference between these two concepts: OLTP Online Transaction Processing : focuses on fast, accurate and secure processing of a large number of continuous financial or operational transactions from end users. Data characteristics: Data changes constantly ( Insert, Update, Delete continuously). Query Pattern : Read/write statements acting on one or a few specific data rows (for example, finding info of a specific customer with WHERE id = 123 ). Advantages Data integrity ( ACID ): Postgres guarantees absolute transaction integrity without errors or data loss, thanks to its locking mechanisms and MVCC ...

Normalization and Denormalization

Image
Introduction Data Anomalies Before diving into the main content of this article, we need to understand Data Anomalies, which are logical flaws or data discrepancies that occur in relational databases when proper table normalization has not been applied. This leads to information being stored repeatedly in a redundant manner. When data operations (Insert, Update, Delete) are performed, they cause the database to fall into an inconsistent state where data is correct in some places but incorrect in others. Data Anomalies are divided into 3 main types: Insertion Anomaly: Occurs when you cannot add a new record into the database because the system forces you to enter another piece of information that does not yet exist. Deletion Anomaly: Occurs when you delete one piece of information but accidentally lose another completely different and important piece of information. Update Anomaly: Occurs when a piece of information is repeated across too many rows. As a result, when you edit that infor...