数据库设计的十个最佳实践

数据库是应用及计算机的核心元素,负责存储运行软件应用所需的一切重要数据。为了保障应用正常运行,总有一个甚至多个数据库在默默运作。我们可以把数据库视为信息仓库,以结构化的方式存储了大量的相关信息,并合理分类,方便搜索及使用(java项目 fhadmin.cn)。

因此,数据库设计已经成为软件开发的重要组成部分,而高效的数据库设计对开发人员来说是非常重要的。那么为什么数据库设计很重要,“好”的标准是什么呢?本文将对此进行介绍。

[En]

Therefore, database design has become an important part of software development, and it is very important for developers to design an efficient database. So why is database design important, and what are the criteria for “good”? This article will introduce.

为什么数据库设计很重要?

以我们订购衬衫的网上商城网站为例。今天,在网站上订购衬衫的过程看起来很简单,但它涉及到大量的信息交换。例如,当你第一次浏览网页时,系统会向你显示一系列信息,包括产品分类、所有可用的商品、对应的价格、可用的尺寸、颜色等相关信息。

[En]

Take the website of the online mall where we order shirts as an example. Today, the process of ordering shirts from a website seems simple, but it involves a lot of information exchange. For example, when you browse the web for the first time, the system will show you a series of information, including product classification, all available goods, corresponding prices, available sizes, colors and other relevant information.

网站从存储数据的数据库中检索数据,当用户选择所需商品并继续购买时,网站要求提供个人详细信息、发货地址、付款详细信息,并确认订单。当前在此过程中生成的新数据,如用户详细信息、订单详细信息、采购和付款,将在同一数据库中添加和更新。

[En]

The website retrieves from the database where the data is stored, and when the user selects the desired item and continues to purchase, the site asks for personal details, shipping address, payment details, and confirms the order. New data currently generated in this process, such as user details, order details, purchases and payments, will be added and updated in the same database.

数据库设计非常重要,因为它对于构建可扩展且可在高工作负载下运行的软件应用程序至关重要。要设计一个数据库,首先要选择数据库软件。目前,有数百种数据库软件可用于构建应用程序,我们可以从一些最好的免费数据库软件中进行选择,然后就可以设计出符合要求的数据库了。下面列出了10个最佳数据库设计实践。

[En]

Database design is important because it is critical to building software applications that are scalable and can run under high workloads. To design a database, first of all, it is critical to choose database software. At present, there are hundreds of database software available for building applications, we can choose from some of the best free database software, and then it is time to design databases that meet the requirements. The 10 best database design practices are listed below.

数据库设计的10个最佳实践

为了设计一个好的数据库,必须考虑到所有利益攸关方的意见。在建立数据库之前,收集信息以了解他们对数据库的期望以及他们对数据库操作的熟练程度。这样,我们就可以得到数据库应该采用的技术水平,以及是否应该对用户进行数据库功能的培训。

[En]

In order to design a good database, the views of all stakeholders must be taken into account. Before building the database, collect information to understand their expectations of the database and their proficiency in the operation of the database. In this way, we can get the technical level that the database should adopt, and whether the user should be trained on the function of the database.

数据库有多种类型,选择正确类型则是数据库设计的关键。我们可以将数据库以两种方式分类。一是基于数据库用以定义和操作数据的查询语言。使用SQL的数据库是结构化数据最常用的类型。然而,由于NoSQL数据库的可伸缩性、灵活性和速度更优,它们更适合机器学习、网络分析以及物联网(IoT)使用。

第二种分类是基于数据模型的。有四种类型的分类:关系数据库、层次数据库、网络数据库和面向对象数据库。

[En]

The second classification is based on the data model. There are four types of classification: relational database, hierarchical database, network database, and object-oriented database.

研究不同类型的数据库并根据应用程序需求进行选择是必要的第一步。

[En]

It is a necessary initial step to study the different types of databases and make choices based on application requirements.

在定义数据项以及标记表与列时,遵从一致性原则非常重要,可以帮助我们更好地理解数据。命名表与列的最佳实践之一便是使用简单的名字来定义其包含的数据。比如:只需将包含用户名称的列标记为”CustomerName”(”用户名”)即可。

应当避免使用复数名(如CustomerNames)、缩写(如CN),并且名称中不得使用空格(如Customer Name)。如果坚持遵守这些规则,则将来的用户在使用数据库时会更容易。

数据库规范化是指将数据库中的所有信息组织起来,以避免数据重复和冗余。简单地说,规范化就是将数据分成几个较小的相关表,而不是将它们都保存在一个大表中。

[En]

Database normalization refers to organizing all the information in the database to avoid data duplication and redundancy. To put it simply, normalization is to divide the data into several smaller related tables, rather than keeping them all in one large table.

数据标准化是一种良好的数据库设计实践,有助于提高效率。但请确保不要过度规格化,否则会将数据分散到太多的小表中,从而造成混乱。

[En]

Standardizing data is a good database design practice and helps to improve efficiency. But make sure you don’t over-normalize, or you’ll spread the data into too many small tables and cause confusion.

事实上,文档化并非人见人爱,因为实在太烦了。但要记得,文档化对于良好的数据库设计至关重要,可以追踪所有的小细节。数据库设计应当附有指示说明、ER图、存储过程及所有其他相关的信息。文档还应当为编程者和终端用户提供足够信息量,确保他们能够理解并使用。

在许多情况下,存储在数据库中的信息是加密的,因此隐私成为一个令人担忧的问题。为了获得最大的安全性,我们应该加密密码,使用身份验证来限制对数据库的访问,并使用另一台服务器来存储数据库,而不是使用应用程序所在的服务器。这将确保您的数据不会受到攻击和侵犯隐私的威胁。

[En]

In many cases, the information stored in the database is encrypted, so privacy has become an issue of concern. For maximum security, we should encrypt the password, use authentication to restrict access to the database, and use another server to store the database instead of the server where the application is located. This will ensure that your data is not threatened by attacks and privacy violations.

好的数据库设计应该是可伸缩的,即在使用率增加的情况下,它仍然可以承受高工作量,并确保应用程序的运行。对于工作量可能发生变化的公司来说,在设计数据库时牢记这一点很重要。例如,如果电子商务网站预计随着销售额的增长,访问量将在一个月内快速增长,则在设计数据库时应考虑这一点,以便数据库能够响应访问者的快速增长。并在高工作负载下继续运行。

[En]

Good database design should be scalable, that is, in the case of increased usage, it can still withstand a high workload and ensure the operation of the application. For companies whose workload is likely to change, it is important to keep this in mind when designing databases. For example, if an e-commerce site expects visitors to increase rapidly within a month as sales grow, this should be taken into account when designing the database so that the database can respond to the rapid growth of visitors. and keep operating under high workloads.

数据库设计中的常见错误之一,就是不使用预存程序。预存程序指的是,在操作数据时手边随时可用的提前预存代码串。例如,如果有个SQL查询是常用的操作指令,则将它提前写入预存程序,而不是在用的时候重新来写,就会让工作简单起来。一旦有了预存程序,就可以在需要时一步执行并载入这个SQL查询了。

编写大量存储的程序是一项费力的任务,但如果您花时间完成并记录它,最终用户就更容易使用数据库。

[En]

Writing a large number of stored programs is a laborious task, but if you take the time to complete and document it, it is easier for the end user to use the database.

优秀数据库设计的专业技能之一是在数据库建模和设计上投入时间和精力。对于开发人员来说,一个常见的错误是忽略这一步骤以节省时间,并专注于软件开发的其他更重要的方面。然而,数据库的设计对于保证应用程序的功能非常重要。如果您只想节省时间而不仔细考虑设计,您将需要花费更多的时间来维护数据库,甚至在未来重新设计它。

[En]

One of the professional skills of excellent database design is to invest time and energy in database modeling and design. A common mistake for developers is to ignore this step to save time and focus on other more important aspects of software development. However, database design is very important to ensure the function of the application. If you just want to save time without thinking carefully about the design, you will need to spend more time maintaining the database or even redesigning it in the future.

测试也是数据库设计很关键的步骤,而且经常会被疏忽对待,甚至完全跳过,只为了赶DDL。我们应当在发布项目前,花些时间来彻底测试数据库设计,以确保其满足了所有计划中的需求,且正常运行。

Original: https://www.cnblogs.com/m170981362621/p/15607192.html
Author: m17098136262_1
Title: 数据库设计的十个最佳实践

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/507994/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • 汇编debug的安装

    实验一查看CPU和内存,用机器指令和汇编指令编程 在做实验前需要debug命令。 工具:dosbox,debug.exe 安装:dosbox :https://www.dosbox…

    数据库 2023年6月11日
    0117
  • 如何制作验证码

    推导步骤1:在img标签的src属性里放上验证码的请求路径 补充1.img的src属&amp…

    数据库 2023年6月14日
    088
  • [SWPU2019] Android2

    有一个超长的线程延迟和永远为假的判断条件,应该就是要修改这两点。 使用apktool反编译apk之后,直接打开MainActivity.smali文件,找到 1000000000的…

    数据库 2023年6月11日
    065
  • 在RAC上部署OGG并配置OGG高可用

    简介 由于业务系统要与大数据平台进行对接,需要将Oracle DB的数据同步到异构数据库上,故选用也不得不用上了Goldengate方案然鹅,OGG在RAC上的HA配置一直众说纷纭…

    数据库 2023年6月16日
    091
  • 基于Vue简易封装的快速构建Echarts组件 — fx67llQuickEcharts

    fx67llQuickEcharts A tool to help you use Echarts quickly! npm 组件说明 这本来是一个测试如何发布Vue组件至npm库…

    数据库 2023年6月11日
    099
  • Mysql终端Terminal操作

    datebase管理 1.创建数据库-create 语法:create database 数据库名 character set 编码 注意:默认会存在四个数据库,其数据库中存储的是…

    数据库 2023年6月14日
    067
  • MySQL 基础

    MySQL 基础 SQL 介绍 SQL (Structured Query Language:结构化查询语言) 是用于管理关系数据库管理系统(RDBMS)。 SQL 的范围包括数据…

    数据库 2023年5月24日
    091
  • MySQL中 VARCHAR 可设置的最大长度是多少?

    在使用MySQL的过程中,在存储字符串时,大家或许都有过这样或那样的困惑,譬如: 对于固定长度的字符串,为什么推荐使用 CHAR 来存储? VARCHAR 可设置的最大长度是多少?…

    数据库 2023年6月11日
    098
  • Java面向对象(下)作业

    首先我把题目先列到这里,可以仔细看一下题。 (1)设计一个名为Geometric的几何图形的抽象类,该类包括: ①两个名为color、filled属性分别表示图形颜色和是否填充。 …

    数据库 2023年6月11日
    0142
  • 上传代码到GitHub仓库

    上传代码到GitHub仓库 准备工作 意思是自从 21 年 8 月 13 后不再支持用户名密码的方式验证了,需要创建个人访问令牌(personal access token)。 这…

    数据库 2023年6月14日
    081
  • mysql使用存储过程批量给表加字段

    背景:在一个项目中,您需要将相同的字段添加到数百个表中,这很难手动添加,因此您计划使用存储过程来实现。 [En] Background: in a project, you nee…

    数据库 2023年5月24日
    0118
  • NO.4 计算机组成原理-笔记

    404. 抱歉,您访问的资源不存在。 可能是网址有误,或者对应的内容被删除,或者处于私有状态。 代码改变世界,联系邮箱 contact@cnblogs.com 园子的商业化努力-困…

    数据库 2023年6月14日
    093
  • 如何用axios加后端数据库传值给前端

    小杰笔记: 如何用axios : 第一步:编写数据库实体类 @Data @AllArgsConstructor @NoArgsConstructor public class Us…

    数据库 2023年6月6日
    0134
  • 开源二三事|ShardingSphere 与 Database Mesh 之间不得不说的那些事

    背景 前段时间,以 Apache ShardingSphere 核心团队组建的创业公司 SphereEx,正式对外推出了 Database Mesh 2.0 概念以及与之相配套的开…

    数据库 2023年6月16日
    0120
  • 一文了解Cookie

    Cookie 什么是 Cookie? 先要了解HTTP是 无状态的Web服务器,什么是无状态呢?一次对话完成后下一次对话完全不知道上一次对话发生了什么。如果在Web服务器中只是用来…

    数据库 2023年6月11日
    099
  • Redis与Python连接实例

    2022-09-22 1、 Redis与Python建立连接之前需要先安装”Redis”安装包: 在ubantu中,打开终端,输入命令: sudo pip …

    数据库 2023年6月14日
    0113
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球