Set and edit data types in Database Model diagrams
You can think of data types as rules that restrict the kind of information that can be entered into each column of a table in a database. For example, if you want to make sure no one enters a name in a field that is supposed to have only dates, you set the data type of that field to a date data type. Data types are set for each column in the Database Properties window when you first create a table.
What do you want to do?
Set data types for the columns in a database model table
-
Double-click the shape for the table that has the columns that you want to set data types for.
-
In the Database Properties window, under Categories, click Columns.
-
Click the cell in the Data Type column that you want to change.
-
Click the down arrow next to the current data type and choose a different data type from the list.
Choose between portable and physical data types
Portable data types are generically defined types that map to similar, compatible physical data types in different database systems. Physical data types are the data types the target database supports. For example, if you have the driver set as Access, any data types available in Microsoft Office Access are available as physical data types in your model.
-
Double-click the shape for the table that has the columns that you want to set data types for.
-
In the Database Properties window, under Categories, click Columns.
-
Below the list of columns, click either Portable data types or Physical data types.
-
Portable data types are generically defined types that map to similar, compatible physical data types in different database systems.
-
Physical data types are dictated by the database driver set for the model. To understand more about the data types for your driver, see the documentation for its target database management system (DBMS).
-
Change which set of physical data types is available
Different database management systems support different physical data types. For example, if you have the driver set as Access, any data types available in Access are available as physical data types in your model. If you don't see the data types that you expect, you may need to change the driver that you have set in the Driver Options dialog box.
To use the set of data types for the DBMS in your model, set the drivers to that system in the Driver Options dialog box.
-
Determine which database driver is set for the diagram.
-
Double-click a table, and in the Database Properties window under Categories click Columns.
-
Look below the list of columns, beside the choices for portable and physical data types.
-
Note the target database management system that is shown in parentheses.
-
-
Change the target database driver.
-
On the Database menu, point to Options, and then click Drivers.
-
On the Drivers tab, select the Visio driver for your target database management system.
-
Click Setup and select the check box for the appropriate ODBC driver.
-
Create a user-defined data type
User-defined data types are custom data types that you can create and reuse in the database model they are created in. This might occur, for example, if your table has a column with a number data type for asset tracking. But you know that you may be changing from a number to character based asset tracking system. If you use a user-defined data type you can change its properties from number to character at any time. This changes all affected columns with that type, but doesn't change any other columns that have a number data type.
-
On the Database menu click User Defined Types.
-
In the User-Defined Types dialog box, click Add.
-
In the Add New User-Defined Type dialog box, enter a name.
-
To base your new data type on an existing data type, select the Copy From check box, and then select the name of an existing user-defined data type.
-
Click OK. Specify portable data type characteristics for the data type.
-
Click OK.
Set a collection type for a column
Collection types allow multiple values to be stored in a field. For example if you have a table with information about music, you may want a collection type for genre with Classical, Popular, and Folk. Collection types can optimize the performance of a database by storing data in a single entity instead of using foreign keys and secondary tables.
-
Double-click the table with the column you want to specify as a collection type.
-
In the Database Properties window, under Categories, click the Columns.
-
Click the column you want to set as a collection type, and then click Edit.
-
In the Column Properties dialog box, click the Collection tab, and then choose one of the following collection types:
-
Unordered, Non-Repeating Group Of Values (Set) Allows population instances of a field in a column to have multiple values, but each value must be unique. The values do not have any associated sorting criteria; therefore they are unordered.
-
Ordered Group Of Values (List) Creates an ordered collection of elements that allows duplicate elements. Each element in the collection has an ordinal position. An ordinal position is a position by which a value can be accessed. Because two values can be the same, they are differentiated by their ordinal positions.
-
Unordered, Repeating Group Of Values (Multiset) Creates a collection of elements that can have duplicate values. The elements do not have ordinal positions.
-
-
Click OK to close the Column Properties dialog box.
Create a composite data type with the Type shape
The Database Model Diagram template supports both relational and object-relational database models, so you can work with both simple and composite data types. Simple data types, used by both relational and object-relational databases, support one data value per column. Object-relational databases also support composite data types, in which a column can contain multiple values or fields; each field can have a different data type. For example, you might define an address as a composite data type that includes columns for street, city, state, and postal code.
-
Drag a Type shape from the Object Relational stencil into your database model diagram.
-
Double-click the Type shape to open the Database Properties window and then, under Categories, click Fields.
-
Click in a blank line and begin typing a new Physical Name to add a field.
-
Specify a data type by typing or by selecting one from the list for that field.
-
To prevent null values, select the check box in the Req'd column.
-
To define the Type as Named, Distinct, or Domain, under Categories, click Definition.
-
Select the options you want:
-
Named row type Select to specify that the type is not an alias of any other type.
-
Distinct type Select to specify that the type is based on another type and has the same representation as the type on which it is based, but is an entirely distinct type of its own.
If you select this option, you will not be able to select options on the Fields category.
-
Domain Select to specify that the type is an alias of another type; it is an indirect representation of the same type.
If you select this option the Alias Collection Type option becomes available and you will not be able to select options in the Fields category.
-
Alias collection type (visible only if Domain is selected) Select an option to specify whether an attribute's value is a collection of a single value, set, list, or multi-set. In relational databases, all attribute collection types are single values. Object relational databases allow you to specify the additional collection types.
-
Assign a composite data type to a column
If you create a composite type with the Type shape you can assign it to a column, thereby defining the column as having all the columns of the type. For example, you may have a table with columns ID, Name, Address, where Address is a type composed of the columns Street, City, State, and Postal Code.
-
Double-click the table in which you want to use the composite data type.
-
In the Database Properties window, under Categories, click Columns.
-
Click the down arrow next to the current data type and choose another from the list.
Create a typed table
If you create a composite type with the Type shape you can assign it to a table, thereby defining all the columns of the table based on the type. For example, if you have a type with columns One, Two, and Three, you can assign that type to the table and the table automatically contains those columns.
Note: This can only be done with an empty table.
-
Drag an Entity shape onto the model diagram.
-
Double-click the table and in the Database Properties window, under Categories, click Definition.
-
Click the down arrow next to the current data type and choose another from the list.
No comments:
Post a Comment