星型模式命名约定

发布于 2024-08-11 14:32:45 字数 158 浏览 7 评论 0原文

在星型模式中,将表名称作为维度或事实表前缀是否是常见做法?列名以表名作为前缀也是常见的做法吗?

在我的普通 OLTP 数据库中,我不会这样做,但我在星型模式中看到了此类命名的示例。

数据仓库模式与 OLTP 模式采用不同的命名标准是否有意义?

谢谢德怀特

Is it common practice in a star schema to prefix table names as a dimension or fact table? Is it also common practice to have column names prefixed with the table name?

In my normal OLTP databases, I don't do this, but I'm seeing examples of this type of naming in star schemas.

Does it make sense to have a different set of naming standards for data warehouse schemas vs OLTP schemas?

Thanks Dwight

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

以可爱出名 2024-08-18 14:32:46

表名称:

  • 我喜欢这种约定:[type][subject][name],
  • 其中 type 是“dim”或“fact”(或聚合的“facts”),
  • 其中 subject 是表中的主题区域仓库('comm' 表示通用,'fw' 表示防火墙,'ids',
    等)
  • 其中名称最好是单个单词名称,或者在尺寸的情况下是尺寸缩写
    聚合表
  • ex:dim_comm_org 用于组织维度
  • ex:fact_scan 用于扫描事实表
  • ex:facts_scan_org_sev_daily - 事实扫描汇总表分组
    组织、部门和部门日级

列名:

  • 不要使用整个表名作为前缀 - 这太长了,
  • 只使用其中有意义的部分作为前缀 - 这在编写或读取查询时非常有帮助。

仓库与 OLTP 命名:

  • 两者非常不同。仓库表&列名称通常最终出现在报告的元数据中,供开发人员和用户阅读。 OLTP 则不然。
  • 我认为表前缀在 OLTP 中仍然有用 - 但我认为最好是对模型子集有意义,而不是事实/维度区别。

Table Names:

  • I like this convention: [type][subject][name]
  • where type is 'dim' or 'fact' (or 'facts' for aggregates)
  • where subject is the subject area within the warehouse ('comm' for common, 'fw' for firewall, 'ids',
    etc)
  • where name is ideally a single word name, or abbreviations of dimensions in the case of an
    aggregate table
  • ex: dim_comm_org for the organizational dimension
  • ex: fact_scan for the scan fact table
  • ex: facts_scan_org_sev_daily - fact scan summary table grouped at
    the org, sev & day level

Column Names:

  • don't prefix with the entire table name - that's way too long
  • do prefix with just a meaningful part of it - this helps tremendously when writing or reading queries.

Warehouse vs OLTP Naming:

  • the two are very different. Warehouse table & column names often end up in metadata, on reports, being read by both developers and users. Not so much with OLTP.
  • I think table prefixes are still useful in OLTP - but there I think it's best if it's something meaningful about that subset of the model rather than a fact/dimension distinction.
丢了幸福的猪 2024-08-18 14:32:46

tablename_column 名称约定用于确保数据库中的所有字段都是唯一的,尽管它有点过分,但可以在存在唯一命名的标准/要求(某些客户 IT 部门要求)时使用。

Product.Name => Product.Product_Name
Part.Name => Part.Part_Name

它消除了任何歧义关于名称的来源。

我宁愿完全不使用前缀来命名表(假设这不会违反公司的本地标准),因为虽然今天它可能是一个表,但明天它可能会被重新实现为视图或分区视图,但会公开相同的架构,然后我将不得不接受前缀不正确的对象或更新每个人对新名称的引用/创建同义词。

虽然保持一致性往往是赢家,但如果每个 DBA/Dev 都实现自己的版本,那就会很混乱,所以我倾向于找到公司标准并应用它们。

The tablename_column name convention is used to ensure that all fields within a database are unique, although it is somewhat excessive it can be used for when there is a standard / requirement for unique naming (Which some client IT departments demand.)

Product.Name => Product.Product_Name
Part.Name => Part.Part_Name

It removes any ambiguity over where Name would come from.

I prefer not to name tables with a prefex at all (assuming that does not break the local standards of a company), since whilst it might be a table today, it could be re-implemented as a view or partitioned view tomorrow but expose the same schema, and I would then have to accept objects prefixed incorrectly or update everyones reference to the new name / create a synonym.

Having consistency though tends to be the winner, if every DBA / Dev implemented their own version it would be chaos, so I would tend to find the company standards and apply them.

心如荒岛 2024-08-18 14:32:46

在 DW 中,使用“长名称”命名列是很常见的,因为这些列最终会作为报表(查询结果)中的列标题,并且应该对业务用户友好。因此,通常使用 Product,而不是同时显示为“Name”(除非使用别名)的 Product.NameCustomer.Name。 ProductNameCustomer.CustomerName 因此,一旦星号通过联接展平,它们就会在报告(查询)的顶行中显示为“ProductName”和“CustomerName”。如果数据库允许的话,经常使用下划线代替驼峰式大小写和空格。当表在模式中的作用可能不明显时,建议在大型数据仓库中使用前缀 dim 和fact;我其实很喜欢他们。

It is common in DWs to name columns with "long names" because those columns end up as column headers in reports (query results) and are supposed to be business-user friendly. So instead of having Product.Name and Customer.Name which would both show up as "Name" (unless alias is used) it is common to use Product.ProductName and Customer.CustomerName so they show up as "ProductName" and "CustomerName" in top row of a report (query) once the star is flattened via joins. Underscores are frequently used instead of camel-case and blanks, if allowed by the DB. Prefixes dim and fact are recommended in large DWs when table's role in the schema may not be obvious; I actually like them.

友谊不毕业 2024-08-18 14:32:46

对于Oracle Business Intelligence Repository,优先使用后缀。

Ken,我喜欢您的 [类型] [主题] [名称] 约定,其中类型为“dim”或“fact”(或聚合的“facts”) 问题在于,在 Oracle 业务智能信息库中创建星型模式模型时,最佳实践建议我们应该为维度和事实表创建别名,并为维度和事实表添加 DIM_(或 dim)和 FACT(或fact_)前缀。

为了避免别名维度和事实表读取dim_dim[表名]或fact_fact_fact_[表名],最好用_DM(或_dm)后缀命名维度表,用_FT(或_ft)命名事实表) 后缀。

with Oracle Business Intelligence Repository there is a preference towards the use of suffixes.

Ken, I like your [type] [subject] [name] convention, where type is 'dim' or 'fact' (or 'facts' for aggregates) The problem is that when creating the Star schema model in the Oracle Business Intelligence Repository, best practices suggest that we should create alias names for the dimension and fact tables with a DIM_ (or dim), and FACT (or fact_) prefixes for the dimension and fact tables.

In order to avoid having alias dimension and fact tables to read dim_dim[table name] or fact_fact_fact_[table_name), it is preferred to name the dimension tables with a _DM (or _dm) suffix, and the fact tables with a _FT (or _ft) suffix.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文