数据库优化订单 [英] Database optimization orders

查看:109
本文介绍了数据库优化订单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在用户可以下订单的数据库中,最好是有一个包含地址的新表或每个订单在其标题中有地址数据。

In a database where users can place orders, is it better to have a new table with addresses or each order has the address data in its header.

推荐答案

这不仅仅是关于用户(及其地址),还包括您销售的产品的价格和其他信息,可以在之后更改订单,

This is not just about users (and their addresses) but also about prices and other information about products you are selling, that can change after the order has been placed, yet the order itself must remain intact.

一般来说,有两种方法:

Generally, there are 2 approaches to this:


  1. 复制订单中所需的所有内容(及其项目)。即使master数据发生变化,您仍然可以在可以使用的顺序中有一个副本。

  2. Version或historize整个数据库,类似于这是

  1. Copy everything you need in the order (and its items). Even if the "master" data changes, you still have a copy within the order that you can use.
  2. "Version" or "historize" the whole database, similar to this.

(1)更实用的方法,但可能导致数据冗余(例如,当地址更改时,您仍然会对其进行单独的复制)。

(1) is the more "practical" approach, but can lead to data redundancies (e.g. when address doesn't change, you are nonetheless making separate copies of it).

(2)是更纯粹的方法,但可能需要更多的JOINing,通常更复杂。

(2) is the more "purist" approach, but may require more JOINing and generally be more complex.

这篇关于数据库优化订单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆