一个小时学会MySQL数据库(张果)

论坛 期权论坛 脚本     
niminba   2021-5-23 04:59   1663   0

随着移动互联网的结束与人工智能的到来大数据变成越来越重要,下一个成功者应该是拥有海量数据的,数据与数据库你应该知道。

一、数据库概要

数据库(Database)是存储与管理数据的软件系统,就像一个存入数据的物流仓库。

在商业领域,信息就意味着商机,取得信息的一个非常重要的途径就是对数据进行分析处理,这就催生了各种专业的数据管理软件,数据库就是其中的一种。当然,数据库管理系统也不是一下子就建立起来,它也是经过了不断的丰富和发展,才有了今天的模样。

1.1、发展历史

1.1.1、人工处理阶段
在20世纪50年代中期以前的计算机诞生初期,其处理能力很有限,只能够完成一些简单的运算,数据处理能力也很有限,这使得当时的计算机只能够用于科学和工程计算。计算机上没有专用的管理数据的软件,数据由计算机或处理它的程序自行携带。当数据的存储格式、读写路径或方法发生变化的时候,其处理程序也必须要做出相应的改变以保持程序的正确性。

1.1.2、文件系统
20世纪50年代后期到60年代中期,随着硬件和软件技术的发展,计算机不仅用于科学计算,还大量用于商业管理中。在这一时期,数据和程序在存储位置上已经完全分开,数据被单独组织成文件保存到外部存储设备上,这样数据文件就可以为多个不同的程序在不同的时间所使用。
虽然程序和数据在存储位置上分开了,而且操作系统也可以帮助我们对完成了数据的存储位置和存取路径的管理,但是程序设计仍然受到数据存储格式和方法的影响,不能够完全独立于数据,而且数据的冗余较大。

1.1.3、数据库管理系统
从20世纪70年代以来,计算机软硬件技术取得了飞跃式的发展,这一时期最主要的发展就是产生了真正意义上的数据库管理系统,它使得应用程序和数据之间真正的实现的接口统一、数据共享等,这样应用程序都可以按照统一的方式直接操作数据,也就是应用程序和数据都具有了高度的独立性。

1.2、常见数据库技术品牌、服务与架构

发展了这么多年市场上出现了许多的数据库系统,最强的个人认为是Oracle,当然还有许多如:DB2、Microsoft SQL Server、MySQL、SyBase等,下图列出常见数据库技术品牌、服务与架构。

1.3、数据库分类

数据库通常分为层次式数据库、网络式数据库和关系式数据库三种。

而不同的数据库是按不同的数据结构来联系和组织的。

而在当今的互联网中,最常见的数据库模型主要是两种,即关系型数据库和非关系型数据库。

1.3.1、关系型数据库

当前在成熟应用且服务与各种系统的主力数据库还是关系型数据库。

代表:Oracle、SQL Server、MySQL

1.3.2、非关系型数据库
随着时代的进步与发展的需要,非关系型数据库应运而生。

代表:Redis、Mongodb

NoSQL数据库在存储速度与灵活性方面有优势,也常用于缓存。

1.4、数据库规范化
经过一系列的步骤,我们现在终于将客户的需求转换为数据表并确立这些表之间的关系,那么是否我们现在就可以在开发中使用呢?答案否定的,为什么呢!同一个项目,很多人参与了需求的分析,数据库的设计,不同的人具有不同的想法,不同的部门具有不同的业务需求,我们以此设计的数据库将不可避免的包含大量相同的数据,在结构上也有可能产生冲突,在开发中造成不便。

1.4.1. 什么是范式
要设计规范化的数据库,就要求我们根据数据库设计范式――也就是数据库设计的规范原则来做。范式可以指导我们更好地设计数据库的表结构,减少冗余的数据,借此可以提高数据库的存储效率,数据完整性和可扩展性。

设计关系数据库时,遵从不同的规范要求,设计出合理的关系型数据库,这些不同的规范要求被称为不同的范式,各种范式呈递次规范,越高的范式数据库冗余越小。目前关系数据库有六种范式:第一范式(1NF)、第二范式(2NF)、第三范式(3NF)、巴德斯科范式(BCNF)、第四范式(4NF)和第五范ate` int default 1 comment '状态', `AddDate` timestamp default CURRENT_TIMESTAMP comment '上货日期', `Hang` int comment '挂件', `RawStone` int comment '赌石', `Size` varchar(200) comment '尺寸', `ExpressageName` varchar(100) comment '快递名称', `Expressage` decimal comment '快递费', `AllowComment` int default 1 comment '是否允许评论', `Reserve1` varchar(4000) comment '保留备用1', `Reserve2` varchar(4000) comment '保留备用2', `Reserve3` decimal(0) comment '保留备用3', primary key (Id) ); alter table Products comment '商品'; /*==============================================================*/ /* Table: Users */ /*==============================================================*/ create table Users ( `UserId` int not null auto_increment comment '用户编号', `UserName` varchar(200) not null comment '用户名', `Password` varchar(512) not null comment '密码', `Email` varchar(100) not null comment '邮箱', `Sex` varchar(10) comment '性别', `State` int default 1 comment '状态', `RightCode` int comment '权限状态', `RegDate` timestamp default CURRENT_TIMESTAMP comment '注册时间', `RegIP` varchar(200) comment '注册IP', `LastLoginDate` datetime comment '最近登录时间', `UserReserve1` varchar(4000) comment '保留备用1', `UserReserve2` varchar(4000) comment '保留备用2', `UserReserve3` varchar(4000) comment '保留备用3', primary key (UserId) ); alter table Users comment '用户'; alter table Address add constraint FK_AddressBelongUser foreign key (UserId) references Users (UserId) on delete restrict on update restrict; alter table ArticleComment add constraint FK_ArticleCommentForArticle foreign key (ArticleId) references Articles (ArticleId) on delete restrict on update restrict; alter table ArticleComment add constraint FK_ArticleCommentForUser foreign key (UserId) references Users (UserId) on delete restrict on update restrict; alter table Articles add constraint FK_ArticleBelongType foreign key (ArticleTypeId) references ArticleType (ArticleTypeId) on delete restrict on update restrict; alter table DictSub add constraint FK_BelongDict foreign key (DictId) references DictTop (DictId) on delete cascade on update cascade; alter table OrderPdt add constraint FK_BelongOrder foreign key (OrderId) references Orders (OrderId) on delete cascade on update cascade; alter table OrderPdt add constraint FK_CartForUser foreign key (UserId) references Users (UserId) on delete restrict on update restrict; alter table OrderPdt add constraint FK_OrderDepProduct foreign key (Id) references Products (Id) on delete restrict on update restrict; alter table Orders add constraint FK_OrderBelongAddress foreign key (AddressId) references Address (AddressId) on delete restrict on update restrict; alter table ProductComment add constraint FK_ProductCommentBelongUsers foreign key (UserId) references Users (UserId) on delete restrict on update restrict; alter table ProductComment add constraint FK_ProductCommentForProduct foreign key (ProductId) references Products (Id) on delete restrict on update restrict; alter table Products add constraint FK_BelongBrand foreign key (SubIdMaterial) references DictSub (SubId) on delete restrict on update restrict; alter table Products add constraint FK_BelongColor foreign key (SubIdBrand) references DictSub (SubId) on delete restrict on update restrict; alter table Products add constraint FK_BelongInlay foreign key (SubIdInlay) references DictSub (SubId) on delete restrict on update restrict; alter table Products add constraint FK_BelongMaterial foreign key (SubIdColor) references DictSub (SubId) on delete restrict on update restrict; alter table Products add constraint FK_BelongMoral foreign key (SubIdTopLevel) references DictSub (SubId) on delete restrict on update restrict; alter table Products add constraint FK_BelongTopLevel foreign key (SubIdMoral) references DictSub (SubId) on delete restrict on update restrict;

六、下载程序、帮助、视频

MySQL绿色版下载地址1:https://pan.baidu.com/s/1hrS5KUw 密码: sug9

MySQL绿色版下载地址2:https://www.jb51.net/softs/594937.html

MySQL文档下载1:https://pan.baidu.com/s/1nuGQo57 密码: 898h

MySQL文档下载2:https://www.jb51.net/books/11598.html

MySQL5.5.27_64位安装包下载地址1: https://pan.baidu.com/s/1minwz1m 密码: ispn

MySQL5.5.56_64位安装包下载地址2: https://www.jb51.net/softs/363920.html

MySQL5.7.17安装包官网下载地址: https://dev.mysql.com/downloads/windows/installer/

文档中没有您可以查帮助:

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:1060120
帖子:212021
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP