File system and database comparison, file system database
Comparison between file systems and databases
This article compares common file systems and database technologies from the perspective of Single-host systems. There should be many omissions.
Commonalities:
- Same as system software or underlying software
- Are used to store and access data.
- Has a long history of research and development.
- There are mature standards or specifications. This is conducive to the development of portable programs, but also to the development of innovative systems, especially distributed systems.
- There are also many commonalities in implementation technology.
- Mostly use lower-layer languages such as C/C ++
- Ensure data consistency. In particular, transactions are supported to varying degrees.
- Both have the concept of Block, Page, Allocation unit, or Extent.
- Buffer cache, LRU, Group commit, and other concepts and algorithms are used.
- IO Optimization for Various Loads
Differences:
- The database has much stronger support for transactions, and the file system can only ensure the consistency of metadata.
- Databases have different levels of consistency, which are reflected in isolation levels.
- The database can have REDO and UNDO logs. Generally, the file system only uses REDO logs.
- Database transactions can be very long, and file system transactions are very short.
- Transactions in the database cannot be determined in advance, but are input by the user. Transactions in the file system can be determined in advance with clear categories.
- Databases are implemented in user mode, while file systems are generally implemented in kernel mode. Therefore, the former is easier to achieve cross-OS Platform
- Database access interfaces are usually non-procedural SQL languages, while file systems are APIs. The mainstream standards for the two are SQL and POSIX.
- The database can detect deadlocks, and the file system needs to avoid deadlocks.
Contact points:
- Database systems often rely on file systems as their underlying storage, and may also implement some file system functions.
- The file system can be specially optimized for special applications such as databases.
- The file system can be used as a simple database (such as VSAM), and the database can also expose NFS (such as Oracle)
- The file system may use some simple database functions (for example, using a symbolic link as KV to implement simple DB functions, or directly using a small DBMS)