>forward engineering Oracle8 with Rational Rose... example
Below is a simple example of creating two tables and
a Foreign Key between them.
1. Create a DataBase Component to match the database you
are working with.
a. Hightlight Component View in Rose browser, right click,
Data Modeler:New:Database
b. Double click on this Component icon in browser to open
up specification.
Set name = Database name
Set Target = Database language
2. Create a new schema.
a. Tools:Data Modeler:Add Schema
-or-
Hightlight Logical View in Rose browser, right click,
Data Modeler:New:Schema
(This will create 2 packages under the Logical View, one called
Schemas and then within schemas another one called schema S_0)
b. Double click on this Schema icon (S_0) in browser to open
up specification.
Set Name = your schema name
Set Database = Database name you created in step 1.
3. Create a Data Model Diagram.
a. Right click on the schema package in the Rose browser,
Data Modeler:New:Data Model Diagram.
This creates a Diagram under the Package Schema
b. Double click on the Diagram to open.
4. Create a table.
a. Now you can use the toolbar to add tables. After adding
the table to the diagram, double click on the table to open
table specification, go to column tab to add columns, right
click, insert. Select PK check box if you wish to make this a
Primary Key.
b. Double click on column to open up column specification,
set type and constraints.
5. Create another table following the same steps a #4.
6. Create a Foreign Key by adding a indentifying or
non-identifing relationship from the toolbar and connect it
between the two tables.
Regarding Identifying and Non-identifying relationships:
Identifying relationships represent composite aggregations,
An Identifying relationship specifies that a child object cannot
exist without the parent object. To enforce the rule, the foreign
key in the child object also becomes part of that object�s primary
key, thus creating a composite aggregation.
Non-identifying relationships represent associations,
A Non-identifying relationship specifies a regular association
between objects. It uses a 1:1 or 1:n cardinality. Non-identifying
relationships can be specified as optional where a parent is not
required or mandatory where a parent is required by setting the
parent table cardinality. To specify a relationship as optional
set the parent cardinality to 0..1. To specify a relationship as
mandatory set the parent cardinality to 1.
Consider the following example,
Two tables Parent and Child.
Each contains one column; Parent_ID & Child_ID,
which are their respective primary keys.
Notice that with Identifying relation, the primary
key in the child is a concatination of the two
primary keys:
//** Non-Identifying
CREATE TABLE Parent (
Parent_ID NUMBER ( 5 ) NOT NULL,
CONSTRAINT PK_Parent2 PRIMARY KEY (Parent_ID)
);
CREATE TABLE Child (
Parent_ID NUMBER ( 5 ) NOT NULL,
Child_ID NUMBER ( 5 ) NOT NULL,
CONSTRAINT PK_Child3 PRIMARY KEY (Child_ID)
);
ALTER TABLE Child ADD ( CONSTRAINT FK_T_14 FOREIGN KEY (Parent_ID)
REFERENCES Parent (Parent_ID));
//** Identifying
CREATE TABLE Parent (
Parent_ID NUMBER ( 5 ) NOT NULL,
CONSTRAINT PK_Parent2 PRIMARY KEY (Parent_ID)
);
CREATE TABLE Child (
Child_ID NUMBER ( 5 ) NOT NULL,
Parent_ID NUMBER ( 5 ) NOT NULL,
CONSTRAINT PK_Child3 PRIMARY KEY (Parent_ID, Child_ID)
);
ALTER TABLE Child ADD ( CONSTRAINT FK_Child5 FOREIGN KEY (Parent_ID)
REFERENCES Parent (Parent_ID));
To generate code, hightlight <<schema>> schema_name in Rose browser,
right click, Data Modeler:Forward Engineer.
For more help see on line help, contents tab, Rose Data Modeler,
How to.
Patrick Kennedy
Rational Support
************************************************************************
* Rose Forum is a public venue for ideas and discussions.
* For technical support, visit http://www.rational.com/support
*
* Admin.Subscription Requests: [EMAIL PROTECTED]
* Archive of messages:
http://www.rational.com/products/rose/usergroups/rose_forum.jtmpl
* Other Requests: [EMAIL PROTECTED]
*
* To unsubscribe from the list, please send email
*
* To: [EMAIL PROTECTED]
* Subject:<BLANK>
* Body: unsubscribe rose_forum
*
*************************************************************************