Notes/Abstract 4 Database
Index:
** 0x01 Legacy Databases
** 0x02 Naive Data List
** 0x03 Relational Database
** 0x04 Modern databases
** 0x05 References
0x01 Legacy Databases(ref [4])
- Flat-file(Configure) databases
- Simple Data Structure for organizaing small amounts of local data
- Example: /etc/passwd
- Disadvantage:
- Very limited in the level of complexity they can handle
- Can not make easy connections between the data represented
- Hierarchical databases
- Using parent-child relationships to map data into trees
- Example: FileSystems/DNS/LDAP directories
- Disadvantage:
- Limit ability to organize most data
- overhead of accessing data by traversing the hierarchy
- Network databases
- Mapping more flexible connections with non-hierarchical links
- Example: IDMS
- Disadvantage:
- Access data still needed to follow the network paths
- The parent-child relationship also affected the way that item could connect to one another
0x02 Naive Data List(ref [1])
- Redundancy Problems
- Multiple Themes(Business Concept)
- Modification Issues
- Deletion Anomalies
- Column Value Missing
- Update Anomalies
- Missing Sigle Update
- Insertion Anomalies
- Redudancy Value
- Deletion Anomalies
0x03 Relational Database(ref [1])
- Database NormalForm (Solve List Problems, ref[3])
- First NormalForm
- The value in each column must be atomic
- if not split it
- The value in each column must be atomic
- Second NormalForm
- Primary key dependencies only, no partial key dependencies
- if not split it
- Primary key dependencies only, no partial key dependencies
- Third NormalForm
- No Transitive dependencies
- if not split it with foreign key
- No Transitive dependencies
- First NormalForm
- SQL
- DDL(Data Define Language)
- Create/Drop/Alter
- fieldname-type-nullable-defaultvalue-constrains
- Create/Drop/Alter
- DML(Data Manipulation Language)
- Insert/Update/Delete/Select
- SubQuery/Join(Left/Inner/Right)
- Windows function(ref [2])
- sum/count with group by
- sum/avg/... with over(...)
- null is not a value
- true>unknown>false
- CTE, recursive select
- DCL(Data Control Language)
- Grant/Deny/Rovoke
- DDL(Data Define Language)
- Key
- Unique Key
- Candidate Key
- Composite Key
- Primary Key
- Surrogate Key(Constrains Unique)
- Non-Unique Key
- Foreign key
- Unique Key
- ER
- Entity
- Relation
- 1:1
- 1:N
- N:M
- Concurrency
- Lost Update Problem
- Dirty Read
- Inconsistent Read
- Phantom Read
- Lock
- Optimistic Lock
- Lock On Modify
- Compare And Swap (CAS)
- Passimisitic Lock
- Full Lock/Unlock, Rollback if failed
- Optimistic Lock
- Lock Granularity
- Table
- Row
- Column
- Cell
- Transaction(ACID)
- A: Atom
- Do All
- Do Nothing
- C: Consistance
- Lock Granularity
- 2PC
- I: Isolate
- Read UnCommitted (Dirty Read)
- Read Committed (InConsistent Read)
- Repeatable Read (Phantom Read)
- Serializable
- D: Durable
- Committed changes are permanent
- A: Atom
- Cursors
- Forwardable only Cursor
- Backwardable/Forwardable Cursor
- Static Cursor: Update/Insert/Delete invisible
- KeySet Cursor: Insert invisible
- Dynamic Cursor: consume more resources
- Lost Update Problem
- Security
- User-Role Mode
- ACL
- Backup/Recovery
- UNDO mode
- REDO mode
- BIN log
- Distributed Database
- Master/Slave
- Partition Database
- Partition Table
- Raft
- NewSQL
- Database SQL Layer
- SQL Parser
- SQL Query Analyzer
- SQL Optimizer
- SQL Executor
0x04 Modern databases (ref [4])
- Key-value databases
- Simple, dictionary-style lookups for basic storage and retrieval
- Example: Redis/memcached/etcd
- Advantage:
- Store Application Configuration
- Store Application variables and flags
- Fast
- Document databases
- Storing all of an item's data in flexible, self describing structures
- Example: MongoDB/RethinkDB/Couchbase
- Advantage:
- Change data properties without alerting existing structures or data
- Disadvantage:
- You are responsible for maintaining the consistency and structure of your data
- Graph databases
- Mapping relationships by focusing on how connections between data and meaningful
- Example: Neo4j/JanusGraph/Dgraph
- Advantage:
- "relational" in RMDB refers to the ablitity to tie information in different tables together.
- On the other hand, with graph database, the primary purpose is defining and managing relationships themselves.
- Column-family databases
- Databases with flexible columns to bridge the gap between relational and document databases.
- Example: Cassandra/HBase
- Advantage:
- Great performance for row-based operations and highy scalability
- All of data and metadata of an entry is accessible with a single row identifier, no computaionally expensive joins are required to find and pull information.
- Disadvantage:
- If you have highly relational data that requires joins, this is not the right type of database for your application.
- NewSQL databases
- Brining modern scalability and performance to the traditional releation pattern
- Example: MemSQL/VoltDB/Spanner/Calvin/CockroachDB/FaunaDB/yugabyteDB/TiDB
- Advantage:
- Good fit for relational datasets that require scaling beyound what conventional relational databases can offer.
- Implement the relational abstraction and privide SQL interfaces, transitioning to a NewSQL database is often more straightforward then moving to s NoSQL alternative
- Disadvantage:
- Keep in mind that although they mostly seek to replicate the conventional relational envirounments, there are differences that may affect your deployments
0x05 References
[1] youtube: Database Lesson(1-8)
[2] SQL Window Functions
[3] wiki: Database normalization
[4] How Database Types Evolved to Meet Different Needs
[5] https://medium.com/@app_38528/dbms-data-type-comparison-62a75246c686
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix