您的位置:首页 > 数据库 > MariaDB

<<连载>><<MariaDB Crash Cource>>中文笔记(第三)

2013-09-06 07:56 597 查看
第三部分 第一章:了解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指"结构化查询语言",被设计用来与数据库通信.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: