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
In MySQL Workbench, connect to your UML database
Expand the options under your name and you should see Tables
Either Right-Click on Tables and choose Create Table or click on the Create Table Icon in the toolbar.
In the Table Name, enter articles.
Add the columns id, title, description, createdDate, and status by filling out the column area according to this info:
| Field Name | Primary Key | Data Type | Auto Increment | Default Value |
|---|---|---|---|---|
| id | YES | INT | YES | |
| title | NO | Nvarchar(100) | NO | |
| description | NO | nvarchar(1000) | NO | |
| createdDate | NO | datetime | NO | CURRENT_TIMESTAMP |
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.
Your table should appear under the Tables section in the left hand column.