Previous | Table of Contents | Next

Page 539

Figure 20.2.
Creating a table.

As shown in Figure 20.3, fill in these fields in the Table folder:
Name STUDENT
Display Title Student
Number of Rows, Start/End An estimate of the number of rows that will initially/ultimately be stored in the table (used to estimate the size of the initial extent for the table)
Comment Contains basic information about students.
Journal Checked. When used with Designer/2000, it indicates that a journal table should be created for this table (a journal table is used to store all changes to a table, including who was responsible for the change and when it was made).

Page 540

Figure 20.3.
Specifying the table
characteristics.

Specifying the Columns for a Table

To specify the columns in the Student table, select the tab folder labeled Column Defn. You will see five column headings displayed: Column Name, Seq, Domain, Datatype, and Avg Len. However, there are more fields to the right of Avg Len that can be displayed by using the horizontal scrollbar. In this form, each row represents information about a single column (see Figure 20.4). To add a column to the Student table, specify a value for these fields:

Column Name The name of the column (for example, Student_ID)
Seq The order in which the columns should be specified in the CREATE TABLE statement generated by Database Designer
Domain May be left blank (can be used with Designer/2000 to define each domain and the attributes that are associated with the domain)
Datatype The datatype of the column can be specified from the popup list
Avg len Average length of the column (this is used for estimating the size of the initial extent for the table)

If you scroll to the right, you will see some other fields displayed, including (see Figure 20.5):

Max Len The maximum length for the column (which you may or may not specify, depending on the datatype of the column).
Opt If checked, the column is optional (the default); if not checked,the column is mandatory (NOT NULL).

Page 541

Figure 20.4.
Defining a column.

Figure 20.5.
Additional fields for
defining a column.

Specifying a Table's Constraints

To specify a table's constraints, select the Constraints tab folder. Within the Constraints tab folder, you will see four other tab folders that correspond to the four types of constraints: Primary, Foreign, Unique, and Check. To specify the primary key for the Student table, enter the constraint name, and select the Student_ID column from the poplist labeled Column Name (see Figure 20.6).

Page 542

Figure 20.6.
Specifying the primary
key.

The Student table has another constraint: a CHECK constraint on Year to ensure that it is either FRESHMAN, SOPHOMORE, JUNIOR, or SENIOR. To create this constraint, select the Validation tab folder. Select the column whose values you want to validate—in this case, YEAR. Enter each valid value for the column, as shown in Figure 20.7.

Figure 20.7.
Specifying the
validation for a
column.

Page 543

When you are finished specifying the table's characteristics, click OK. The table will be displayed in the diagram with the characteristics that you specified. As you can see in Figure 20.8, the # is displayed to the left of Student_ID, signifying that the column is the primary key. Also, all mandatory columns have a * displayed to their left.

Figure 20.8.
The created table
is displayed in a
diagram.

Specifying a Foreign Key

To follow the steps that are used to create a foreign key, let's refer to an existing diagram that has two tables: Department and Instructor. As you can see in Figure 20.9, the Instructor table doesn't contain Department_ID, which identifies the department with which the instructor is associated.

To create a mandatory foreign key in the Instructor table, select the Mandatory Foreign Key button on the tool bar (it is commonly referred to as a crow's foot). Notice that the mouse pointer has now changed to the crow's foot. Move the crow's foot over the Instructor table. Left-click on the Instructor table; drag the crow's foot over the Department table and left-click. You should now notice two things (as shown in Figure 20.10):

Page 544

Figure 20.9.
Existing diagram
containing two tables
without a relation-
ship.

Figure 20.10.
The foreign key is
created.

Page 545

To edit the foreign key, double-click the line that defines the foreign key. A window, labeled Edit Foreign Key, will appear (see Figure 20.11). For this foreign key, the default values do not need to be changed.

Figure 20.11.
Editing the foreign
key.

Generating the DDL Statements for the
Diagram

Database Designer provides a Generation Wizard that guides you through the process of generating a database schema from your ER diagram. To invoke the Generation Wizard, you can select Tools | Generation Wizard from the menu. The first window displayed by the Generation Wizard simply informs you that you can generate database objects to a file or to a database (see Figure 20.12). Click Next to proceed to the next window.

In the next window, you must indicate where you want to create the database objects—to a file that contains the DDL statements which will build your database or directly to a database. By default, the DDL statements will be directed to an SQL file (see Figure 20.13). Click Next to proceed to the next window.

In the next window, you can restrict the generation of database objects to specific object types. However, by default, all database objects will be generated (see Figure 20.14).

Previous | Table of Contents | Next

Используются технологии uCoz