• About Heli

HeliFromFinland

~ Heli's thoughts on Database Designing, Oracle SQL Developer Data Modeler, User Groups etc.

HeliFromFinland

Category Archives: Database design

General issues about database design

Generate REST services

17 Friday Apr 2020

Posted by Helifromfinland in Data Modeler, Database design

≈ 2 Comments

While generating the DDLs for the table you can also generate the REST services for the table easily.

To generate the DDL select File, Export, DDL File.

ddl

Then select the RDBMS Site and the relational model wanted and press Generate.

ddl2

Select Generate REST Services.

ddl3

And the script now not only includes the table generation (and whatever else you chose) but also REST enabling scripts.

ddl4

P.S. If you want to isolate the tables from users with views, you can easily create a view for a table (and then grant privileges to views instead of tables). Just like described above you can create the REST services for views as well.

To create the views for tables select Tools, Table to View Wizard.

view

Select the tables wanted.

view3

And then generate the DDLs as described.

view2

 

Reporting with Data Modeler 17.3

28 Saturday Oct 2017

Posted by Helifromfinland in Data Modeler, Database design

≈ Leave a comment

In version 17.3 there are some changes in the reporting user interface. The reporting itself works as before.

The reporting form has been devided into two tabs: General and Objects.

General includes things that define how the report looks like, including templates and output formats:

reporting1

You can also define the Company name, some reporting preferences, Reports Directory and Saxon XSLT 2.0 jar file path in the General tab. The defaults can be set in Preferences as before:

reporting3

And Objects tab include selecting the source (open design/reporting repository) and configurations (which objects will be included to the report):

reporting2

 

Default System Types Directory

13 Friday Oct 2017

Posted by Helifromfinland in Data Modeler, Database design

≈ 3 Comments

Why would I define the Default System Types Directory in Preferences?

SystemTYpes

If that directory has been defined you do not need to worry about domains etc. when upgrading Data Modeler. All the system type kind of things are automatically available even though you upgrade.Things like:

Report templates
Report configurations
Saved searches
Custom report templates
Domains
RDBMS Sites
Custom Scripts
Types
Global Design Level Settings

And you can also add this directory to version control to be able to keep track of the changes…

 

Sharing Design Properties/Design Level Settings

12 Thursday Oct 2017

Posted by Helifromfinland in Data Modeler, Database design

≈ Leave a comment

I have defined the Naming Standards, Templates etc for one design and I would like to have those same settings for another design I am working on. How can I do that?

You can do that using the Export/Import functionality. Open the design that has the right settings. Go to either Design Properties or Design Level Settings and select Export.

Export.jpg

Save the file. Remember to add the extension xml.

Open the design you want to implement those settings. Select Import and find the file with the exported settings. Press Open. Now the Design Properties/Design Level Settings are the same as in the original design.

 

P.S. If you want ALL your designs having the same design level settings simply check the “Use global design level settings” box and no need to do any export/import.

P.S.2. You might be interested in this too: helifromfinland.blog/2017/10/13/default-system-types-directory/

 

Design Level Settings

12 Thursday Oct 2017

Posted by Helifromfinland in Data Modeler, Database design

≈ Leave a comment

I am sure you remember there are Preferences and Design Properties in Data Modeler. Preferences affect all the designs in a Data Modeler installation (in that computer) whileas Design Properties affect only that design they are defined for.

 

Now in Data Modeler 17.3 you can find those Design Properties also under Tools menu by a name Design Level Settings:

DesignL0

 

These are the sames you can still find under Design Properties too and you should definitely check them (either under Design Properties or Design Level Settings), because they are important.

DesignL1

 

 

P.S. You might be interested in this too: helifromfinland.blog/2017/10/13/default-system-types-directory/

 

 

Where are my domains?

12 Thursday Oct 2017

Posted by Helifromfinland in Data Modeler, Database design

≈ Leave a comment

I just upgraded Data Modeler to the latest release/installed Data Modeler to a new computer but all my domains are gone. Is there any way to get them back or do I need to define them manually again? Of course there is a way!

Select File, Import, Domains.

Domains1

Then find the file your domains are saved to using Open Domain File.

Domains2

Import.

Domains3

Go and check the domains.

Domains4

And there they are.

P.S. You might be interested in this too: helifromfinland.blog/2017/10/13/default-system-types-directory/

 

How can I change the table/column names to uppercase?

11 Wednesday Oct 2017

Posted by Helifromfinland in Data Modeler, Database design

≈ 6 Comments

When I desing the ER model I want to use mixed case naming but in my tables I want to have all the names uppercase. Is there a way to automatically change the names uppercase? YES!

Upper1

These are my tables and as you can see the names of the tables and some of the columns are very mixed cased notation. What I need now is a Transformation Script:

Upper11

In the Custom Trasformation Scripts I can find a script called Tables to upper case – Rhino.

Upper15

I press Apply. And this is what I get:

Upper2

 

How can I create triggers automatically for the journaling columns?

11 Wednesday Oct 2017

Posted by Helifromfinland in Data Modeler, Database design

≈ 6 Comments

Every single table in our database has columns USER_CREATED, USER_MODIFIED, DATE_CREATED, DATE_MODIFIED. Is there a way to get Data Modeler to create the triggers for inserting data to those columns? YES!

The thing you need is Table DDL Transformation:

TableDDL1

 

Define a new Table DDL Transformation Script set (in my example Trigger_for_Technical_Column):

TableDDL2

Define a After Create script and write something like this to it (thank you Marko Helskyaho 🙂 ):

/*
variable ddlStatementsList should be used to return the list with DDL statements
that are created by script – as shown below:
ddlStatementsList.add(new java.lang.String(ddl));
other available variables:
– model – relational model instance
– pModel – physical model instance
– table – the table in relational model
– tableProxy – table definition in physical model
*/
var ddl;
var lname;
// trigger name prefix
trgPre = “BIU_”;
// trigger name suffix
trgSuf = “_TRG”;
prompt = model.getAppView().getSettings().isIncludePromptInDDL();
useSchema = model.getAppView().getSettings().isIncludeSchemaInDDL();
if(model.getStorageDesign().isOpen()){
if(useSchema){
lname = tableProxy.getLongName();
}else{
lname = tableProxy.getName();
}
}else{
if(useSchema){
lname = table.getLongName();
}else{
lname = table.getName();
}
}

if(prompt){
ddl= “\nPROMPT Creating Trigger for ‘”+lname+”‘;\n”;
}else{
ddl = “\n”;
}
ddl = ddl +
“CREATE OR REPLACE TRIGGER “+trgPre+lname+trgSuf +”\n”+
” BEFORE \n” +
” INSERT OR \n” +
” UPDATE ON “+lname+” FOR EACH ROW \n” +
” BEGIN \n” +
” IF INSERTING THEN \n” +
” :NEW.DATE_CREATED := SYSDATE; \n” +
” :NEW.USER_CREATED := NVL(WWV_FLOW.G_USER,USER); \n” +
” END IF; \n” +
” :NEW.DATE_MODIFIED := SYSDATE; \n” +
” :NEW.USER_MODIFIED := NVL(WWV_FLOW.G_USER,USER); \n” +
” END; \n” +
” /”
ddlStatementsList.add(new java.lang.String(ddl));

You can immediatelly test it. Select one of your tables as Table To Test (in my example Isa) and press Test. This is what I got:

TableDDL3

Looks what I wanted but how can I use this script?

When generating DDLs select Include Table DDL Scripts tab. Then select the script from Active Script Set list and select those tables you want to execute it:

TableDDL4

OK. And this is what I got:

CREATE TABLE isa (
avain_uusi NUMBER(16) NOT NULL,
jokumuu VARCHAR2(50 CHAR) NOT NULL,
user_created VARCHAR2(50 CHAR) NOT NULL,
user_modified VARCHAR2(50 CHAR),
date_created DATE NOT NULL,
date_modified DATE
);

ALTER TABLE isa ADD CONSTRAINT isa_pk PRIMARY KEY ( avain_uusi );

CREATE OR REPLACE TRIGGER BIU_Isa_TRG
BEFORE
INSERT OR
UPDATE ON Isa FOR EACH ROW
BEGIN
IF INSERTING THEN
:NEW.DATE_CREATED := SYSDATE;
:NEW.USER_CREATED := NVL(WWV_FLOW.G_USER,USER);
END IF;
:NEW.DATE_MODIFIED := SYSDATE;
:NEW.USER_MODIFIED := NVL(WWV_FLOW.G_USER,USER);
END;
/

CREATE TABLE lapsi (
avainlapsi NUMBER(16) NOT NULL,
lisatieto VARCHAR2(50 CHAR) NOT NULL,
avain_uusi NUMBER(16) NOT NULL,
user_created VARCHAR2(50 CHAR) NOT NULL,
user_modified VARCHAR2(50 CHAR),
date_created DATE NOT NULL,
date_modified DATE
);

ALTER TABLE lapsi ADD CONSTRAINT lapsi_pk PRIMARY KEY ( avainlapsi,avain_uusi );

CREATE OR REPLACE TRIGGER BIU_lapsi_TRG
BEFORE
INSERT OR
UPDATE ON lapsi FOR EACH ROW
BEGIN
IF INSERTING THEN
:NEW.DATE_CREATED := SYSDATE;
:NEW.USER_CREATED := NVL(WWV_FLOW.G_USER,USER);
END IF;
:NEW.DATE_MODIFIED := SYSDATE;
:NEW.USER_MODIFIED := NVL(WWV_FLOW.G_USER,USER);
END;
/

ALTER TABLE lapsi
ADD CONSTRAINT lapsi_isa_fk FOREIGN KEY ( avain_uusi )
REFERENCES isa ( avain_uusi );

 

 

How can I get technical columns to the relational model?

11 Wednesday Oct 2017

Posted by Helifromfinland in Data Modeler, Database design

≈ Leave a comment

I always define columns like USER_CREATED, USER_MODIFIED, DATE_CREATED, DATE_MODIFIED for my tables but I would not like to design them in the logical model. Is there a way to get them automatically to the relational model? YES!

Here’s my logical model. None of my entities has those attributes defined.

TempTable0

 

First design a table that only has those technical columns, nothing else. In my example a table is called TempTable:

TempTable1

 

Then when Engineering to Relational Model select General Options, Use Template Table and select this table from the list:

TempTable2

Engineer.

Now all the tables you just generated to a relational model has these columns:

TempTable3

 

 

 

 

OTN Appreciation Day: Constraints

11 Tuesday Oct 2016

Posted by Helifromfinland in Database design, Events, Oracle

≈ 2 Comments

My favourite feature in a database is constraints: Primary Key, Foreign Key, Unique Key, Not NULL, etc.

Why? Because I like to have good quality data in my databases! The only way to have a good quality data is to design the databases and use constraints whenever possible.

To avoid duplicate data I use Primary Key and Unique Key Constraints, to avoid orphan records in child tables I use Foreign Key Constraints and to avoid data nobody can understand (NULLs!) I use Not NULL constraints. I can also define CHECK constraints to define a condition for each row in the table, the data is not accepted to the table unless it meets the criteria defined in a constraint. A simple example of a CHECK Constraint would be a list of values for a column, for example each row must have either “Yes” or “No” as a value for the column. A CHECK constraint can only be defined for columns in one table, not columns in several tables nor all the data in a table. What we do not have yet is a “CHECK constraint for several tables at a time”, “CHECK constraint for a whole table” or “CHECK constraint for the whole database”. This kind of constraint is called an assertion. If you want to vote for this important feature to be implemented in Oracle database, just go and vote: https://community.oracle.com/ideas/13028 !

These are just examples of a great feature. The database will look after the data quality for me, while I do more interesting things…

— Heli

← Older posts

Subscribe

  • Entries (RSS)
  • Comments (RSS)

Archives

  • October 2022
  • October 2021
  • April 2020
  • October 2019
  • October 2018
  • June 2018
  • December 2017
  • October 2017
  • September 2017
  • July 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • July 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • February 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • June 2014
  • May 2014
  • April 2014
  • January 2014
  • December 2013
  • November 2013

Categories

  • Data Modeler
  • Database design
  • Events
  • General
  • Oracle
  • SQL Developer

Meta

  • Register
  • Log in

Blog at WordPress.com.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Follow Following
    • HeliFromFinland
    • Join 49 other followers
    • Already have a WordPress.com account? Log in now.
    • HeliFromFinland
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...