ThatJeffSmith

Querying Your Oracle SQL Developer Data Modeler Designs

Oracle SQL Developer Data Modeler has a multi-user repository that makes it very easy to control and version changes to your data models and designs. However, it’s stored in a Subversion (think files) repository. Many of our users are accustomed to having EVERYTHING stored in the database.

And when something is in a database, then it can be accessed via SQL.

So how can I leverage all the data in my designs without having to use the client tool? What I really want to do is use SQL. And the answer is:

The SQL Developer Data Modeler Reporting Schema

When you have your model, you’re able to save it to your database. Everything but the Physical Model information will be stored in a reporting schema. Yes, we’re going to be adding support for the Physical Model information at a later date.

So:

  1. Create design
  2. Build model
  3. Save model
  4. Export Model to Reporting Schema
I'm doing this from inside SQL Developer but it's also there in the standalone Modeler application

I’m doing this from inside SQL Developer but it’s also there in the standalone Modeler application

But wait, I don’t have a reporting schema yet!
No worries, after you select the connection for your reporting schema, SQL Developer will build the repository for you automatically. I recommend you create a separate user JUST for the reporting schema.

Select your connection (database/user) and go!

Select your connection (database/user) and go!

Voila, reporting schema created!

Voila, reporting schema created!

Before You Write Any SQL, Check Out the Reports First

We supply a few simple reports for you. You can check out the ‘Data Modeler’ Reports node and try running a few of them.

Supplied Relational Model Reports

Supplied Relational Model Reports

Now if you want to get an idea of what the data looks like in this new reporting schema, you could of course import from the data dictionary to yet ANOTHER model, or you could get lazy like me and just browse the schema. The table and column names are pretty self-descriptive. And if you get even lazier you can copy the supplied reports down to the user reports, and then use the editor to grab the SQL…

select t.table_name "Table_Name",
       m.model_name "Model",
       d.design_name "Design",
       d.published_by "Published_By",
       to_char(d.date_published, 'YYYY-MM-DD HH24:MI:SS') "Date_Published",
       t.ovid "Table_Ovid"
  from dmrs_tables t, dmrs_models m, dmrs_designs d,
       (select design_name, published_by, max(date_published) latest
          from dmrs_designs
         where (:Design is null or upper(design_name) like upper(:Design))
           and (:Published_By is null or upper(published_by) like upper(:Published_By))
        group by design_name, published_by) z
 where t.model_ovid = m.model_ovid
   and m.design_ovid = d.design_ovid
   and d.design_name = z.design_name
   and d.published_by = z.published_by
   and (:Table_Name is null or upper(t.table_name) like upper(:Table_Name))
   and (:Model is null or upper(m.model_name) like upper(:Model))
   and (:Design is null or upper(d.design_name) like upper(:Design))
   and (:Published_By is null or upper(d.published_by) like upper(:Published_By))
   and ((:Date_Published is not null and to_char(d.date_published,'YYYY-MM-DD HH24:MI:SS') like :Date_Published)
       or (:Date_Published is null and 'TRUE' like upper(:Most_Recent_Design) and d.date_published = z.latest)
       or (:Date_Published is null and 'FALSE' like upper(:Most_Recent_Design)))
 order by "Design","Date_Published" desc,"Model","Table_Name"

Or You Can Write Your Own SQL, Of Course

Or you can run reports out of the Data Modeler directly from the Reporting Schema instead from out of the designs. This means anyone could run those reports that had access to the reporting schema vs having the actual designs loaded on their machines.

Run your data modeler reports from the reporting schema vs the loaded designs

Run your data modeler reports from the reporting schema vs the loaded designs

This is a ‘Read Only’ Type of Repository

Meaning, I can’t use DML to update my models. That still happens via SQL Developer Data Modeler.

Any questions?