Creating Your First Table

On this page

Data Tables look very similar to spreadsheets in that the table can be visualized in rows and columns. Each row is an individual item and each column is a piece of information about that item.

When designing a database, you need to define what columns you are going to have. For our purposes here, we are going to make a data table that is going to hold articles or other little "blurbs" about our bookstore. There were three:

  • Title
  • Description
  • Active

The first table we are going to create is going to have columns for those three pieces of information as well as the date the article was written which will be put in automatically.

Steps to Creating the Table

1

In MySQL Workbench, connect to your UML database

2

Expand the options under your name and you should see Tables

3

Either Right-Click on Tables and choose Create Table or click on the Create Table Icon in the toolbar.

4

In the Table Name, enter articles.

5

Add the columns id, title, description, createdDate, and status by filling out the column area according to this info:

Field NamePrimary KeyData TypeAuto IncrementDefault Value
idYESINTYES
titleNONvarchar(100)NO
descriptionNOnvarchar(1000)NO
createdDateNOdatetimeNOCURRENT_TIMESTAMP
6

When submitted, the SQL should look something like this:

create table articles
(
    id int auto_increment,
    primary key(id),
    title       nvarchar(100)                      null,
    description nvarchar(1000)                     null,
    createdDate datetime default CURRENT_TIMESTAMP null
);

Click on Apply.

7

Your table should appear under the Tables section in the left hand column.

Lesson 3 of 3 - Connecting to a Database