数据库优化命令 [英] Database optimization orders

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

问题描述

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

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.

推荐答案

这不仅与用户(及其地址)有关,还与您销售的产品的价格和其他信息有关,这些信息之后可能会发生变化strong> 订单已下达,但订单本身必须保持完整.

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. 复制您在订单中需要的所有内容(及其商品).即使主"数据发生变化,您仍然可以使用订单内的副本.
  2. 版本"或历史化"整个数据库,类似于这个.

(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天全站免登陆