How to Generate a Script from a Diagram in MySQL Workbench

To generate a script from a diagram in MySQL Workbench:

  1. Select File > Export > Forward Engineer SQL CREATE Script...
  2. Enter a location to save the file (optional) and set options to include on the script (such as DROP statements etc), then click Continue
  3. Exclude any objects by deselecting them, otherwise leave them as is, then click Continue
  4. The script is generated. You can copy it to your clipboard or click Finish to save it to a file

Continue reading

How to Create a New Database Diagram using MySQL Workbench

To create a new database diagram using MySQL Workbench:

  1. Click File > New Model from the menu
  2. Create a new schema by clicking the + icon next to Physical Schemas
  3. Add tables by clicking Add Tables, then add/configure their columns in the bottom pane.
  4. Create relationships and any other configurations by using the various tabs
  5. Create a diagram by clicking Model > Create Diagram from Catalog Objects

The diagram will be created. You can rearrange the tables to a more suitable layout by clicking and dragging.

Continue reading

What is MySQL Workbench?

MySQL Workbench is a graphical tool for working with MySQL.

MySQL Workbench provides an easy to use interface for performing the many tasks involved when working with databases. It integrates SQL development, administration, database design, creation and maintenance into one visual integrated development environment.

MySQL Workbench is similar to SQL Server’s SSMS, which is used for administering SQL Server.

Continue reading

What is an Orphaned Record?

An orphaned record is a record whose foreign key value references a non-existent primary key value.

Orphaned records are a concept within database relationships. If a row in a related table references a non-existent row in the primary table, it is said to be an orphaned row. This is because it has no “parent” with which its data is associated with. The terms orphaned row and orphaned record tend to be used interchangeably, even though there’s a subtle difference between a row and a record.

Continue reading

What is Referential Integrity?

Referential integrity refers to the accuracy and consistency of data within a relationship.

In relationships, data is linked between two or more tables. This is achieved by having the foreign key (in the associated table) reference a primary key value (in the primary – or parent – table). Because of this, we need to ensure that data on both sides of the relationship remain intact.

So, referential integrity requires that, whenever a foreign key value is used it must reference a valid, existing primary key in the parent table.

Continue reading

What is Data Integrity?

The term data integrity refers to the accuracy and consistency of data.

When creating databases, attention needs to be given to data integrity and how to maintain it. A good database will enforce data integrity whenever possible.

For example, a user could accidentally try to enter a phone number into a date field. If the system enforces data integrity, it will prevent the user from making these mistakes.

Maintaining data integrity means making sure the data remains intact and unchanged throughout its entire life cycle. This includes the capture of the data, storage, updates, transfers, backups, etc. Every time data is processed there’s a risk that it could get corrupted (whether accidentally or maliciously).

Continue reading