From 1af6fd5c94dfca1fba2ce50236775a1f008375c4 Mon Sep 17 00:00:00 2001 From: Barnato <31374668+Barnato@users.noreply.github.com> Date: Thu, 5 Oct 2017 20:33:45 -0500 Subject: [PATCH 1/2] Database cm_blog with two (2) tables called user table and article table. User table uses MD5 to prevent passwords being shown in plain text --- schema.sql | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/schema.sql b/schema.sql index 7017acc..d1b7e27 100644 --- a/schema.sql +++ b/schema.sql @@ -2,4 +2,11 @@ CREATE database cm_blog; USE cm_blog; SHOW databases; CREATE TABLE cm_blog.article - (article_id int NOT NULL AUTO_INCREMENT Primary Key, author_user_id int NOT NULL, title varchar(35), body text, publish_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP); +(article_id int NOT NULL AUTO_INCREMENT Primary Key, author_user_id int NOT NULL, title varchar(35), body text, publish_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP); +CREATE TABLE cm_blog.user +(user_id int NOT NULL AUTO_INCREMENT Primary Key, name varchar(35), emailaddress varchar(80), password varchar (32)); +UPDATE user +SET password = MD5(password); +INSERT INTO user (password) +VALUES (MD5('verysecretpassword')); +SELECT * FROM user WHERE password=MD5('verysecretpassword'); From 67c326efc86bdc383c12399fec929de2d5f5500d Mon Sep 17 00:00:00 2001 From: Barnato <31374668+Barnato@users.noreply.github.com> Date: Fri, 13 Oct 2017 20:10:40 -0500 Subject: [PATCH 2/2] Corrected error which was UPDATE command used before INSERT command. Corrected code has INSERT command before UPDATE command. --- schema.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schema.sql b/schema.sql index d1b7e27..4fa5036 100644 --- a/schema.sql +++ b/schema.sql @@ -5,8 +5,8 @@ CREATE TABLE cm_blog.article (article_id int NOT NULL AUTO_INCREMENT Primary Key, author_user_id int NOT NULL, title varchar(35), body text, publish_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP); CREATE TABLE cm_blog.user (user_id int NOT NULL AUTO_INCREMENT Primary Key, name varchar(35), emailaddress varchar(80), password varchar (32)); -UPDATE user -SET password = MD5(password); INSERT INTO user (password) VALUES (MD5('verysecretpassword')); +UPDATE user +SET password = MD5(password); SELECT * FROM user WHERE password=MD5('verysecretpassword');