When you create domains, defaults and attach them to the columns in a data model, you are actually speeding up the data model creation process by using the predefined datatypes for all the similar columns. Metadata/data in the database and data structures will be consistent across the data models so that conflicts can be reduced. Check constraints enforce some rules on columns in the data model as per your instructions.
In this section, you will see how you can create domain, defaults and check constraints by using TOAD Data Modeler for the sample data shown below. To know more about the definitions and meaning of a domain, defaults and check constraints, please refer our earlier section Data Modeling Objects listed under the category Data Modeling.
Column Name | Data Type |
---|---|
FULL_NAME | NOT NULL |
STREET_NAME | VARCHAR2(30) NOT NULL |
CITY_NAME | VARCHAR2(30) NOT NULL |
GENDER | CHAR(1) NOT NUL |
SSN | CHAR(9) NOT NULL |
RECORD_DATE | DATE NOT NULL |
USER_NAME | VARCHAR2(30) NOT NULL |
Column Name | Data Type |
---|---|
FULL_NAME | NAME_DOMAIN NN |
STREET_NAME | NAME_DOMAIN NN |
CITY_NAME | NAME_DOMAIN NN |
GENDER | Char(1) NN |
SSN | Char(9) NN |
RECORD_DATE | Date NN |
USER_NAME | NAME_DOMAIN NN |
Note: NN means NOT NULL.
In few columns, you see NAME_DOMAIN. The domain that you attached is displayed here instead of data type.
CREATE TABLE “DOMAIN_RULE_DEFAULT”(
“FULL_NAME” Varchar2(30 ) NOT NULL,
“STREET_NAME” Varchar2(30 ) NOT NULL,
“CITY_NAME” Varchar2(30 ) NOT NULL,
“GENDER” Char(1 ) NOT NULL CONSTRAINT “GENDER_CHECK” CHECK (GENDER IN (‘M’, ‘F’)),
“SSN” Char(9 ) NOT NULL CONSTRAINT “SSN_CHECK” CHECK (SSN BETWEEN (‘000000001’ AND ‘999999999’)),
“RECORD_DATE” Date DEFAULT Sysdate NOT NULL,
“USER_NAME” Varchar2(30 ) DEFAULT USER NOT NULL)
Learn data modeling design Skills on OLTP and OLAP from a US University Professor with…
These SQL commands are related with Oracle's data dictionary and can be used to get…
important DDL Statements from Oracle like Commit, Rollback, Grant, Revoke etc..
In this section, we will try to explain about important database DROP commands that are…
In this section, we will try to explain about important database DML commands that are…
In this section, we will try to explain about important database ALTER commands that are…