What is a Database?
什么是数据库
The easiest way to understand a database is as a collection of related files.
理解数据库最简单的方法是作为相关文件的集合。
Imagine a file (either paper or digital) of sales orders in a shop.
想象一个商店里销售订单的文件 (纸质或数字)。
Then there's another file of products, containing stock records.
然后还有另一个产品文件,包含库存记录。
To fulfil an order, you'd need to look up the product in the order file and then look up and adjust the stock levels for that particular product in the product file.
要完成订单,您需要在订单文件中查找产品,然后在产品文件中查找并调整该特定产品的库存水平。
A database and the software that controls the database, called a database management system (DBMS), helps with this kind of task.
数据库和控制数据库的软件 (称为数据库管理系统 (DBMS)) 有助于完成此类任务。
Most databases today are relational databases, named such because they deal with tables of data related by a common field.
如今,大多数数据库都是关系数据库,之所以这样命名是因为它们处理与公共字段相关的数据表。
For example, Table 1 below shows the product table, and Table 2 shows the invoice table. As you can see, the relation between the two tables is based on the common field product_code. Any two tables can relate to each other simply by having a field in common.
例如,下面的表1显示了产品表,表2显示了发票表。如您所见,两个表之间的关系基于公共字段product_code。任意两个表只需有一个共同的字段就可以相互关联。
Table 1
Product_code | Description | Price |
---|---|---|
A416 | Nails, box | $0.14 |
C923 | Drawing pins, box | $0.08 |
Table 2
Invoice_code | Invoice_line | Product_code | Quantity |
---|---|---|---|
3804 | 1 | A416 | 10 |
3804 | 2 | C923 | 15 |
Database Terminology
数据库术语
Let's take a closer look at the previous two tables to see how they are organized:
让我们仔细看看前两个表,看看它们是如何组织的:
● Each table consists of many rows and columns.
● 每个表由许多行和列组成。
● Each new row contains data about one single entity (such as one product or one order line). This is called a record. For example, the first row in Table 1 is a record; it describes the A416 product, which is a box of nails that costs fourteen cents. The terms row and record are interchangeable.
● 每个新行包含有关单个实体 (例如一个产品或一个订单行) 的数据。这叫做记录。例如,表1的第一行是一条记录; 它描述了A416产品,这是一盒14美分的钉子。术语“行”和“记录”是可互换的。
● Each column (also called an attribute) contains one piece of data that relates to the record, called a tuple. Examples of attributes are the quantity of an item sold or the price of a product. An attribute, when referring to a database table, is called a field. For example, the data in the Description column in Table 1 are fields. The terms attribute and field are interchangeable.
● 每一列 (也称为属性) 包含一条与记录相关的数据,称为元组。属性的示例是售出商品的数量或产品的价格。引用数据库表时,属性称为字段。例如,表1中Description列中的数据为字段。术语"属性"和"字段"是可互换的。
Given this kind of structure, the database gives you a way to manipulate this data: SQL.
鉴于这种结构,数据库为您提供了一种操作此数据的方法: SQL。
SQL (structured query language) is a powerful way to search for records or make changes.
SQL (结构化查询语言) 是一种搜索记录或进行更改的强大方法。
Almost all DBMSs use SQL, although many have added their own enhancements to it.
几乎所有的DBMSs都使用SQL,尽管许多DBMSs已经添加了自己的增强功能。
This means that when you learn SQL while using MariaDB, almost all of it is not specific to MariaDB and can be used with other relational databases as well, such as PostgreSQL, MySQL, Oracle and SQL Server. MariaDB was originally-created as a drop-in replacement to MySQL, so MariaDB and MySQL are particularly close.
这意味着,当您在使用MariaDB时学习SQL时,几乎所有SQL都不是特定于MariaDB的,也可以与其他关系数据库一起使用,例如PostgreSQL、MySQL、Oracle和SQL Server。MariaDB最初是作为MySQL的嵌入式替代品创建的,因此MariaDB和MySQL特别接近。