索引

书的第一章介绍一些基本的概念。理解数据库是掌握 MySQL 非常重要的一个部分。

第二章简单介绍了 MySQL 以及若干个 MySQL工具,熟练掌握 mysql Command-Line Utility 就行了。

database

The term database is used in many different ways, but for our purposes a database is a collection of data stored in some organized fashion.

People often use the term database to refer to the database software they are running. This is incorrect, and it is a source of much confusion. 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.

 

table

information

filing cabinet 文件柜

toss it in a drawer 把它扔在抽屉里

you create files within the filing cabinet 你在文件柜内创建文件

and then you file related data in specific files. 然后在特定文件中提交相关数据。

In the database world, that file is called a table.

The key here is that the data stored in the table is one type of data or one list. You would never store a list of customers and a list of orders in the same database table. Doing so would make subsequent retrieval and access difficult. Rather, you'd create two tables, one for each list.、、

schema

Tables have characteristics and properties that define how data is stored in them. These include information about what data may be stored, how it is broken up, how individual pieces of information are named, and much more. This set of information that describes a table is known as a schema, and schema are used to describe specific tables within a database, as well as entire databases (and the relationship between tables in them, if any).

Columns and Datatypes

A single field in a table. All tables are made up of one or more columns.

Tables are made up of columns.

Breaking Up Data It is extremely important to break data into multiple columns correctly. For example, city, state, and ZIP Code should always be separate columns. By breaking these out, it becomes possible to sort or filter data by specific columns (for example, to find all customers in a particular state or in a particular city). If city and state are combined into one column, it would be extremely difficult to sort or filter by state.

Primary Key

A column (or set of columns) whose values uniquely identify every row in a table.

主键值应该可以唯一标识一条记录并且是非空的。书中提到,虽然对于一张表而言主键不是硬性需要的,但是我们应该“总是定义主键”。

关于主键的三条普遍接受的最佳实践:

  • 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.)

As explained, it is the database software (DBMS or Database Management System) that actually does all the work of storing, retrieving, managing, and manipulating data. MySQL is a DBMS; that is, it is database software.

MySQL Crash Course #01# Chapter 1. 2 概念. Primary key的更多相关文章

  1. MySQL Crash Course #13# Chapter 21. Creating and Manipulating Tables

    之前 manipulate 表里的数据,现在则是 manipulate 表本身. INDEX 创建多列构成的主键 自动增长的规定 查看上一次插入的自增 id 尽量用默认值替代 NULL 外键不可以跨引 ...

  2. MySQL Crash Course #11# Chapter 20. Updating and Deleting Data

    INDEX Updating Data The IGNORE Keyword Deleting Data Faster Deletes Guidelines for Updating and Dele ...

  3. MySQL Crash Course #12# Chapter 18. Full-Text Searching

    INDEX 由于性能.智能结果等多方面原因,在搜索文本时,全文搜索一般要优于通配符和正则表达式,前者为指定列建立索引,以便快速找到对应行,并且将结果集智能排序.启用查询扩展可以让我们得到未必包含关键字 ...

  4. MySQL Crash Course #07# Chapter 15. 关系数据库. INNER JOIN. VS. nested subquery

    索引 理解相关表. foreign key JOIN 与保持参照完整性 关于JOIN 的一些建议,子查询 VS. 联表查询 我发现MySQL 的官方文档里是有教程的. SQL Tutorial - W ...

  5. MySQL Crash Course #18# Chapter 26. Managing Transaction Processing

    InnoDB 支持 transaction ,MyISAM 不支持. 索引: Changing the Default Commit Behavior SAVEPOINT 与 ROLLBACK TO ...

  6. MySQL Crash Course #17# Chapter 25. 触发器(Trigger)

    推荐看这篇mysql 利用触发器(Trigger)让代码更简单 以及 23.3.1 Trigger Syntax and Examples 感觉有点像 Spring 里的 AOP 我们为什么需要触发器 ...

  7. MySQL Crash Course #10# Chapter 19. Inserting Data

    INDEX BAD EXAMPLE Improving Overall Performance Inserting Multiple Rows INSTEAD OF Inserting a Singl ...

  8. MySQL Crash Course #06# Chapter 13. 14 GROUP BY. 子查询

    索引 理解 GROUP BY 过滤数据 vs. 过滤分组 GROUP BY 与 ORDER BY 之不成文的规定 子查询 vs. 联表查询 相关子查询和不相关子查询. 增量构造复杂查询 Always ...

  9. MySQL Crash Course #05# Chapter 9. 10. 11. 12 正则.函数. API

    索引 正则表达式:MySQL only supports a small subset of what is supported in most regular expression implemen ...

随机推荐

  1. 9.13Django ORM那些事

    2018-9-13 14:23:22 ORM那些事  参考 : https://www.cnblogs.com/liwenzhou/p/8660826.html 今天的都是ORM的查询 更详细进阶了! ...

  2. poj1182 食物链【并查集-好题!】

    动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形.A吃B, B吃C,C吃A.  现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种. 有人用两 ...

  3. ubuntu16.04下安装Eigen

    请输入以下命令进行安装: sudo apt-get install libeigen3-dev 一个库由头文件和库文件组成.Eigen头文件的默认位置在 “usr/include/eigen3” 中. ...

  4. CodeForces - 950D A Leapfrog in the Array 玄学题

    题意:n个数1~n(n<=1e18)依次放在一个数组中,第i个数位置为2i-1,其它地方是空的.现在重复以下操作:将最右边的数放到离其左边最近的空的位置,直到所有数移到前一半的位置中.有q< ...

  5. MySQL复制日常维护与管理

    一.复制一些常见设置 1.mysql复制启动时参数: mysql启动时的参数包括:master_host,master_port,master_user,master_password,master_ ...

  6. 堆内存泄漏移除导致tcp链接异常高

    故障现象: 1:活动前端Nginx服务器TCP连接数到1万多 2:活动后端Tomcat其中1台TCP连接数达4千,并且CPU瞬间到780%(配置8核16G),内存正常 3:重启后端Tomcat后,TC ...

  7. https://validator.w3.org

    https://validator.w3.org/nu/?doc=http%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.7%2Fen%2Fmanual-info. ...

  8. 币安Binance API

    本文介绍币安Binance API General API Information The base endpoint is: https://api.binance.com All endpoint ...

  9. laravel教程入门笔记

    安装laravel框架 1.安装命令 composer create-project --prefer-dist laravel/laravel ytkah ytkah表示文件夹名,如果不写的话自动会 ...

  10. 帝国cms底部代码哪里改?要修改版权和统计代码

    最近接手的几个站是用帝国cms做的,底部代码那边都有一个**设计的链接,还有一些不相关的东西,第一眼看到就想把那些帝国cms底部代码清理掉,这就是让别人建站的烦恼,让他们删除说要收费,坑就一个字,自己 ...