如何理解数据库中的三层模式结构

记得几年前我在公司做一个项目,数据库设计特别麻烦。
When a customer wants a report, I first have to check the data table structure, then think about writing the SQL, and finally have the generated report confirmed by the customer. The whole process feels like carpentry.你必须先研究木材的纹理,然后开始制作家具,最后才能看到主人的脸。
At that time, I thought, if there is something that allows me to directly tell the client "I have a report function here", then he can just click on it, and I don't have to bother like this every time.
后来接触到了三级数据库模型,突然觉得有点意思。
External mode is like a user manual.客户只需阅读即可阅读报告、查看数据。
Pattern is the internal logical structure.作为开发人员,我需要理解这一点,但客户不需要。
内部模式是一种特定的存储方式,如文件格式、索引排列等。
DBMS 本身处理这些,不用管客户端。
这样客户只需要看到外部模型,我负责中间逻辑和下层。
The division of labor is much clearer.
同样有趣的是外部模式/模式映射和模式/内部模式映射。
例如,如果客户要求的报告格式发生了变化,我就调整外部模式。
模式不变,内部模式不变,报表功能依然可以使用。
可以。
It's like changing the size of clothes.裁缝只换衣服,不换缝纫机。
But I think, if the customer insists on changing the schema/internal schema, such as splitting a h3 table into smaller tables, will it affect all the external schemas that use this table? It will take a lot of time to test this.
Wait a minute, there's one more thing.内部模式实际上属于特定的数据库系统。
例如,MySQL和Oracle可能具有完全不同的存储结构,但用户通过外部模式感知到相同的结构。
它们就像不同品牌的汽车,驾驶时的感觉是一样的,但它们的发动机和变速箱却完全不同。

I suddenly thought, how nice it would be if one day the database could automatically adjust the internal schema according to report requirements?例如,如果客户说“我需要更快的查询”,系统将自动添加索引,这样我就不必手动更改它。
But is this technology mature now?

为什么要给数据库分层?

Data tiering is a basic skill for data planners.
Layered solutions to clutter. Layering brings four major benefits: 1 . 结构清晰 2 . 减少重复 3 、统一口径 4 、简化问题
以下三层模型是主流。
1 . ODS: Original Data Layer 2 .DW: warehouse middle layer 3 . APP: Application data layer
ODS layer:
保存原始数据
No changes to the outside world
DW layer:
Subdivided into three levels:
DWD: Detailed layer, fine-grained facts
DWM: middle layer, aggregated data
DWS:业务层、宽表聚合
APP层:
面向应用的数据
维度表面层:
High cardinality dimensions (user, product)
低基数维度(配置、日期)
架构流程: 1 . Determination of source data 2 .ETL采集 3 . 保存主题 4 . 数据采集城市 5 . 查询分析 6 . User application
e-commerce log example: ODS:多表原始日志 DWD:一体化运行监控(PC/H5 /小程序/APP) DWM:核心维度聚合(人员、产品、设备、页面) DWS: User Behavior Wide Table APP:业务需求应用表
层次结构组织数据。