<<連載>><<MariaDB Crash Cource>>中文筆記(第三)

第三部分

 

第一章:瞭解SQL

    數據庫基礎
        數據庫是啥?不管你意識到與否,你時時都在跟數據庫打交道,每當你從通訊錄裏點擊E-mail名字,或是使用搜索引擎,或是用賬戶密碼登錄網站,甚至當你使用ATM機取錢的時候,你都在跟數據庫打交道.
        但到底什麼是數據庫?

        DATABASE:A container (usually a file or set of files) to store organized data
        定義:存儲有結構數據的容器.

        Database software is actually called the Database Management System(or DBMS). The database is the container created and manipulated via the DBMS. A database might be a file stored on a hard drive, but it might not. And for the most part this is not even significant as you never access a database directly anyway; you always use the DBMS, and it accesses the database for you.
        數據庫軟件準確來講應該叫數據庫管理系統,數據庫是通過DBMS來創建和管理的,一個數據庫可能是存在硬盤上的一個或多個文件.最重要的是,你從來不是直接連接到數據庫的,而是DMBS代替你訪問數據庫的.

        Table: A structured list of data of a specific type.
        表:一個結構化的列表,存儲特定類型的數據

        What makes a table name unique is actually a combination of several things, including the database name and table name. This means that while you cannot use the same table name twice in the same database, you definitely can reuse table names in different databases.
        不能在1個數據庫內創建名稱相同的表,在不同數據庫可創建名稱相同的表

        Schema: Information about database and table layout and properties.
        元信息:描述數據庫和表屬性的信息.

        Column: A single field in a table. All tables are made up of one or more columns
        字段:表中一個單獨的區域,所有的表都是由一個或多個字段組成的.

        Datatype: A type of allowed data. Every table column has an associated datatype that restricts (or allows) specific data in that column.
        數據類型:一種允許的數據,每張表的所有字段都有一個關聯的數據類型來約束和規定存儲的數據.

        Row: A record in a table.
        行:表中的1個記錄

         Columns may also be defined to accept no value, meaning no data at all. In SQL, the term NULLis used to mean no value.
         字段可以被定義爲接受"空值",SQL中,NULL就表示空值

         Primary key: A column (or set of columns) whose values uniquely identify every row in a table.
         主鍵:1個或多個字段,它的值可以唯一確定表中每一行.

         Without a primary key, updating or deleting specific rows in a table becomes difficult because there is no guaranteed safe way to refer to just the rows to be affected.
         沒有主鍵,更新或刪除特定的行將會非常困難,因爲沒有一個安全有保證的方法去指向特定的行.

         Any column in a table can be established as the primary key, as long as it meets 
the following conditions: 
■  No two rows can have the same primary key value.
■  Every row must have a primary key value (primary key columns may 
not contain NULLvalues).
        表中的任意字段都可以做主鍵,只要滿足以下2個條件:
        1.沒有2行在此字段上有相同值
        2.每行記錄在此字段上都不爲空

        Primary Key Best Practices :In addition to the rules that MariaDB enforces, several  universally accepted best practices should also be adhered to
■ Don’t update values in primary key columns.
■ Don’t reuse values in primary key columns.
■ Don’t use values that might change in primary key columns. (For example, when 
you use a name as a primary key to identify a supplier, you would have to change 
the primary key when the supplier merges and changes its name.)
        主鍵最佳實踐:
        1.不要更改主鍵裏的值
        2.不要使用相同的值
        3.不要使用有可能變化的值

        SQL (pronounced as the letters S-Q-L read as sequel) is an abbreviation for Structured Query Language. SQL is a language designed specifically for communicating with databases. 
        SQL指"結構化查詢語言",被設計用來與數據庫通信.

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章