What is a Database?
什么是數(shù)據(jù)庫(kù)
The easiest way to understand a database is as a collection of related files.
理解數(shù)據(jù)庫(kù)最簡(jiǎn)單的方法是作為相關(guān)文件的集合。
Imagine a file (either paper or digital) of sales orders in a shop.
想象一個(gè)商店里銷售訂單的文件 (紙質(zhì)或數(shù)字)。
Then there's another file of products, containing stock records.
然后還有另一個(gè)產(chǎn)品文件,包含庫(kù)存記錄。
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.
要完成訂單,您需要在訂單文件中查找產(chǎn)品,然后在產(chǎn)品文件中查找并調(diào)整該特定產(chǎn)品的庫(kù)存水平。
A database and the software that controls the database, called a database management system (DBMS), helps with this kind of task.
數(shù)據(jù)庫(kù)和控制數(shù)據(jù)庫(kù)的軟件 (稱為數(shù)據(jù)庫(kù)管理系統(tǒng) (DBMS)) 有助于完成此類任務(wù)。
Most databases today are relational databases, named such because they deal with tables of data related by a common field.
如今,大多數(shù)數(shù)據(jù)庫(kù)都是關(guān)系數(shù)據(jù)庫(kù),之所以這樣命名是因?yàn)樗鼈兲幚砼c公共字段相關(guān)的數(shù)據(jù)表。
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顯示了產(chǎn)品表,表2顯示了發(fā)票表。如您所見,兩個(gè)表之間的關(guān)系基于公共字段product_code。任意兩個(gè)表只需有一個(gè)共同的字段就可以相互關(guān)聯(lián)。
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
數(shù)據(jù)庫(kù)術(shù)語
Let's take a closer look at the previous two tables to see how they are organized:
讓我們仔細(xì)看看前兩個(gè)表,看看它們是如何組織的:
● Each table consists of many rows and columns.
● 每個(gè)表由許多行和列組成。
● 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.
● 每個(gè)新行包含有關(guān)單個(gè)實(shí)體 (例如一個(gè)產(chǎn)品或一個(gè)訂單行) 的數(shù)據(jù)。這叫做記錄。例如,表1的第一行是一條記錄; 它描述了A416產(chǎn)品,這是一盒14美分的釘子。術(shù)語“行”和“記錄”是可互換的。
● 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.
● 每一列 (也稱為屬性) 包含一條與記錄相關(guān)的數(shù)據(jù),稱為元組。屬性的示例是售出商品的數(shù)量或產(chǎn)品的價(jià)格。引用數(shù)據(jù)庫(kù)表時(shí),屬性稱為字段。例如,表1中Description列中的數(shù)據(jù)為字段。術(shù)語"屬性"和"字段"是可互換的。
Given this kind of structure, the database gives you a way to manipulate this data: SQL.
鑒于這種結(jié)構(gòu),數(shù)據(jù)庫(kù)為您提供了一種操作此數(shù)據(jù)的方法: SQL。
SQL (structured query language) is a powerful way to search for records or make changes.
SQL (結(jié)構(gòu)化查詢語言) 是一種搜索記錄或進(jìn)行更改的強(qiáng)大方法。
Almost all DBMSs use SQL, although many have added their own enhancements to it.
幾乎所有的DBMSs都使用SQL,盡管許多DBMSs已經(jīng)添加了自己的增強(qiáng)功能。
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.
這意味著,當(dāng)您在使用MariaDB時(shí)學(xué)習(xí)SQL時(shí),幾乎所有SQL都不是特定于MariaDB的,也可以與其他關(guān)系數(shù)據(jù)庫(kù)一起使用,例如PostgreSQL、MySQL、Oracle和SQL Server。MariaDB最初是作為MySQL的嵌入式替代品創(chuàng)建的,因此MariaDB和MySQL特別接近。