Create Columns

Return to Introduction  Previous page  Next page

What is a Column?

The basic organizational element of a relational database is the Column. Every individual item of data entered into a relational database is represented as a value in a column of a row in a table. Columns are represented in the UML Data Modeling Profile as a stereotyped attribute; that is, an attribute with the Column stereotype.

Create Columns

Note: For MySQL, before creating columns first add ENUM and SET datatypes. Select the Settings | Database Datatypes menu option and, on the Database Datatypes dialog, in the Product Name field select MySQL. Add the datatypes ENUM and SET.

To create columns, follow the steps below:

·Click on the Column icon on the Data Modeling page of the Enterprise Architect UML Toolbox and drag it onto the name of the Table element; when prompted to do so, type in the column name and data type, then double-click on the column name in the Table
·Right-click on the Table in a diagram to open the context menu, and select the Attributes menu option.
2.The Table n Attributes dialog displays.
3.If you started with the Attributes context menu option, type in the column Name and Data Type and click on the Save button.

Tip: If the drop-down list of datatypes is empty, this means that you have not selected a target database for the table. Close the Columns dialog and re-open the Table Properties dialog to set a Database type before continuing. To prevent this recurring, set the default database type.

4.The following fields for each column are optional:
·Primary Key - select the checkbox if the column represents the primary key for this table
·Not Null - select the checkbox if empty values are forbidden for this column
·Unique - select the checkbox if it is forbidden for any two values of this column to be identical
·Initial - type a value that can be used as a default value for this column, if required
·Access - click on the drop-down arrow and select a scope of Private, Protected or Public (the field defaults to Public)
·Alias - type an alternative name for the field (for display purposes), if any
·Notes - type any other information necessary to document the column.

Note: Some datatypes, such as the Oracle NUMBER type, require a precision and scale. These fields are displayed where required and should be filled in as appropriate. For example, for Oracle:
create NUMBER by setting Precision = 0 and Scale = 0
create NUMBER(8) by setting Precision = 8 and Scale = 0
create NUMBER(8,2) by setting Precision = 8 and Scale = 2.

Note: Oracle VARCHAR2(15 CHAR) and VARCHAR2(50 BYTE) datatypes can be created by adding the tag LengthType with the value CHAR or BYTE.

Note: For MySQL ENUM and SET datatypes, in the Initial field type the values as a comma-separated list, in the format ('one','two','three') or, if one value is the default, in the format: ('one','two','three') default 'three'.

Change the Column Order

To change the column order, follow the steps below:

1.On the Columns dialog, highlight a column name in the Columns panel.
2.Click on the:
·uphand button to move the column up one position
·downhand button to move the column down one position.