You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
2.4 KiB
50 lines
2.4 KiB
DBMS = Database Management System (e.g. MySQL, MariaDB, PostgreSQL, Oracle, Access, MongoDB)
|
|
|
|
SQL:
|
|
This should be your default option for most applications
|
|
Relational database with predefined schema
|
|
Data organized in tables, rows, and columns
|
|
Uses SQL as a common language, but some features may be DBMS-specific (MySQL vs PostgreSQL, etc.)
|
|
Well-suited for multi-table transactions
|
|
|
|
NoSQL:
|
|
Useful when you need high-performance at a huge scale, with little or no relation between tables
|
|
Allows storing data with no schema
|
|
Well-suited for documents, JSON, time series data, data dumps, and logs
|
|
Records can have internal structure (such as an array or tree-like structure)
|
|
Lack of good support for joins can be circumvented by storing joined data multiple times in different records
|
|
This sacrifices memory for time
|
|
Maintaining data consistency is more challenging
|
|
Some NoSQL DMBSs have limited support for joins and transactions
|
|
|
|
Note: If you just need to dump a bunch of JSON data (or something similar) from your application and fetch it back at a later time, you may not need a detailed database model. You may just want to store the JSON data directly (which both SQL and NoSQL databases can do).
|
|
|
|
SQLite:
|
|
From their website: "SQLite does not compete with client/server databases. SQLite competes with fopen()"
|
|
Benefits:
|
|
Simple to setup
|
|
Low latency, even for large sequences of SQL statements
|
|
Transactional
|
|
Serverless
|
|
Single data file
|
|
Lightweight processing
|
|
Drawbacks:
|
|
Any write operation requires a lock on the whole database; many simultaneous writes will slow it down
|
|
Lacks stored procedures
|
|
Lacks user management (e.g. who has permission to write to which table)
|
|
|
|
Transaction:
|
|
A unit of work on the database (possibly with multiple actions), treated independently of other such units.
|
|
If you are using a database, you must learn how to use transactions
|
|
Properties (ACID):
|
|
Atomic - either all of the transaction takes affect, or none of it (including under power failures and crashes)
|
|
Consistent - database invariants are maintained (constraints, triggers, referential integrity, etc.)
|
|
Isolated - transactions are executed as if they were sequential
|
|
Durable - committed transactions are never forgotten (i.e. they stored to non-volatile memory)
|
|
|
|
Basic operations (CRUD) and their associated SQL statements:
|
|
Create (INSERT)
|
|
Retrieve (SELECT)
|
|
Update (UPDATE)
|
|
Delete (DELETE)
|