<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jimmy Gitonga</title>
    <description>The latest articles on DEV Community by Jimmy Gitonga (@afrowave).</description>
    <link>https://dev.to/afrowave</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F225196%2F88aaeef3-3253-4d47-8dca-554598d202ba.png</url>
      <title>DEV Community: Jimmy Gitonga</title>
      <link>https://dev.to/afrowave</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/afrowave"/>
    <language>en</language>
    <item>
      <title>Designing a database with MySQL using the Workbench — Part 3</title>
      <dc:creator>Jimmy Gitonga</dc:creator>
      <pubDate>Sat, 28 Oct 2023 20:15:27 +0000</pubDate>
      <link>https://dev.to/afrowave/designing-a-database-with-mysql-using-the-workbench-part-3-1nn8</link>
      <guid>https://dev.to/afrowave/designing-a-database-with-mysql-using-the-workbench-part-3-1nn8</guid>
      <description>&lt;p&gt;If you have just stepped in, please have a look at the first two parts in this series, &lt;em&gt;Designing a MySQL database using the Command Line Interface&lt;/em&gt;, &lt;a href="https://dev.to/afrowave/designing-a-database-with-mysql-using-the-command-line-interface-part-1-1ffe"&gt;&lt;strong&gt;Part 1&lt;/strong&gt;&lt;/a&gt; and &lt;a href="https://dev.to/afrowave/designing-a-database-with-mysql-using-the-command-line-interface-part-2-26of"&gt;&lt;strong&gt;Part 2&lt;/strong&gt;&lt;/a&gt;. We continue to work with the database we developed in these two articles. As in the previous articles, pick any name for your tables in the database if you find these a bit too abstract.&lt;/p&gt;

&lt;p&gt;Now that we are comfortable with the building of a database in MySQL through the Command Line Interface, let us look at designing the databases through the &lt;strong&gt;&lt;em&gt;MySQL Workbench 6.3.x&lt;/em&gt;&lt;/strong&gt;. For information on installation procedures for different OSs, look at the &lt;a href="https://downloads.mysql.com/docs/workbench-en.pdf" rel="noopener noreferrer"&gt;&lt;em&gt;‘workbench-en.pdf’&lt;/em&gt;&lt;/a&gt; manual available from the MySQL website. It also has a tutorial on how to build a database in the Workbench.&lt;/p&gt;

&lt;p&gt;In this part, we will work with the database “&lt;strong&gt;Waks_Noma&lt;/strong&gt;” that we built previously. We will import the database into the &lt;strong&gt;MySQL Workbench&lt;/strong&gt;(Workbench), understand the visual representation of our _waks_noma_database, add a table into the &lt;strong&gt;EER(Entity-Entity Relationship)&lt;/strong&gt;, export it into the existing live database and make queries from Workbench.&lt;/p&gt;

&lt;h2&gt;
  
  
  Workbench
&lt;/h2&gt;

&lt;p&gt;When one opens Workbench, the initial screen looks like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A7WyKGSpzEMHbPiy1hbrz1w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A7WyKGSpzEMHbPiy1hbrz1w.png" alt="Workbench splash screen"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To work on the &lt;strong&gt;waks_noma&lt;/strong&gt; database, we will open our MySQL instance on our local machine.&lt;/p&gt;

&lt;p&gt;Click on the &lt;strong&gt;Local instance 3306&lt;/strong&gt; button and you may be asked enter the name and password.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;NOTE&lt;/em&gt;: When working in a multi-user environment and online to a live remote server, the name and password security issues should be taken very seriously.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We get:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AZJPrvjmFyMjLPf02UtcZTA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AZJPrvjmFyMjLPf02UtcZTA.png" alt="Workbench Dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The schemas of the databases present on the local computer appear &lt;strong&gt;Schemas&lt;/strong&gt;tab at the bottom left. We choose our &lt;em&gt;waks_noma&lt;/em&gt; and collapse the &lt;strong&gt;Management&lt;/strong&gt; tab.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AnlgwXXeG8RWb-nUIm3vn-w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AnlgwXXeG8RWb-nUIm3vn-w.png" alt="Workbench Query Window"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  a) Adding the Designers’ Table: waseenoma
&lt;/h3&gt;

&lt;p&gt;With &lt;em&gt;waks_mona&lt;/em&gt; selected, click on &lt;strong&gt;Add Table&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AX4-xemF2_60fsc4GewrKsw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AX4-xemF2_60fsc4GewrKsw.jpeg" alt="Workbench Add Table"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add the new name add the following columns:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A06mgOz2os6EF-GVNgX_1Jw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A06mgOz2os6EF-GVNgX_1Jw.png" alt="Workbench Table Add Columns"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;NOTE: Set the &lt;strong&gt;PK&lt;/strong&gt; (Primary Key) to AI( auto-increment), and make sure all tthe colums are &lt;strong&gt;NN&lt;/strong&gt; (NOT_NULL). We will click on &lt;strong&gt;Apply&lt;/strong&gt; and we see something familiar:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AXFFODuZjr9d7WwvXPo4w6Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AXFFODuZjr9d7WwvXPo4w6Q.png" alt="Workbench Review Script"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on &lt;strong&gt;Apply&lt;/strong&gt; to run the script, and get our new table, &lt;em&gt;waseenoma&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F600%2F1%2AOiZkyZW3lYZ2ZDkw-G7aEQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F600%2F1%2AOiZkyZW3lYZ2ZDkw-G7aEQ.png" alt="Inspect Table"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let us go to our command line and confirm that it works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; show tables&lt;span class="p"&gt;;&lt;/span&gt;
+---------------------+
| Tables_in_waks_noma |
+---------------------+
| majobo              |
| majobskils          |
| majobtek            |
| maklayo             |
| maklayojobo         |
| maskils             |
| teknoma             |
| waseenoma           |
+---------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Success.&lt;/p&gt;

&lt;h3&gt;
  
  
  b) Adding Designers’ names into ‘waseenoma’
&lt;/h3&gt;

&lt;p&gt;Let us go back to our &lt;strong&gt;Schemas&lt;/strong&gt; tab, select &lt;em&gt;waseenoma&lt;/em&gt; table. Click on the icon on the right &lt;strong&gt;:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AN9_sSm7hu6C1tZdkZxqaYw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AN9_sSm7hu6C1tZdkZxqaYw.png" alt="Insert Data"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We insert our data in the editing tab that is named &lt;em&gt;waseenoma 1&lt;/em&gt; and click on the &lt;strong&gt;Apply changes to data&lt;/strong&gt; :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A-8nOwUDc0MrvIHenvZ_r7Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A-8nOwUDc0MrvIHenvZ_r7Q.png" alt="Apply to save data"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on &lt;strong&gt;Apply:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AKl9-JbTEzoSDMai1oYgfQg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AKl9-JbTEzoSDMai1oYgfQg.png" alt="Review script to apply data"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the &lt;strong&gt;Apply&lt;/strong&gt; again.&lt;/p&gt;

&lt;p&gt;Now to check that the data has really been applied to the &lt;em&gt;waseenoma,&lt;/em&gt; at the command line we get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; from waseenoma&lt;span class="p"&gt;;&lt;/span&gt;
+----------+--------------+-------------------+
| mnoma_id | mnoma_name   | mnoma_desc        |
+----------+--------------+-------------------+
|        1 | Mchora       | Graphics Chief    |
|        2 | Blossom      | Layout Sweetener  |
|        3 | Helium Ninja | Content Developer |
|        4 | Msafara      | Video Converger   |
+----------+--------------+-------------------+
4 rows &lt;span class="k"&gt;in &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;0.00 sec&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are certain that the Workbench works and we can go onto work with EER diagrams.&lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;Home&lt;/strong&gt; tab and click on the “ &amp;gt; ” icon*&lt;em&gt;:&lt;/em&gt;*&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AFaLn2b4ilFGHJJCgexBoiQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AFaLn2b4ilFGHJJCgexBoiQ.png" alt="Workbench create EER Dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the “Create EER Model from Database”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AzYMnS00B3TBaoKCSHpezeA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AzYMnS00B3TBaoKCSHpezeA.png" alt="Workbench Set EER parameters"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unless there is a good reason, like you have many users on the machine, leave these settings as they are. Continue to connect to the DBMS:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A7Kwd9AteX8OsE4H07Viybw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A7Kwd9AteX8OsE4H07Viybw.png" alt="Workbench Connect to database"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on &lt;em&gt;continue&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AIjFDCShjCVbxJaVg0mNmYg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AIjFDCShjCVbxJaVg0mNmYg.png" alt="Workbench Connect to database 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We choose our database &lt;em&gt;waks_noma&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Ah__lLtRvUqXFNjpEkNqb5w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Ah__lLtRvUqXFNjpEkNqb5w.png" alt="Workbench Connect to database 3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We &lt;em&gt;execute&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ApX8slYocux9v87B7YuU1dg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ApX8slYocux9v87B7YuU1dg.png" alt="Workbench Connect to database 4"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once we have completed the steps, we open the EER Diagram and arrange our ERDs:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AMzm7fJqv6QLSuUNINr2-pw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AMzm7fJqv6QLSuUNINr2-pw.png" alt="Workbench View EER"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  c) Joining majobo and waseenoma: majobnoma Table
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Am_wDwsfKIa0XVmPWOhlSOg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Am_wDwsfKIa0XVmPWOhlSOg.png" alt="Workbench join tables"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Above the &lt;em&gt;waseenoma&lt;/em&gt; table, go an pick “Place a New Table” and insert a table &lt;em&gt;majobnoma.&lt;/em&gt; Edit &lt;em&gt;majobnoma&lt;/em&gt; and in the &lt;strong&gt;Foreign Keys&lt;/strong&gt; tab, create the FKs to &lt;em&gt;majobo.job_id&lt;/em&gt; and &lt;em&gt;wanoma.mnoma_id&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A-t2GLMznWhWfBqP701wTVw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A-t2GLMznWhWfBqP701wTVw.png" alt="Workbench join tables 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We notice the “Crow Feet” connection that automatically appear between the &lt;em&gt;majobo&lt;/em&gt; table and the &lt;em&gt;wanoma&lt;/em&gt; table. You will notice that the existing “joining tables” that we made directly in the command line don’t automatically relate to their respective table FKs.&lt;/p&gt;

&lt;p&gt;We will correct this by changing them from the columns that are in the tables and using the &lt;strong&gt;Foreign Keys&lt;/strong&gt; tab update them. Make sure that you connect the column in &lt;em&gt;majobnoma&lt;/em&gt; and the referenced column both &lt;em&gt;majobo&lt;/em&gt; and &lt;em&gt;waseenoma.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ACMgPZkPKc6Lc3dPzAFBq3Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ACMgPZkPKc6Lc3dPzAFBq3Q.png" alt="Workbench join tables 3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once we finish the connecting the joining tables; &lt;em&gt;majobskils&lt;/em&gt;, &lt;em&gt;makalyojobo&lt;/em&gt; and &lt;em&gt;majobtek&lt;/em&gt;, the new EER looks like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A0JNaY7IzRf5gsyhSYJzMgQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A0JNaY7IzRf5gsyhSYJzMgQ.png" alt="Workbench View join tables"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Exporting the EER to waks_noma
&lt;/h4&gt;

&lt;p&gt;Finally we need to implement this EER onto the actual database. When we query the database, we get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; show tables&lt;span class="p"&gt;;&lt;/span&gt;
+---------------------+
| Tables_in_waks_noma |
+---------------------+
| majobo              |
| majobskils          |
| majobtek            |
| maklayo             |
| maklayojobo         |
| maskils             |
| teknoma             |
| waseenoma           |
+---------------------+
8 rows &lt;span class="k"&gt;in &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;0.07 sec&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we can see the database does not know about the &lt;em&gt;majobnoma&lt;/em&gt; table. In the Workbench, go to the &lt;strong&gt;Home&lt;/strong&gt; tab and get the to the local instance. When you look at the tables, it is clear the &lt;em&gt;majobnoma&lt;/em&gt; table is missing.&lt;/p&gt;

&lt;p&gt;So we will set up Workbench to create the SQL statements we need to sync the EER diagram with the live database schema. Go to the &lt;strong&gt;File &amp;gt; Export &amp;gt; Forward Engineer SQL CREATE Script.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ASyEtO6eHwSNyc50TOJfRUg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ASyEtO6eHwSNyc50TOJfRUg.png" alt="Workbench Link EER with database"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add a name for the SQL script and press continue. The instructions for the options in this tab can be found here — &lt;a href="https://dev.mysql.com/doc/workbench/en/wb-forward-engineering-sql-scripts.html" rel="noopener noreferrer"&gt;Forward Engineering Using an SQL Script&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A_hRCNtJHZbPIdLuleRKqRA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A_hRCNtJHZbPIdLuleRKqRA.png" alt="Workbench Link EER with database 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The “Export …” will be highlighted:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ANRKTw_Mlk6ghMnH4ejkDPQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ANRKTw_Mlk6ghMnH4ejkDPQ.png" alt="Workbench Link EER with database 3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We export the table objects and save. Make sure you are on the &lt;strong&gt;local instance&lt;/strong&gt;tab. We then open the script to run it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AL484tZK5jruUK_mVAQRlAQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AL484tZK5jruUK_mVAQRlAQ.png" alt="Workbench Link EER with database 4"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The following window pops up:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ARiV_gGo-K9_WvFxn0jJWFA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ARiV_gGo-K9_WvFxn0jJWFA.png" alt="Workbench Link EER run SQL script"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And if you have done everything right:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Aq_9sAtbWgj97nNKAzvUipA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Aq_9sAtbWgj97nNKAzvUipA.png" alt="Workbench Link EER success"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Opening the Workbench local instance, we can see the &lt;em&gt;majobnoma&lt;/em&gt; is in the database now:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Ab_AYiFlGo4OYwdt2O0Frxw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Ab_AYiFlGo4OYwdt2O0Frxw.png" alt="Workbench check table majobnoma"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And checking through the CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; show tables&lt;span class="p"&gt;;&lt;/span&gt;
+---------------------+
| Tables_in_waks_noma |
+---------------------+
| majobnoma           |
| majobo              |
| majobskils          |
| majobtek            |
| maklayo             |
| maklayojobo         |
| maskils             |
| teknoma             |
| waseenoma           |
+---------------------+
9 rows &lt;span class="k"&gt;in &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;0.00 sec&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you have reached this far, be rest assured you are on your way to being a on your way to being a MySQL &lt;em&gt;ninja!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That concludes our series on designing relational databases using &lt;strong&gt;MySQL using the CLI&lt;/strong&gt; and &lt;strong&gt;the Workbench&lt;/strong&gt; desktop application. If you have enjoyed the series, please give us some feedback to encourage us to extend development of databases with MySQL or PostgreSQL.&lt;/p&gt;

&lt;p&gt;Thanks for reading and we hope you at least enjoyed yourself.&lt;/p&gt;

</description>
      <category>mysql</category>
      <category>database</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Designing a database with MySQL using the Command Line Interface — Part 2</title>
      <dc:creator>Jimmy Gitonga</dc:creator>
      <pubDate>Sun, 06 Mar 2022 20:53:37 +0000</pubDate>
      <link>https://dev.to/afrowave/designing-a-database-with-mysql-using-the-command-line-interface-part-2-26of</link>
      <guid>https://dev.to/afrowave/designing-a-database-with-mysql-using-the-command-line-interface-part-2-26of</guid>
      <description>&lt;p&gt;In the first part of &lt;a href="https://dev.to/afrowave/designing-a-database-with-mysql-using-the-command-line-interface-part-1-1ffe"&gt;Designing a database with MySQL using the Command Line Interface — Part 1&lt;/a&gt;, we have built a database and in the process used the most important queries in MySQL, namely, CREATE, USE, DESCRIBE, INSERT, SELECT, DELETE and ALTER.&lt;/p&gt;

&lt;p&gt;We will continue to build out the Waks Noma database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; show databases&lt;span class="p"&gt;;&lt;/span&gt;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| waks_noma          |
+--------------------+
5 rows &lt;span class="k"&gt;in &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;0.01 sec&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; use waks_noma&lt;span class="p"&gt;;&lt;/span&gt;
Reading table information &lt;span class="k"&gt;for &lt;/span&gt;completion of table and column names
You can turn off this feature to get a quicker startup with &lt;span class="nt"&gt;-A&lt;/span&gt;
Database changed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are ready.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding Categories Table: maskils
&lt;/h2&gt;

&lt;p&gt;A good designer’s portfolio may have a number of categories: web development, motion graphics, branding, graphic design, and video production. Inexperienced database designers will just add a categories column (or columns) to next to the jobs so that data entry is of a job and its category. This is simple enough, but by adding a column called job_type, what would happen is that every so often, the type of work would be repeated or a project would have more than one job category, typically, like when making a multimedia presentation.&lt;/p&gt;

&lt;p&gt;Unfortunately, this table is now inflexible. Because category names are repeated, any changes in spelling or wording will require more updating and are more likely to result in both system and user error.&lt;/p&gt;

&lt;h3&gt;
  
  
  Design decisions
&lt;/h3&gt;

&lt;p&gt;Our categories are: Graphic Design, Web Design, Video production. Should we break this into sub categories, like under graphic design; brand identity, poster development, print layout? Can we list all the current and add future categories?&lt;/p&gt;

&lt;p&gt;The decision is made to add a separate table of job categories:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*** CREATE Categories table ***/&lt;/span&gt;
&lt;span class="k"&gt;create&lt;/span&gt; &lt;span class="k"&gt;table&lt;/span&gt; &lt;span class="n"&gt;maskils&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;cat_id&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt; &lt;span class="k"&gt;not&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt; &lt;span class="n"&gt;auto_increment&lt;/span&gt; &lt;span class="k"&gt;primary&lt;/span&gt; &lt;span class="k"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;cat_name&lt;/span&gt; &lt;span class="nb"&gt;varchar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;not&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;cat_desc&lt;/span&gt; &lt;span class="nb"&gt;text&lt;/span&gt; &lt;span class="k"&gt;not&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="cm"&gt;/*** end CREATE ***/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; show tables&lt;span class="p"&gt;;&lt;/span&gt;
+---------------------+
| Tables_in_waks_noma |
+---------------------+
| majobo              |
| maskils             |
+---------------------+
2 rows &lt;span class="k"&gt;in &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;0.00 sec&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will load the data form a local file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; load data &lt;span class="nb"&gt;local &lt;/span&gt;infile &lt;span class="s1"&gt;'[absolute path/to/]madiambo.txt'&lt;/span&gt; into table maskils&lt;span class="p"&gt;;&lt;/span&gt;
Query OK, 7 rows affected, 7 warnings &lt;span class="o"&gt;(&lt;/span&gt;0.00 sec&lt;span class="o"&gt;)&lt;/span&gt;
Records: 7  Deleted: 0  Skipped: 0  Warnings: 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our maskils table look thus:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; from maskils&lt;span class="p"&gt;;&lt;/span&gt;
+--------+--------------------+------------------------------------+| cat_id | cat_name           | cat_desc                                                                                                                                                                                            +--------+--------------------+------------------------------------+|      1 | Graphic Design     | This category deals single page design and layouts that include brand identities, posters, banners, T-shirt designs and so on.    |
|     2 | Print Layout        | This category includes magazine layouts brochures, posters, banners and brand collateral.          |
|      3 | Web Design         | This category describes User Interface design &lt;span class="o"&gt;(&lt;/span&gt;UI&lt;span class="o"&gt;)&lt;/span&gt; whether left at design or exploded to a working prototype. It also includes Information Architecture &lt;span class="o"&gt;(&lt;/span&gt;IA&lt;span class="o"&gt;)&lt;/span&gt; flows with the subsequent Wire Frames.                             |
|      4 | Web Development    | This category deals with the middleware used such as PHP or Content Management Solutions &lt;span class="o"&gt;(&lt;/span&gt;CMS&lt;span class="o"&gt;)&lt;/span&gt; such as Wordpress, Joomla, and Drupal or frameworks such as Ruby on Rails and Django.                                                  | 
|      5 | Video Production   | This category deals with video product development and delivery from script development to the finished product ready &lt;span class="k"&gt;for &lt;/span&gt;delivery.                               |       |      6 | Motion Graphics    | This category has animated graphics &lt;span class="k"&gt;for &lt;/span&gt;Television and film. It can incorporate web animation that enhances UX.                  |
|      7 | Animation          | This category deals with 2D and 3D animation, whether story based, character driven, web banners or motion graphics &lt;span class="k"&gt;for &lt;/span&gt;insertion &lt;span class="k"&gt;in &lt;/span&gt;TV and web content.               |
|      8 | Mobile Development | This category covers work singly or incorporating other media that is specifically geared &lt;span class="k"&gt;for &lt;/span&gt;delivery on mobile handsets and smart phones.                               | +--------+--------------------+------------------------------------+8 rows &lt;span class="k"&gt;in &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;0.00 sec&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The only purpose of this table is to hold information about categories. Ultimately, this design is simpler because each table makes sense on its own, independent of other tables. Each table will have one job and only one job. majobo will only hold information about the work done. maskils will only hold information about the categories of the work done.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;maskils&lt;/em&gt; is structured as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Vir_fRX0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hi80859xsxdql2gsoc2u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Vir_fRX0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hi80859xsxdql2gsoc2u.png" alt="maskills ERD" width="533" height="221"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By assigning only one job to each table, we can simplify the data and enable ourselves to better manage the data. For instance, if we need to rename the category "Video Production" to "Film", we now only need to update one row in maskils. If our categories were a column in the table majobo, we would have to go through the pain of searching every record in majobo for "Video Production" and updating each of those rows - an unnecessarily difficult process. In fact, all of our SQL statements will become easier to write and faster to process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Assigning Jobs to Categories
&lt;/h2&gt;

&lt;p&gt;If each table only has one job, then &lt;em&gt;majobskils&lt;/em&gt; will be to link a specific job done to a specific category describing the type of work done. Thus, it will only hold two columns: job_id and cat_id. Both columns are called Foreign Keys. Columns designated as foreign keys will hold values that are primary keys in other tables. That is, job_id is a primary key in majobo. In majobskils, the column work_id is a foreign key. The same goes for cat_id and maskils.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*** CREATE majobskils Table ***/&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;majobskils&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="n"&gt;job_id&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    
&lt;span class="n"&gt;cat_id&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="k"&gt;TYPE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;myisam&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="cm"&gt;/*** end CREATE TABLE ***/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: With the creation of this table, we have declared a type of MySQL storage engine. The main ones are &lt;strong&gt;InnoDB&lt;/strong&gt; and &lt;strong&gt;MyISAM&lt;/strong&gt;. The current general difference is that InnoDB allows transactions and MyISAM does not. MySQL 5.x uses InnoDB by default. For more information, investigate on &lt;em&gt;MySQL storage engines&lt;/em&gt;.&lt;br&gt;
For our &lt;em&gt;majobskils&lt;/em&gt;, the table does not need to handle transactions since it carries data that will not change in the near future.&lt;/p&gt;

&lt;p&gt;So comparing the two tables:&lt;/p&gt;
&lt;h3&gt;
  
  
  majobo
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;+--------+-------------+-------------------------+-------------------+
| job_id | job_name    | job_desc            ...      |
+--------+-------------+-------------------------+-------------------+
|      1 | The Warehouse  | ... The web space was required  ... |
|      2 | Aim to Succeed | This was a graphic design poster ... |
|      3 | Oiling Life    | ... The brochure was to be ... |
|      4 | Dying to Give  | The main piece was a video documentary ...  |
+--------+-------------+-------------------------+-------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  maskils
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;+--------+--------------------+--------------------------------------+
| cat_id | cat_name           | cat_desc                                                                                                                                                                                    |
+--------+--------------------+--------------------------------------+
|      1 | Graphic Design     | ...
|      2 | Print Layout       | ...
|      3 | Web Design         | ...
|      4 | Web Development    | ...
|      5 | Video Production   | ...
|      6 | Animation          | ...                                    
|      7 | Mobile Development | ...
+--------+--------------------+--------------------------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We then insert data into majobskils as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*** INSERT DATA into majobskils ***/&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;majobskils&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cat_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'3'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;majobskils&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cat_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'1'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;majobskils&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cat_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'3'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'1'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;majobskils&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cat_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'4'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'5'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="cm"&gt;/*** end INSERT DATA ***/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The results:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; SELECT &lt;span class="k"&gt;*&lt;/span&gt; FROM majobskils&lt;span class="p"&gt;;&lt;/span&gt;
+--------+--------+
| job_id | cat_id |
+--------+--------+
|      1 |      3 |
|      2 |      1 |
|      3 |      1 |
|      4 |      5 |
+--------+--------+
4 rows &lt;span class="k"&gt;in &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;0.01 sec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We use job_id and cat_id because these ID numbers are unique to each row in majobo and maskils, respectively.&lt;/p&gt;

&lt;p&gt;If we had instead used job_name and cat_name in majobskils, we would have redundant data - data that is duplicated elsewhere. Unlike name fields, ID fields are never subject to change, so using them to identify a row is safer and requires less storage and rework. The process of removing redundant data is called Database Normalization.&lt;/p&gt;

&lt;p&gt;The structure for majobskils is shown in the following ERD as well as the relationships to majobo and maskils.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TUADVfT0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wbxxmkd311gqd3to5txl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TUADVfT0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wbxxmkd311gqd3to5txl.png" alt="majobskills ERD" width="800" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Joining majobo and maskils Tables
&lt;/h2&gt;

&lt;p&gt;At this point, the database is set up to hold our job and the corresponding categories. Because the data is spread across three tables, we need to join the tables within our SELECT query. Joining tables means that we combine tables based on common fields (related fields). Joins do not physically join the tables, but rather join the query result sets from implied queries. There is no physical change to the database design.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*** Get the category names associated with job_id #1 ***/&lt;/span&gt;

&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;maskils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cat_name&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;majobo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;maskils&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;majobskils&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;majobo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;majobo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;majobskils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;
&lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;majobskils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cat_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;maskils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cat_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;+------------+
| cat_name   |
+------------+
| Web Design |
+------------+
1 row &lt;span class="k"&gt;in &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;0.00 sec&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we look at the ERD above, we can follow the query through the linking fields. A table like majobskils is called a linking tables (or mapping tables) because it links together (maps) other tables like majobo and maskils.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding Technology Classifications Table: teknoma
&lt;/h2&gt;

&lt;p&gt;We will handle adding technology classifications just as we did the categories. A variety of  media technologies exist: XHTML, PHP, Flash, Photoshop, etc. Because we want our database to capture what technology was used for each work, we will create a technologies table: tbl_tech. Like previous tables, tbl_tech will have an ID column, tech_id, that is the primary key and is also set to auto increment. It will only hold information about technologies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*** CREATE teknoma table ***/&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;teknoma&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;tek_id&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt; &lt;span class="n"&gt;AUTO_INCREMENT&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;tek_name&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="cm"&gt;/*** end CREATE ***/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We load data from a local file with all the definitions of the technologies used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; LOAD DATA LOCAL INFILE &lt;span class="s1"&gt;'teknoma.txt'&lt;/span&gt; INTO TABLE teknoma&lt;span class="p"&gt;;&lt;/span&gt;
mysql&amp;gt; &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; from teknoma&lt;span class="p"&gt;;&lt;/span&gt;
+--------+--------------+
| tek_id | tek_name     |
+--------+--------------+
|      1 | Vector Art   |
|      2 | Pixel Art    |
|      3 | HTML5        |
|      4 | CSS3         |
|      5 | Javascript   |
|      6 | ReactJS      |
|      7 | PHP          |
|      8 | Laravel      |
|      9 | Ruby         |
|     10 | Rails        |
|     11 | Python       |
|     12 | Django       |
|     13 | REST API     |
|     14 | MySQL        |
|     15 | PostreSQL    |
|     16 | iOS          |
|     17 | Andriod      |
|     18 | React Native |
|     19 | Video        |
|     20 | AR / VR      |
+--------+--------------+
20 rows &lt;span class="k"&gt;in &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;0.00 sec&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Like majobskils, we will create majobtek which will link majobo to teknoma. Both job_id and tek_id are foreign keys within majobtek.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*** CREATE majobtek Table ***/&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;majobtek&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="n"&gt;job_id&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    
&lt;span class="n"&gt;tek_id&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="k"&gt;TYPE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;myisam&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="cm"&gt;/*** end CREATE TABLE ***/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And comparing the two tables and joining in the corresponding job to tek:&lt;/p&gt;

&lt;h3&gt;
  
  
  majobo
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;+--------+-------------+-------------------------+-------------------+
| job_id | job_name    | job_desc            ...      |
+--------+-------------+-------------------------+-------------------+
|      1 | The Warehouse  | ... The web space was required  ... |
|      2 | Aim to Succeed | This was a graphic design poster ... |
|      3 | Oiling Life    | ... The brochure was to be ... |
|      4 | Dying to Give  | The main piece was a video documentary ...  |
+--------+-------------+-------------------------+-------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*** INSERT DATA into majobtek ***/&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;majobtek&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tek_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'3'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;majobtek&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tek_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'4'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;majobtek&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tek_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'7'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;majobtek&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tek_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'12'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;majobtek&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tek_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'1'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;majobtek&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tek_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'2'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;majobtek&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tek_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'3'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'1'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;majobtek&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tek_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'3'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'2'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;majobtek&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tek_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'4'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'18'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;majobtek&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tek_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'4'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'19'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;majobtek&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tek_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'4'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'20'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="cm"&gt;/*** end INSERT DATA ***/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So the fun part begins. To see what technology was used in what project, we create the following queries. If a, b, and c look confusing in the following query, don't be alarmed. a, b, and c are just alias table names. In essence, a, b, and c just represent a shorter way to type the table names that are used later in the query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*** Get the technology names used with job_id #1 ***/&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tek_name&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;majobo&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;majobtek&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;teknoma&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;
&lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tek_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tek_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;+----------+
| tek_name |
+----------+
| HTML5    |
| CSS3     |
| PHP      |
| Django   |
+----------+
4 rows &lt;span class="k"&gt;in &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;0.08 sec&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*** Get the job names used with tek_id #1 ***/&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;job_name&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;majobo&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;majobtek&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;teknoma&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tek_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;
&lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tek_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tek_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;+----------------+
| job_name       |
+----------------+
| Aim to Succeed |
| Oiling Life    |
+----------------+
&lt;span class="sb"&gt;`&lt;/span&gt;
So our majobtek ERD looks like so:

&lt;span class="o"&gt;![&lt;/span&gt;majobtek ERD]&lt;span class="o"&gt;(&lt;/span&gt;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jnzwa60jn9i9bw4r86t0.png&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;## Adding the Clients Table:  maklayo&lt;/span&gt;

Appropriately, maklayo will have klayo_id as the primary key &lt;span class="nb"&gt;set &lt;/span&gt;to auto increment.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
sql&lt;br&gt;
/*** CREATE maklayo table ***/&lt;br&gt;
CREATE TABLE maklayo (&lt;br&gt;
    klayo_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,&lt;br&gt;
    klayo_name VARCHAR(20) NOT NULL&lt;br&gt;
);&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;We then insert client names from a text file:

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
sql&lt;br&gt;
/*** LOAD DATA INTO maklayo ***/&lt;br&gt;
LOAD DATA LOCAL INFILE 'maklayo.txt' INTO TABLE maklayo;&lt;br&gt;
`&lt;br&gt;
And again a table linking jobs to clients:&lt;/p&gt;

&lt;p&gt;`/*** CREATE maklayojobo Table &lt;strong&gt;&lt;em&gt;/&lt;br&gt;
CREATE TABLE maklayojobo (&lt;br&gt;
job_id INT NOT NULL,&lt;br&gt;&lt;br&gt;
klayo_id INT NOT NULL&lt;br&gt;
)TYPE = myisam;&lt;br&gt;
/&lt;/em&gt;&lt;/strong&gt; end CREATE TABLE ***/&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;We insert data:

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
sql&lt;br&gt;
/*** INSERT DATA into maklayojobo &lt;strong&gt;&lt;em&gt;/&lt;br&gt;
INSERT INTO maklayojobo (job_id, klayo_id)&lt;br&gt;
VALUES ('1','1');&lt;br&gt;
INSERT INTO maklayojobo (job_id, klayo_id)&lt;br&gt;
VALUES ('2','4');&lt;br&gt;
INSERT INTO maklayojobo (job_id, klayo_id)&lt;br&gt;
VALUES ('3','5');&lt;br&gt;
INSERT INTO maklayojobo (job_id, klayo_id)&lt;br&gt;
VALUES ('4','6');&lt;br&gt;
/&lt;/em&gt;&lt;/strong&gt; end INSERT DATA ***/&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;To make this a little interesting, here is a query that finds out which technologies were used on a particular job for a particular client:

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
sql&lt;br&gt;
/*** Get the technology names used for klayo_id #1 ***/&lt;br&gt;
SELECT e.tek_name FROM maklayo a,&lt;br&gt;
maklayojobo b, majobo c, majobtek d, teknoma e&lt;br&gt;
WHERE a.klayo_id = 1&lt;br&gt;
AND a.klayo_id = b.klayo_id&lt;br&gt;
AND b.job_id = c.job_id&lt;br&gt;
AND c.job_id = d.job_id&lt;br&gt;
AND d.tek_id = e.tek_id;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
We get:

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
sql&lt;br&gt;
+----------+&lt;br&gt;
| tek_name |&lt;br&gt;
+----------+&lt;br&gt;
| HTML5    |&lt;br&gt;
| CSS3     |&lt;br&gt;
| PHP      |&lt;br&gt;
| Django   |&lt;br&gt;
+----------+&lt;br&gt;
4 rows in set (0.01 sec)&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

Below is the ERD that makes the possible queries above happen:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ah1h20ae7hvd18acoruz.png)

This concludes our designing a database in MySQL using the CLI.

It is possible to do design and build a MySQL database with the a Graphic User Interface. That is in our next article, [**Designing a database using MySQL Workbench.**](https://dev.to/afrowave/designing-a-database-with-mysql-using-the-workbench-part-3-1nn8) 

_This article was first published on Medium.com_  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>mysql</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Designing a database with MySQL using the Command Line Interface — Part 1</title>
      <dc:creator>Jimmy Gitonga</dc:creator>
      <pubDate>Tue, 18 May 2021 19:46:18 +0000</pubDate>
      <link>https://dev.to/afrowave/designing-a-database-with-mysql-using-the-command-line-interface-part-1-1ffe</link>
      <guid>https://dev.to/afrowave/designing-a-database-with-mysql-using-the-command-line-interface-part-1-1ffe</guid>
      <description>&lt;p&gt;I dived in to Python and Django became my go-to tool for the kind of projects I do (data-intensive). I decided at that time (late ’00s) that it would be nice to get to understand how I can work with the database, just in case my framework ORM needs help. So I came up with my personal learning exercises to become familiar with my database of choice then. I think that these series of articles will help the next lot of database ninjas.&lt;/p&gt;

&lt;h1&gt;
  
  
  MySQL
&lt;/h1&gt;

&lt;p&gt;This article is adequate for an absolute beginner to begin to tinker with the MySQL database. If you do not have an installation on your localhost, get an installer here — &lt;a href="https://dev.mysql.com/downloads/mysql/" rel="noopener noreferrer"&gt;Download MySQL Community Server&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;MySQL has an interesting story. Even with the purchase of MySQL by Oracle and the split that made MariaDB, MySQL is still the most popular Open Source Relational Database Management System (RDBMS) for Open Source software development.&lt;/p&gt;

&lt;p&gt;MySQL 5 was an important release as it brought enterprise features such as &lt;em&gt;Stored Procedures&lt;/em&gt; and &lt;em&gt;Triggers&lt;/em&gt; into MySQL. Now with Big Data flying around all over the place, Relational Databases have simply had to be faster and more efficient. For ingesting lots of data to be sorted out later, NoSQL has been the answer. For data that is already structured, SQL is still the best way to go.&lt;/p&gt;

&lt;p&gt;Today, unless one is building a “static” web site, a web developer will deal with databases at one point in time. A lot of frameworks and tools like SQLAlchemy abstract the database from the “middleware’, in this case, Python. For Frontend developers, once one is past HTML5/CSS3/ECMAScript 6 or the React /Vue “concepts” and enters into Rails(Ruby)/ Django(Python)Angular(JavaScript) web frameworks, a massive paradigm shift will occur. But in many cases, you may never write a line of SQL.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Relational Database
&lt;/h2&gt;

&lt;p&gt;A Database is a store for data, either as files or as URLs to where the actual data is are stored. In its basic form, a database can be a list of articles associated to each other by one or more attributes. For example, a list of men’s names and another list of dates.&lt;/p&gt;

&lt;p&gt;A Relational Database (RDB) is where the list of men’s names can be related to the list of dates. Let the relation between the two lists be birthdays. The two lists would be put into a table as two columns and the table would called ‘birthdays’. This is table is a Relational Database. How one chooses to view the data from it; such as, how many men were born in April or when was John born, depends on the queries made.&lt;/p&gt;

&lt;p&gt;MySQL is often the choice of web developers with database functionality needs. Other SQL databases such as PostgreSQL or Microsoft’s MSSQL Server may use slightly different query syntax, but the relational database design concepts shown will still apply.&lt;/p&gt;

&lt;p&gt;This article assumes that MySQL 5+ is installed on the computer or server being used and the syntax used will work on your command line interface of choice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;I am on macOS. Once I followed all the instructions, I opened the Terminal to start up mysql. After a fresh install, the mysql command is buried in /usr/local/mysql/bin. Create an alias so that you can call the command easily. You can operate as root, though it is best practice to create a new user and login as the new user. I will assume that you know how and have logged in as a registered user and not as root. To get to know who to do that, check out the manual.&lt;/p&gt;

&lt;p&gt;Previously, KEYWORDS were written in CAPITAL CASE letters. But now, keywords may be entered in any lettercase. So these are all the equivalent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; SELECT VERSION&lt;span class="o"&gt;()&lt;/span&gt;, CURRENT_DATE&lt;span class="p"&gt;;&lt;/span&gt;
mysql&amp;gt; &lt;span class="k"&gt;select &lt;/span&gt;version&lt;span class="o"&gt;()&lt;/span&gt;, current_date&lt;span class="p"&gt;;&lt;/span&gt;
mysql&amp;gt; SeLeCt vErSiOn&lt;span class="o"&gt;()&lt;/span&gt;, current_DATE&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Part 1: Designing an RDB using the Command Line Interface
&lt;/h1&gt;

&lt;p&gt;I have picked specific names for my database and tables, and I encourage this practice as it improves security, how? It is harder for hackers to guess the names of the tables. Of course there must also be proper documentation and version control, oh yes, of the database.&lt;/p&gt;

&lt;p&gt;I will use lower case letters to be in sync with CLI (Command Line Interface) commands. Let us see what we have for databases:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; show databases&lt;span class="p"&gt;;&lt;/span&gt;
+ — — — — — — — — — — +
| Database            |
+ — — — — — — — — — — +
| information_schema  | 
| mysql               |
| performance_schema  |
| sys                 |
+ — — — — — — — — — — +
4 rows &lt;span class="k"&gt;in &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;0.00 sec&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are the default databases used by &lt;code&gt;mysql&lt;/code&gt;. In the console printouts for the show databases command, I will leave out these particular databases.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Database: Waks Noma
&lt;/h2&gt;

&lt;p&gt;Our database will hold the information of members of a web design company, the technologies they use, the projects they have singly or jointly worked on and the duration of the projects.&lt;/p&gt;

&lt;p&gt;Pick any name for your database since the ones I have used might be abstract and make sense in a pidgin of Swahili known as Sheng’.&lt;/p&gt;

&lt;p&gt;Let the design company be called &lt;em&gt;Waks Noma&lt;/em&gt;. So we create a database for the company:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; create database waks_noma&lt;span class="p"&gt;;&lt;/span&gt;
Query OK, 1 row affected &lt;span class="o"&gt;(&lt;/span&gt;0.00 sec&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To see that we successfully created the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; show databases&lt;span class="p"&gt;;&lt;/span&gt;
+ — — — — — — — — — — +
| Database            |
+ — — — — — — — — — — +
| waks_noma           |
+ — — — — — — — — — — +
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  i) Creating the Jobs Table: majobo
&lt;/h3&gt;

&lt;p&gt;We need to work out what we will be setting up as the item of the database that every thing else will revolve around. This item is what we give a “primary id”. We are choosing between the designer or the job element. This is thinking through and in many cases drawing out is Database Schema Design. Schema design should be taken seriously at the onset of every database development. &lt;/p&gt;

&lt;p&gt;It is good practice, to plan out the relationships between items in the database. In our case, we want to show off the jobs, and then the designers on these jobs. So we will give jobs the Primary Key.&lt;/p&gt;

&lt;p&gt;Our first table consist of the jobs done by the company, Waks Noma.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mysql&amp;gt; use waks_noma;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And then we create the table ‘majobo’:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;create table majobo &lt;span class="o"&gt;(&lt;/span&gt;
 job_id int not null auto_increment primary key,
 job_name varchar&lt;span class="o"&gt;(&lt;/span&gt;20&lt;span class="o"&gt;)&lt;/span&gt; not null, job_desc text not null,
 job_pic_url varchar&lt;span class="o"&gt;(&lt;/span&gt;255&lt;span class="o"&gt;)&lt;/span&gt; not null
&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We query the database to see the results,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mysql&amp;gt; show tables;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and we get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;+ — — — — — — — — — — -+
| Tables_in_waks_noma  |
+ — — — — — — — — — — -+
| majobo               |
+ — — — — — — — — — — -+
1 row &lt;span class="k"&gt;in &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;0.00 sec&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We check out whether the table is as we want it:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mysql&amp;gt; describe majobo;&lt;/code&gt;&lt;br&gt;
We get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;+ — — — — — — + — — - — — —- + — — -+ — — — — - - -+ — — — — — — — +
| Field       | Type         | Null | Key | Default | Extra        |
+ — — — — — - + — — — — — -— + — - -+ — - + — — - -+ — — — — — — — +
| job_id      | int&lt;span class="o"&gt;(&lt;/span&gt;11&lt;span class="o"&gt;)&lt;/span&gt;      | NO   | PRI | NULL   | auto_increment|
| job_name    | varchar&lt;span class="o"&gt;(&lt;/span&gt;20&lt;span class="o"&gt;)&lt;/span&gt;  | NO   |     | NULL   |               |
| job_desc    | text         | NO   |     | NULL   |               |
| job_pic_url | varchar&lt;span class="o"&gt;(&lt;/span&gt;255&lt;span class="o"&gt;)&lt;/span&gt; | NO   |     | NULL   |               |
+ — — — — — — -+ — — — — — — + — — — + — — -+ — — -+ — — — — — — — +
4 rows &lt;span class="k"&gt;in &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;0.02 sec&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are in business!&lt;/p&gt;

&lt;p&gt;NOTE: One can store images in a MySQL database, but it is not advisable for speed and stability reasons. Instead store the URLs to the images and other media as shown.&lt;/p&gt;

&lt;h3&gt;
  
  
  ii) Loading the table with Values
&lt;/h3&gt;

&lt;p&gt;There are two ways to load the database with values:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;through the shell prompt&lt;/li&gt;
&lt;li&gt;through uploading data from a text file&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is not only restricted to inserting data but deleting data too through the shell prompt. For data loading through a file, one deletes all the previous entries and makes corrections in the file, and uploads the data again. If the data set entered through the file is large and one need to make a change on one record then that too can be done.&lt;/p&gt;

&lt;h4&gt;
  
  
  a) Insert and Delete through the Shell Prompt
&lt;/h4&gt;

&lt;p&gt;In the real world, the shell prompt is rarely directly used unless the user is adding the odd entry or two. However as MySQL script files are written and run, these instructions would reside in a script file. We are styling the code as if it were in a script file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*** INSERT sample data into majobo ***/&lt;/span&gt;

&lt;span class="k"&gt;insert&lt;/span&gt; &lt;span class="k"&gt;into&lt;/span&gt; &lt;span class="n"&gt;majobo&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;job_desc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;job_pic_url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;values&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'The Warehouse'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Developing a comprehensive website that
  will deliver on all fronts. Client-side was developed in ReactJS.
  Server-side was developed Django REST API and incorporating some
  custom modules'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'https://www.waksnoma.ke/thewarehouse/'&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="cm"&gt;/*** end INSERT ***/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result looks like this, formatted to fit into the page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; from majobo&lt;span class="p"&gt;;&lt;/span&gt;
+ — — — — + — — — — — — — -+ — — — — — — — — -+ — — — — — — — — — +
| job_id  | job_name       | job_desc         | job_pic_url       |
+ — — — — + — — — — — — — -+ — — — — — — — — -+ — — — — — — — — — +
| 1       | The Warehouse  | Developing a comprehensive website that will deliver on all fronts. Client-side was developed &lt;span class="k"&gt;in &lt;/span&gt;ReactJS. Server-side was developed Django REST API and incorporating some custom modules        | https://www.waksnoma.ke/thewarehouse/    |
+ — — — — + — — — — — — — -+ — — — — — — — — -+ — — — — — — — — — +
1 row &lt;span class="k"&gt;in &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;0.00 sec&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will notice that we never put a value for the &lt;code&gt;job_id&lt;/code&gt;. This shows that our &lt;code&gt;auto_increment&lt;/code&gt; is working as it should. We add another set of data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*** INSERT sample data into majobo ***/&lt;/span&gt;

&lt;span class="k"&gt;insert&lt;/span&gt; &lt;span class="k"&gt;into&lt;/span&gt; &lt;span class="n"&gt;majobo&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;job_desc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;job_pic_url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;values&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'aim to succeed'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'This was a graphic design poster job
  that was to introduce the school open day. The client company has
  a group of schools'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s1"&gt;'https://www.waksnoma.ke/waks/aimingposter.jpg'&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="cm"&gt;/*** end INSERT ***/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives us a table that has the following features:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; from majobo&lt;span class="p"&gt;;&lt;/span&gt;
+ - - - -+ - - - - - - - -+ - - - - - - - + - - - - - - - - - - - -+
| job_id | job_name       | job_desc      | job_pic_url            |
+ - - - -+ - - - - - - - -+ - - - - - - - + - - - - - - - - - - - -+
|      1 | The Warehouse  | Developing a comprehensive website that will deliver on all fronts. Client-side was developed &lt;span class="k"&gt;in &lt;/span&gt;ReactJS. Server-side was developed Django REST API and incorporating some custom modules       | https://www.waksnoma.ke/thewarehouse/  |
|      2 | aim to succeed | This was a graphic design poster job that was to introduce the school open day. the client company has a group of schools   | https://www.waksnoma.ke/waks/aimingposter.jpg |
+ - - - - + - - - - - - -+ - - - - - - - + - - - - - - - - - - - - +
2 rows &lt;span class="k"&gt;in &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;0.00 sec&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Question: What if we want to put in content data that,&lt;br&gt;
especially in the description, has an apostrophe, ' ?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's take the above example to illustrate this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*** INSERT sample data into majobo ***/&lt;/span&gt;

&lt;span class="k"&gt;insert&lt;/span&gt; &lt;span class="k"&gt;into&lt;/span&gt; &lt;span class="n"&gt;majobo&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;job_desc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;job_pic_url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="k"&gt;values&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;"Aim to Succeed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nv"&gt;"This was a graphic design poster job that
 was to introduce the school's open day. The client company has a
 group of schools"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nv"&gt;"https://www.waksnoma.ke/waks/aimingposter.jpg"&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="cm"&gt;/*** end INSERT ***/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note however instead of using the single quotation marks to isolate the data into strings, double quotation marks are used instead. This way the description will allow the “… school’s open day …” to enter into the database without issues. So our database now has:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; from majobo&lt;span class="p"&gt;;&lt;/span&gt;
+ - - - - + - - - - - - -+ - - - - - - - + - - - - - - - - - - - - +
| job_id  | job_name     | job_desc      | job_pic_url             |
+ - - - - + - - - - - - -+ - - - - - - - + - - - - - - - - - - - - +
|       1 | The Warehouse | Developing a comprehensive website that will deliver on all fronts. Client-side was developed &lt;span class="k"&gt;in &lt;/span&gt;ReactJS. Server-side was developed Django REST API and incorporating some custom modules      | https://www.waksnoma.ke/thewarehouse/        |
|       2 | aim to succeed | This was a graphic design poster job that was to introduce the school open day. the client company has a group of schools | https://www.waksnoma.ke/waks/aimingposter.jpg   |
|       3 | Aim to Succeed | This was a graphic design poster job that was to introduce the school&lt;span class="s1"&gt;'s open day. The client company has a group of schools | https://www.waksnoma.ke/waks/aimingposter.jpg |
+ - - - - + - - - - - - -+ - - - - - - - + - - - - - - - - - - - - +
3 rows in set (0.00 sec)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;NOTE: Double quotation marks work just as well as single quotation marks in defining strings in the data. This is true in a number of programming and scripting languages.&lt;/p&gt;

&lt;p&gt;Sadly, in the &lt;code&gt;majobo&lt;/code&gt; table, there are two entries that look similar and they need to be removed. We will remove entry id=2 and id=3.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; delete from majobo where job_name &lt;span class="o"&gt;=&lt;/span&gt; ‘Aim to Succeed’ order by job_id limit 2&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; from majobo&lt;span class="p"&gt;;&lt;/span&gt;
+ - - - - + - - - - - - -+ - - - - - - - + - - - - - - - - - - - - +
| job_id | job_name      | job_desc      | job_pic_url             |
+ - - - - + - - - - - - -+ - - - - - - - + - - - - - - - - - - - - +
|      1 | The Warehouse | Developing a comprehensive website that will deliver on all fronts. Client-side was developed &lt;span class="k"&gt;in &lt;/span&gt;ReactJS. Server-side was developed Django REST API and incorporating some custom modules | https://www.waksnoma.ke/thewarehouse/ |
+ - - - - + - - - - - - -+ - - - - - - - + - - - - - - - - - - - - +
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To clear the entire table, the command is:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mysql&amp;gt; delete from majobo;&lt;/code&gt;&lt;br&gt;
Checking the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; from majobo&lt;span class="p"&gt;;&lt;/span&gt;
Empty &lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;0.00 sec&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;Resetting the AUTO_INCREMENT&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Since we have erased all the data from the table, we need to reset our auto_increment in order for us to have data integrity.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; alter table majobo auto_increment &lt;span class="o"&gt;=&lt;/span&gt; 0&lt;span class="p"&gt;;&lt;/span&gt;
Query OK, 0 rows affected &lt;span class="o"&gt;(&lt;/span&gt;0.14 sec&lt;span class="o"&gt;)&lt;/span&gt;
Records: 0 Duplicates: 0 Warnings: 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  b) Insert data from a File
&lt;/h4&gt;

&lt;p&gt;The data to be put into &lt;code&gt;majobo&lt;/code&gt; can be loaded from a file in either a remote location or from the local drive.&lt;/p&gt;

&lt;p&gt;Here is a view of our text file with in plain text with tab separated values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    The Warehouse   The client is an art and entertainment facilitator. The web space was required to showcase the various groups that they are involved with. It is a multimedia site with blogs and comments.     https://www.waksnoma.ke/waks/thewarehouse/
    Aim to Succeed  This was a graphic design poster job that was to introduce the school open day. The client company has a group of schools and the poster was to be put up in selected shopping centres and malls.   https://www.waksnoma.ke/waks/aimingposter.jpg
    Oiling Life The client is an established petroleum company that needed a company brochure of all their lubricating products. The brochure was to be given to the company's service stations and car speciality shops.   https://www.waksnoma.ke/waks/oilinglife.pdf
    Dying to Give   The main piece was a video documentary on the state of organ donation in East Africa and what needs to be done to make sure that the awareness is raised of this selfless giving. The client is a major cardiological hospital. https://www.waksnoma.ke/waks/dyingtogive.mov
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Depending on where the file is on your local drive, our instructions to load it are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; load data &lt;span class="nb"&gt;local &lt;/span&gt;infile ‘[absolute_path]/mawaks.txt’ into table majobo&lt;span class="p"&gt;;&lt;/span&gt;
Query OK, 4 rows affected, 4 warnings &lt;span class="o"&gt;(&lt;/span&gt;0.00 sec&lt;span class="o"&gt;)&lt;/span&gt;
Records: 4 Deleted: 0 Skipped: 0 Warnings: 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our table now looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; from majobo&lt;span class="p"&gt;;&lt;/span&gt;
+ - - - - + - - - - - - -+ - - - - - - - + - - - - - - - - - - - - +
| job_id | job_name      | job_desc      | job_pic_url             |
+ - - - - + - - - - - - -+ - - - - - - - + - - - - - - - - - - - - +
|      1 | The Warehouse  | The client is an art and entertainment facilitator. The web space was required to showcase the various &lt;span class="nb"&gt;groups &lt;/span&gt;that they are involved with. It is a multimedia site with blogs and comments.  | https://www.waksnoma.ke/waks/thewarehouse/  |
|      2 | Aim to Succeed | This was a graphic design poster job that was to introduce the school open day. The client company has a group of schools and the poster was to be put up &lt;span class="k"&gt;in &lt;/span&gt;selected shopping centers and malls. |
https://www.waksnoma.ke/waks/aimingposter.jpg |
|      3 | Oiling Life    | The client is an established petroleum company that needed a company brochure of all their lubricating products. The brochure was to be given to the company&lt;span class="s1"&gt;'s service stations and car speciality shops.  |
https://www.waksnoma.ke/waks/oilinglife.pdf   |
|      4 | Dying to Give  | The main piece was a video documentary on the state of organ donation in East Africa and what needs to be done to make sure that the awareness is raised of this selfless giving. The client is a major cardiological hospital. | https://www.waksnoma.ke/waks/dyingtogive.mov  |
+ - - - - + - - - - - - -+ - - - - - - - + - - - - - - - - - - - - +
4 rows in set (0.00 sec)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Going back to our assignment, let us lay out our table in a way we can see its design.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql&amp;gt; describe majobo&lt;span class="p"&gt;;&lt;/span&gt;
+ - - - - + - - - - - - -+ - - - - - - - + - - - - - - - - - - - - +
| Field       | Type         | Null | Key | Default | Extra        |
+ - - - - + - - - - - - -+ - - - - - - - + - - - - - - - - - - - - +
| job_id      | int&lt;span class="o"&gt;(&lt;/span&gt;11&lt;span class="o"&gt;)&lt;/span&gt;      | NO   | PRI | NULL  | auto_increment |
| job_name    | varchar&lt;span class="o"&gt;(&lt;/span&gt;20&lt;span class="o"&gt;)&lt;/span&gt;  | NO   |     | NULL    |              |
| job_desc    | text         | NO   |     | NULL    |              |
| job_pic_url | varchar&lt;span class="o"&gt;(&lt;/span&gt;255&lt;span class="o"&gt;)&lt;/span&gt; | NO   |     | NULL    |              |
+ - - - - + - - - - - - -+ - - - - - - - + - - - - - - - - - - - - +
4 rows &lt;span class="k"&gt;in &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;0.24 sec&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let us draw a graphical representation of majobo, we get:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F532%2F1%2AotScTIxlSlOIYSeR4UqtLA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F532%2F1%2AotScTIxlSlOIYSeR4UqtLA.png" title="The Mojobo Table" alt="majob0 ERD"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The diagram shown above is an Entity Relationship Diagram. Database ERDs are used to show relationships between tables in database as well as table structures. Because ERDs help visualize table structures and relationships, they often lead us to better database designs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We have built a database and in the process used the most important queries in MySQL, namely, CREATE, USE, DESCRIBE, INSERT, SELECT, DELETE and ALTER.&lt;/p&gt;

&lt;p&gt;I will publish the next part - &lt;strong&gt;Designing a database with MySQL using a Command Line Interface — Part 2&lt;/strong&gt; in a few days.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This article was first published on Medium.com&lt;/em&gt;&lt;/p&gt;

</description>
      <category>mysql</category>
      <category>database</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
