logo

How To Create an Information Database

2017-09-01


Introduction

MySQL is a relational database management system. MySQL began as an open-source development and has been owned by Oracle since 2008. Oracle has continued developing MySQL and has a dual-licensing model. There is a community version released under GPL or you can purchase a proprietary version.

The day Oracle acquired MySQL the software was forked due to concerns over it's commercialization. The largest actively maintained fork is MariaDB.

This procedure is an example for a user to create an information database. It can be used to store data that your would like to remember, such as combination locks, product information, subscriptions, maintenance schedules, etc.

This procedure assumes user can install software, invoke mysql program from a shell. The objective of this procedure is to show user how to create a simple database with primary key. The database structure is simple but uses a primary key to auto_increment a sequential number. This is an easy way of creating an ID for each record. Future procedures I plan to interact with this database using PERL.

Procedure

1. Log into mysql.

2. Use database of your choosing. I used a database called test.

USE test

3. User must design table based on desired data structure. To create a table named "example" with the following format:

info_id date info
unique integer XXXX-XX-XX up to 200 characters

You need to input the command:

CREATE TABLE example

(

info_idSMALLINT(8) UNSIGNED NOT NULL PRIMARY KEY unique,

dateDATE NOT NULL,

infoVARCHAR(200) NULL

);

INSERT INTO example VALUES (1,"2017-09-01", "combo lock 1 - 0 6 28");

INSERT INTO example VALUES (2,"2017-09-01", "combo lock 2 - 21 18 16");

INSERT INTO example VALUES (3,"2017-09-01", "combo lock 3 - 14 62 12");

4. To add a record: (I will provide three bogus records)

5. Congratulations, you created a database! Now search records using SQL.

SELECT * FROM example WHERE info like '%com%';

SELECT * FROM example WHERE info_id = 1;

Conclusion

This procedure will create a simple MySQL database and input three lines of data.

mysql example

Design credit knxops.com in cooperation with Ltimas and co.
Copyright © 2019 by Gregory Altimas aka Greg Altimas