SQL 主表和事务表的区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35675890/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 04:27:56  来源:igfitidea点击:

difference between master and transaction table

sqlsql-serverdatabase

提问by Vidhya

Why do we need to have two tables (master and transaction table) of any topic like sales,purchase,etc.. What should be the relationship between the two tables and what should be the difference between them. Why do we really need them.

为什么我们需要有一个像任何主题的两个表(主机和事务表)salespurchase等等。我应该是两个表之间的关系应该是什么它们之间的区别。为什么我们真的需要它们。

回答by FallAndLearn

Master and Transaction tables are needed in the database schema specially in the verticals of sales.

数据库模式中需要主表和事务表,特别是在销售的垂直领域。

Master Data: Data which seldom changes. For example, if a company has a list of 5 customer then they will maintain a customer master table having the name and address of the customers alongwith other data which will remain permanent and is less likely to change.

主数据:很少变化的数据。例如,如果一家公司有一个包含 5 个客户的列表,那么他们将维护一个客户主表,其中包含客户的姓名和地址以及其他数据,这些数据将保持永久且不太可能更改。

Transaction Data: Data which frequently changes. For example, the company is selling some materials to one of the customer.So they will prepare a sales order for the customer. When they will generate a sales order means they are doing some sales transactions.Those transactional data will be stored in Transactional table.

交易数据:经常变化的数据。例如,公司正在向其中一位客户销售一些材料,因此他们将为客户准备一份销售订单。当他们生成销售订单时,意味着他们正在进行一些销售交易。这些交易数据将存储在 Transactional 表中。

This is really required to maintain database normalization.

这确实是维护数据库规范化所必需的。

回答by Classik--

In the end, it really depends on the type of data you are working with. If you have a specific example, that might give us a better indication on what you are trying to do. However, in general, a master table would theoretically be constant in relationship to habitual changes seen in your transaction table.

最后,这实际上取决于您使用的数据类型。如果你有一个具体的例子,这可能会让我们更好地说明你正在尝试做什么。但是,一般来说,主表在理论上与事务表中看到的习惯性变化相关是恒定的。

回答by Sorter

Master Table

主表

Master data is for capturing the system. Designing master table is the first step of database design. Master tables hold basic information of the system. To understand master tables, you need to understand the concept of a transaction.

主数据用于捕获系统。设计主表是数据库设计的第一步。主表保存系统的基本信息。要了解主表,您需要了解事务的概念。

Transaction Table

交易表

A transaction is an activity performed by entities within the system. These activities are captured to represent events like item purchase, ticket booking. Understanding transactions will give you clearer distinction of master tables from transaction tables.

事务是由系统内的实体执行的活动。这些活动被捕获以代表诸如物品购买、订票等事件。了解事务将使您更清楚地区分主表和事务表。

Example

例子

For example, to describe a class of students all the information needed will be part of master tables like student info, class info, teacher info, subject info. But to know what daily attendance of the students will be captured in the transaction table.

例如,要描述一个班级的学生,所有需要的信息都将是主表的一部分,如学生信息、班级信息、教师信息、学科信息。但是要知道学生每天的出勤情况会被记录在事务表中。

Reference

参考

Here is an article to help distinguish the two. https://metamug.com/article/difference-between-master-and-transaction-table.html

这里有一篇文章可以帮助区分两者。https://metamug.com/article/difference-between-master-and-transaction-table.html