数据库设计示例
> 前言 (› Preface)
Several years ago I was a junior developer with high ambitions to create web apps. Once I got an idea to analyze all money that I spend to understand my expenses better. I needed an application which could store payments, show statistics graphs, and give more than just a colourful circle graph with all payments in a month.
几年前,我是一名初级开发人员,具有创建Web应用程序的雄心壮志。 一旦有了一个想法,我就可以分析我花的所有钱以更好地了解自己的支出。 我需要一个可以存储付款,显示统计图并给出一个月内所有付款的彩色圆形图的应用程序。
For these reasons, I decided to develop an app and include all the features that I wanted.I am going to discuss with you the design of a relational database, which I made for this app.
出于这些原因,我决定开发一个应用程序并包含我想要的所有功能。我将与您讨论关系数据库的设计,这是我为此应用程序设计的。
›我需要存储什么数据? (› What data do I need to store?)
I explored this question with an example. I imagined that I bought the “Martian” book in the book shop, which located in the book shop “Book lovers”. Then, I paid for the book 5$ in cash on 20 Aug 2020 at 3:04 pm.
我用一个例子探讨了这个问题。 我以为我是在书店“书迷”里买的“火星人”书。 然后,我于2020年8月20日下午3:04用现金支付了这本书5美元。
Accordingly, at this moment, there are several parameters of the purchase:
因此,此刻,有几个购买参数:
- the name of the product — the “Martian” book, 产品名称-“火星人”书,
- the price — 5$, 价格-5美元,
- the location of the shop — “Book lovers” shop, 商店的位置-“书迷”商店,
- the payment type — cash, 付款方式-现金,
- the currency — USD, 货币-美元,
- date and time — 20 Aug 2020, 3:04 pm. 日期和时间-2020年8月20日,下午3:04。
![Image for post](https://miro.medium.com/max/9999/1*GnKnDLGjTNKd9l2LUU0UHg.png)