In this lesson, you create a table named Products.
For information table design considerations, see Design considerations.
In the right pane of Sybase Central, double-click Tables.
Right-click Tables and choose New » Table.
In the What Do You Want To Name The New Table field, type Products.
The database server creates the table using defaults, and then displays the Columns tab in the right pane. The Name field for the new column is selected and a prompt waits for you to specify a name for the new column.
Type ProductID as the name for the new column.
Since this is the first column in the table, PKey is selected, indicating that the column is the primary key for the table.
When creating a table, you can create a primary key that is made up of more than one columns by creating the columns and placing a checkmark in the PKey column. See Primary keys.
In the Data Type list, select Integer.
Click the ellipsis (three dots) button.
Click the Value tab and choose Default Value » System-Defined » Autoincrement.
An autoincrement value increments for each row added to the table. This ensures that values in the column are unique—a requirement for primary keys. See Primary keys.
From the File menu, choose New » Column.
Complete the following fields:
Add the following tables to your database.
Customers table Add a table named Customers with the following columns:
CustomersID An identification number for each customer. Make sure PKey is selected, set the Data Type to Integer, and set the Default Value to Autoincrement.
CompanyName The name of each company. Set the DataType to Char with a maximum length of 35 characters.
SalesOrders table Add a table named SalesOrders with the following columns:
SalesOrdersID An identification number for each sales order. Set the DataType to Integer, and make sure PKey is selected. Set the Default Value to Autoincrement.
OrderDate The date on which the order was placed. Set the DataType to Date.
CustomerID The identification number of the customer who placed the sales order. Set the DataType to Integer.
SalesOrderItems table Add a table named SalesOrderItems with the following columns:
SalesOrderItemsID The identification number of the sales order of which the item is a part. Set the DataType to Integer, and make sure PKey is selected.
LineID An identification number for each sales order. Set the DataType to Integer, and make sure PKey is selected.
Since PKey is set for both SalesOrderItemsID and LineID, this means the primary key for the table comprises the concatenated values of these two columns.
ProductID The identification number for the product being ordered. Set the DataType to Integer.
From the File menu, choose Save.
|Discuss this page in DocCommentXchange.
Send feedback about this page using email.
|Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1|