OO Design Vs. RDBMS functionality

Hi All,
I am new to Java world, been Oracle DBA so far and I am dealing with the following situation and need your input/comments on this:
We have a business entity called Button and the button can be one of the following types:
HTMLButton, MenuButton, SearchButton etc.
So in our UML Diagram, we defined Button as a parent class (having members that are common to all the derived buttons like buttonId, Name, Description etc.) and the above 3 as the derived classes containing members that are specific to this particular entity. e.g., HTMLButton has a member called HTMLContents and SearchButton has a member called SearchURL etc.
On the RDBMS side, we are using a single table to store all different kinds of buttons with an additional column "Button_Type". This table contains all the members from all the parent and derived classes. The buttonId will be unique across all the button types, hence a primary key for this table.
Now, we are writing few methods for these classes that will be used by the business logic like remove(), update() and find().
There are 2 ways to code these methods that I could think of.
First Way:
The parent class Button implements all 3 of the methods but in the find and update method, it only handles the members that are visible to this class. So in update method, it has SQL to update only the Button members/columns based upon the Primary key buttonId. And in the find method, it returns a Button object back based upon a given buttonId.
And all the derived classes override these methods by first calling the (super).update or (super).find and then adding their own code to handle the specific members of their own code.
e.g.
public class Button {
public Button find (String buttonId)
Button button = new Button();
// do all the logic to select button_id, button_name, button_desc from table_name where button_id = ? " and do the getString and call the setters on button.
return button;
public class HTMLButton extends Button {
public HTMLButton find (String buttonId)
HTMLButton htmlButton = new HTMLButton();
Button button = (super).find(buttonId);
// call the getters on parent to set the common members first
htmlButton.setName(button.getName()); // repeat for other common memebrs
// now get the HTMLButton specific members from Database and call setters on HTMLButton.
// "select html_content, html_btn_height from tab_name where button_id = buttonId"
// do a htmlButton.setString(rs.getString("HTML_CONTENT"));
return (Button) htmlButton;
So in a nutshell, the first way, i described above, breaks the table in 2 parts and the first part is handled by the parent and the second part is handled by the derived class.
Second Way:
I treat Button class as Abstract or may be a class that just stores the method signatures but the actual implementation is done at the derived class level. So while writing a find method on derived class, it executes a SQL like:
"Select button_id, button_name, button_desc, html_content, html_btn_height from tab_name
where button_id = buttonId"
and then calls the setters and returns the object back.
Now the problem:
So I am trying to figure out which one is better way to implement.
The first approach gives me a better OO approach but at the same time, doubles my database access as each update or find will be called in 2 steps (partially by parent class and partially by child class).
The second approach makes me write duplicate code but avoids poor performance on the database side.
I can tell you one thing that there wont exist something called a Button by itself, it always belongs to some type of button.
So I will really appreciate responses on this forum and I am sure this will help me in understanding OO approach better while at the same time, giving me an efficient performace.
Thanks in advance

I feel Tim in incorrect, the correct OO approach would be the "First Way", as behaviour common to the subclasses can be captured in the button class, even if the class itself is abstract.
However, the original poster has indicated that this would bring additional overhead to the database. I would still try and do it this way, and implement some clever scheme to avoid the database overhead. Perhaps the method in Button can start the construction of the database query, but allow subclasses to extend this by overriding another method, something like:public class Button {
public (static) Button find(String buttonId) {
  StringBuffer queryBuf = new StringBuffer("SELECT buttons_tbl.button_id, buttons_tbl.button_name");
  query.append(getExtraSelectFields());
  query.append(" FROM buttons_tbl ");
  query.append(getFromExpression());
  query.append(" WHERE buttons_tbl.button_id = '");
  query.append(buttonId);
  query.append("'");
  query.append(getWhereExpression());
  // fire off query and capture result
protected abstract String getExtraSelectFields();
protected abstract String getFromExpression();
protected abstract String getWhereExpression();
protected
}HtmlButton would then implement just the abstract methods, e.g.:public class HtmlButton {
public String getExtraSearchFields() {
  return "htmlbuttons_tbl.html_content, htmlbuttons_tbl.html_btn_height";
public String getFromExpression() {
  return " LEFT JOIN htmlbuttons_tbl";
}Well, it needs to be a bit smarter than this, but I hope you get the point.

Similar Messages

  • Define hierarchies in Power BI Designer on RDBMS without PowerPivot

    Hi,
    Is there a way to define hierarchies that can be used in the reports (drill down) in the Power BI Designer straight on an RDBMS source (similar to hierarchy definition in PowerPivot)?
    Thanks!
    Martin

    My Current workaround for pulling data from SSRS until the dev team have worked out the odata issue is to pull the report in as a csv file:
    Csv.Document(Web.Contents("http://Servername/ReportServer?/SummaryReport&rs:Command=Render&rs:Format=Csv")),
    I also tried pulling an excel file from SSRS with no success.
    Tried:
    Excel.Workbook(URL)
    Excel.Workbook(Web.Contents(URL))
    Excel.Workbook(File.Contents(URL))
    Excel.Workbook(File.Contents(Web.Contents(URL)))
    if anyone has had luck pulling in an excel file from SSRS i would like to know how.
    Is there a rough release date for the odata functionality?

  • Database Design for Multiple function site

    Hi
    I am working on one project which involve multiple function
    site, such as
    Company Product Catelog, Customer Support Forum, Document
    Exchange Engine and
    etc...
    Normally we will combine ALL TABLEs into one DATABASE.
    My question are:
    1) Is my break them to individual DATABASE, will it perform
    better?
    Means Product Catelog and Forum will have different
    DATABASE, but they
    will using the same DOMAIN NAME.
    2) I am worried about the break down and corruption of
    DATABASE, so I have the
    idea to separate them out. Are my idea correct or wrong?
    3) I am seeking for better DATABASE DESIGN, because I know
    the database will
    become huge in future. I request for your idea and opinion.
    Thank you very much.

    Creating views: not an option I think. It would involve a lot of programming with 'instead of' triggers etc.
    Seperate databases: a good way if the locations are completely independant and do not share information. This involves more DBA work.
    Separate schema's in one database: this would make public synonyms impossible, and is probably not a good option.
    Adding a location id to tables: the best way I think, and flexible. You can easily add another location, and locations can easily share information.

  • Template Designer - Custom Partner Functions in Object GDCOIC

    Hi,
    After spending a lot of time juggling with Template designer we have finally managed to get it working.
    But we have now come to an issue where the object used to create web service for template designer GDCOIC doesn't have details of partner functions we have setup in our system niether does it have custome date fields.
    Does anyone know how to add them? redefine - regenerate component GDCOIC?
    Thanks,
    Pankaj

    Here is the screnario
    Customer(Sold2party) is assigned to multiple sales org, Has multiple vendors, so when i create sales order in GUI, and enter the customer ID in "Sold2party" it gives a first pop-up to select sales org and i select one the sales org and then gives next pop up to select vendor and i select one of the vendor then i go to "partner" tab and i can see "vendor" listed as one the partner function in the tab........ Now the same dosent happens in Webclient. I get the first popup for sales org in webclient but NOT the second popup to select vendor.
    thanks
    Shree

  • TestStand Design Search/Replace Functionality

    We are in the process of changing from using Measurement Studio/Visual Basic to using TestStand as the test executor. (We are just learning to use TestStand and LabView.)
    Currently, all testing is done using VB as the low level calls, and VB scripting for the test automation.
    Our plan is to start by putting the VB low level code into an Active-X DLL and as time permits, move the low level code to LabView.
    The question is, as we create replacement functions using LabView, how do we Replace the Active-X DLL calls with the LabView functions?
    My first thought was to use "Search and Replace" (as there is in most other language enviornments) but I can't find such a function in TestStand. IS THERE A WAY TO DO THIS?
    M
    y other thought is to somehow create a subsequence for EACH library call that points to a single block for that function, where that single block can be changed from the Active-X DLL call to a LabView call.
    Examples would be that we have a Read/Write Parameter function as:
    ReturnStatus=DLL_Parameter(Name,Instance,Value,Mode)
    We would eventually create a new function in Labview and would want to replace ALL instances of the DLL call with a similar LabView function.
    How do we design this in?
    Mikef

    Unfortunately a search/replace feature has only been introduced in the new TestStand V3.0. It allows for searching and some replacing of values, properties, etc. however this may not help what you are describing.
    It is possible to write you own custom search/replace code that uses the TestStand API and can scan through a sequence file for particular step names or types and then insert a new LabView Step and remove the old DLL call step.
    If you need to keep the DLL parameters you can access them using the Step.TS.SData cluster. (You may need to set the �Show Hidden Properties� in the Station Options to see this in the Sequence Editor).
    Check out the TestStand API Reference and some of the Examples included in TestStand on how to use it.
    Hope this helps
    Simon Holman
    Simon Holman
    Software Engineer
    Certified LabVIEW Developer
    Certified TestStand Developer
    measX GmbH & Co. KG.
    http://www.measx.com

  • Best design for Boolean function from simple query

    Hello,
    what is the most efficient, shorter, readable, simple way to make a boolean function that simply return true or false from a simple query that return 0 or 1 to n records?
    Is this solution using a cursor's the best (working...):
       FUNCTION is_date_present (p_date IN DATE)
          RETURN BOOLEAN
       IS
          CURSOR chk_cursor
          IS
             SELECT COUNT (*)
               FROM target_dates
              WHERE target_date = p_date;
          nb   NUMBER := 0;
       BEGIN
          OPEN chk_cursor;
          FETCH chk_cursor
           INTO nb;
          CLOSE chk_cursor;
          IF nb >= 1
          THEN
             RETURN TRUE;
          ELSE
             RETURN FALSE;
          END IF;
       END;Performance, clarity and simplicity are important...
    Thanks

    Well, I prefer (not tested):
    FUNCTION is_date_present (p_date IN DATE)
    RETURN BOOLEAN
    IS
    nb NUMBER := 0;
    BEGIN
    SELECT COUNT (*)
    INTO nb
    FROM target_dates
    WHERE target_date = p_date;
    IF nb >= 1 THEN
    RETURN TRUE;
    LSE
    RETURN FALSE;
    IF;
    END;Regards,
    MiguelWhy count multiple records when you only care if you get at least 1 occurrence? Just wasted cycles.
    FUNCTION is_date_present (p_date IN DATE)
    RETURN BOOLEAN
    IS
    nb NUMBER := 0;
    BEGIN
      SELECT COUNT (*)
      INTO nb
      FROM DUAL
      WHERE EXISTS
          SELECT NULL 
          FROM target_dates
          WHERE target_date = p_date
      IF nb >= 1 THEN
         RETURN TRUE;
      ELSE
         RETURN FALSE;
      END IF;
    END;Or you could just add a ROWNUM = 1 on to yours, either way.

  • Design Studio Scripting function "refresh" to reload the BI LaunchPad Browser Window and solve the automatic adjustment

    Hi experts,
    I have created a Design Studio application with GridLayout Components to ensure the automatic adjustment.
    In the local mode everything works fine! If I maximize or minimize the browser window the automatic adjustment of the design studio application works absolutely correct.
    If I execute the same Design Studio Application in SAP BI LaunchPad the automatic window adjustment works only fine if I refresh the Browser window after minimize or maximize.
    Example:
    Mnimized and refreshed Browser window (good):
    Maximzed and not refreshed Browser window (bad):
    To fix this issue, Is there a workaround with a scripting funtion (e.g. ".refresh") to give the user the possibility to reload the browser window by a button or icon?
    By the way, the issue and the Todo "Refresh" is valid in Design- and Runtime!
    Many thanks in advance!
    Best regards,
    Michael

    Hi Michael,
    Isn't this issue fixed in 1.2 SP1?
    In any case if you want to manual refresh you have to redraw the chart, this can be achieved by,
    reloading data source,
    change some selection in the chart,
    or change the data source, (apply filter,swap dimensions etc.)
    Regards,
    Fazith Ali Z.

  • Please Help!!!  In Design Does Not Function

    I downloaded the InDesign Program from Creative Cloud.
    The program does come on.  The File Menu is functioning.  I am able to open a new document, place a text box and type in it. 
    None of the other buttoms work.  I click and there is nothing.  I have a Windows 7 (latest Windows) with tons of space.
    My other progam which I completed Illustrator worked beautifully.
    Please help.
    Thanks

    And exactly what "buttons" are you referring to? What is your document setup? What are you trying to do? Have you actualyl read the help and are sure you are doing everything right?
    Mylenium

  • Functional application design  =  Logical components/Physical components

    Hello
    In realisation phase I come across terms
    Functional application design  =  Logical components
    Functional application design  =  Physical components
    Can I get some explanation what is the principle difference between a logical and Physical component.
    Thanks

    It depends entirely on the business requirements. Specifically
    - is a lot of concurrent 'history and active record' reporting required?
    - what is the ratio of active to deleted records?
    - can the [performance, maintenance and development] cost of avoiding deleted records be justified?
    - is a 'history' table acceptable instead of inline records?
    - what is the "too many rows, we need to delete some" archive strategy?
    Once past the analysis stage, into design
    - is the shop oriented towards RDBMS as a data manager or a data storage and retrievval system?
    - do developers code in a client/middle tier or are they knowledgeable coders in the database tier?
    - do you intend to squeeze the value out of Oracle, or do you code everything on your own?
    These last 3 questions are really the same thing.

  • Design ,Technical & functional Documents

    We are going to send PO(R/3) to our Supplier network thru XI and also we are going to receive the Invoices into our R/3 System.
    For the Above scenario we need the following Documents
    1)Design Documentation
    2) Functional Documentation
    3) Technical Documentation
    I want to know what Information I need for the above classifications and also who will be incharge for the above like who will execute the Design Documentation, Who will write the Functional and Technical Documentation?
    If there is any useful documents available?
    Thanks.

    Jenni
    Design Documentation tell us how the interfaces are going to work for the entire project. So usually Architects or Senior guys who have indepth experience of XI will usually write this.
    Functional Documentation tell us the functioanlity of the interface. This is written by the Functional guys who have indepth knowledge about the functionality what they are looking from the interface. They may even take the help of technical guys to some extent.
    Technical Documentation tells us how the interface is going to be worked technically. Here we will mention what are the adapters, naming conventions etc we are going to use for the interface. This is written by the XI developers. This are purely my views and this may change from person to person jenni.
    For further info go through the urls:
    Re: Building XI
    XI technical specification documents
    Regards,
    ---Satish

  • Microwave function generator design

    I am a final year ECE student I want to know how to design a high frequency microwave function generator using the labview. Pl. help me in this. It may help me in proceeding my final project..

    LabVIEW is a programming language.  It can do anything, but its specialty is its ease in communicating with real world devices.  But it doesn't have any means of designing a "microwave function generator".
    What are you really trying to do?  Are you sure you should be trying to use LabVIEW to do it?
    What is an "ECE" student?

  • A problem with a function

    Oracle Version: 10g
    Operating System: Microsoft windows 2003
    Hello, I need some help, I would appriciate if anyone could help me out.
    on one hand, I have a table that contains a list of table names that are sensitive in my org.
    In addition, not all the columns in the table are sensitive, some tables have only one or tow sensitive columns
    on the other hand, I have another table that contains all the SQL Statements that passed through all my DB's in the org + some other details like username, machine name etc.
    the sql statement is one columns - varchar2(4000). ALL the SQL TEXT is printed there.
    I need to create a report of the SQL Statements and their details that have any reference to the sensitive entities.
    I'm kind of new to PL/SQL or programming in DB in general.
    Can you please assist me in designing the write function and script.
    Additional details:
    Sensitive_tables table:
    table_name varchar2 (65) -- the names of the sensitive tables
    All_fields number (1) -- 0=not all the fields are sensitive, 1=all the fields are sensitive
    the conditions where the function should return true:
    1. It's not a select/SELECT statement.
    2. There is a relation to a sensitive table that all its columns are sensitive
    3. There is a relation to a sensitive table and to a specific sensitive column.
    below is the function.
    There are 2 cursors - the first loop will check if the SQL Statement touches a sensitive column + a sensitive table.
    The second one checks if the the SQL Statement a table that all its columns are sensitive.
    CREATE OR REPLACE function sens_entity_match (p_statement varchar2)
    return VARCHAR2
    IS
    v_match VARCHAR2(5);
    sql_stmt VARCHAR2(4000);
    TYPE tbls_wth_all_flds IS REF CURSOR;
    tbls_all_fields tbls_wth_all_flds;
    table_name_y varchar2(65);
    TYPE tbls_wthout_all_flds IS REF CURSOR;
    tbls_some_fields tbls_wthout_all_flds;
    table_name_n varchar2(65);
    BEGIN
    sql_stmt:=upper(p_statement);
    OPEN tbls_all_fields FOR select table_name from sens_tables where ALL_FIELDS='1';
    OPEN tbls_some_fields FOR select table_name from sens_tables where ALL_FIELDS='0';
    FETCH tbls_all_fields INTO table_name_y;
    FETCH tbls_some_fields INTO table_name_n;
    WHILE tbls_some_fields%FOUND LOOP
    BEGIN
    IF upper (sql_stmt) like 'SELECT%' THEN
    BEGIN
    RETURN ('FALSE');
    v_match:='FALSE';
    END;
    ELSIF
    ( ((sql_stmt LIKE '%ID_NUMBER%' ) OR (sql_stmt LIKE '%id_number%' )) AND (sql_stmt LIKE table_name_n) )
    OR
    ( ((sql_stmt LIKE '%ADDRESS%') OR (sql_stmt LIKE '%address%')) AND (sql_stmt LIKE table_name_n) )
    OR
    ( (((sql_stmt LIKE '%EMAIL%') OR (sql_stmt LIKE '%E_MAIL%')) OR (sql_stmt LIKE '%email%') OR (sql_stmt LIKE '%e_mail%') ) AND (sql_stmt LIKE table_name_n) )
    OR
    (( (sql_stmt LIKE '%BANK%') or (sql_stmt LIKE '%bank%')) AND (sql_stmt LIKE table_name_n) )
    OR
    ( ((sql_stmt LIKE '%PYM%') OR (sql_stmt LIKE '%PYM%')) AND (sql_stmt LIKE table_name_n) )
    OR
    ( ((sql_stmt LIKE '%CREDIT_CARD%') OR (sql_stmt LIKE '%credit_card%')) AND (sql_stmt LIKE table_name_n) )
    OR
    ( ( (sql_stmt LIKE '%USER%') OR (sql_stmt LIKE '%user%') )AND (sql_stmt LIKE table_name_n) )
    OR
    ( ((sql_stmt LIKE '%CHURN%') OR (sql_stmt LIKE '%churn%') ) AND (sql_stmt LIKE table_name_n) )
    OR
    ( ((sql_stmt LIKE '%LEGAL%') OR (sql_stmt LIKE '%legal%') ) AND (sql_stmt LIKE table_name_n) )
    THEN
    BEGIN
    v_match:='TRUE';
    RETURN ('TRUE');
    END;
    ELSE
    v_match:='FALSE';
    END IF;
    FETCH tbls_some_fields INTO table_name_n;
    END;
    END LOOP;
    WHILE tbls_all_fields%FOUND LOOP
    BEGIN
    IF upper (sql_stmt) like 'SELECT%' THEN
    BEGIN
    v_match:='FALSE';
    RETURN ('FALSE');
    END;
    ELSIF (sql_stmt LIKE table_name_y) THEN
    BEGIN
    v_match:='TRUE';
    RETURN ('TRUE');
    END;
    ELSE
    BEGIN
    v_match:='FALSE';
    RETURN ('FALSE');
    END;
    END IF;
    FETCH tbls_all_fields INTO table_name_y;
    END;
    END LOOP;
    RETURN (v_match);
    END;
    Eexampls that should should be true:
    select sens_entity_match ('update address_data set "EMAIL" = :24 where rowid= :old_rowid') from dual;
    {address_data is a sensitive_table that exists in "sensitive_tables" table and email is a sensitive column}
    select sens_entity_match ('isnert into legal (ssss) select bbbb from input where rowid = 666;') from dual;
    {legal  is a sensitive_table that exists in "sensitive_tables" table and all its columns are sensitive}
    An example that shouldn't should be true:
    select sens_entity_match ('select bank from bank_details where bank_id= 11;') from dual;
    {The SQL text is a select statement}
    The function complies and works, but it doesn't catch all the SQL Statements that are relevant.
    How can I improve it?
    What should I change?
    I would appriricate any help.
    Thanks,
    Roni.

    Hi user611218!
    If I understud right, then you want to have some kind of auditing. I suggest if want auditing than you should use the auditing capabilities of Oracle (Standard auditing and Fine Grained Auditing). It's much easier to generate a report from an Auditingtrail than to create a "Self-Made-Function".
    But if you prefer the soluting with your function then you should change the following:
    ELSIF( ((sql_stmt LIKE '%ID_NUMBER%' ) OR (sql_stmt LIKE '%id_number%' )) AND (sql_stmt LIKE table_name_n) )
    CHANGE IT TO
    ELSIF ((INSTR(LOWER(sql_stmt), 'id_number') > 0)) AND (INSTR(LOWER(sql_stmt), LOWER(table_name_n))))
    Change all the LIKE ... Statements to INSTR ... like above.
    Hope this helps!

  • How to implement the Transfer Function in Real Time VIs?

    Hi all,
    I'm relatively new to Labview Real Time modoule and want to implement one Controller(not PID one) in Deterministic Loop! I have already designed discrete Transfer Function and searching for the way to build one Controller with it! Is it right to use the Simulation Loop instead of Timed Loop (in this case Deterministic loop) and implement the controller in it?! If it's correct so, should I use the same clock and Priod as Timed Loop?!
    It would be very helpful, if there is an Example about using transfer function in Real Time Loops!
    thanks for your help,
    Mohsen 

    Hello mhmdi,
    Sorry I can't open your VI (looks like it is a new version of LV than I have installed).
    You're right - you don't need to convert to a difference equation if you have the CD&SIM Module which can take discrete time transfer functions directly. You don't need shift registers with this function, as it is effectively done internally. If you don't have CD&SIM discrete TF's can be implemented easily just in a timed (or while) loop with feedback nodes or shift registers to replicate each z-1 you need.
    Some more ideas:
    There are many configuration parameters and options with the Discrete TF VI - which you need to understand for your application and make sure are correct. Sometimes implementing in a basic form (timed loop and shift registers) allows you to see what is happening without any confusing options you might not need.
    Are you using the Discrete TF VI in a Simulation Loop ? You might need to think if the loop being used is appropriate for a Real Time application. Maybe the timing of the TF, the loop and the DAQmx data are not all suitable for each other.
     I'm not familar with DAQmx, so not sure about any specific real-time aspetcs of that.
    "if the sample frequency of the discrete transfer function in the timed-loop is at multiple integers of the sampling rate (e.g. 12000 Hz for tranfer function and 4000 Hz for sampling rate, 12000=3*4000), would it somehow improve the resolution of the controller command?"
    This could actually make things worse - but depends on your transfer function if it is a problem. Think about it this way - in the scenario you state the input signal going into the Discrete TF will only change once in every three samples, that means if your transfer function includes a 1-z^(-1) factor (i.e. a derivative) - that will be zero for two samples then jump up for the next sample. You'll observe a very jittery/noisy signal, but the noise is due to samples not being correct. This will also occur if the sample times are very similar but go in and out of sync where you may get the occassional sample that is the same and hence the occassional zero in the TF.
    In an application I had we had problems trying to get the data coming into a timed loop and the timed loop itself synchronise, and before it was fixed the control signal was very jittery.
    Consultant Control Engineer
    www-isc-ltd.com

  • Report designer ,WAD

    Hi to All,
    Can any body will send step by step/screen shot for
    --->>>>Report designer and its functions, features etc, -
    >>Information Broadcasting, WAD - Integration with EP and publishing queries in EP. in BI.7 version
    pls send to my id
    [email protected]
    Thnx in Advance
    Regards
    Chaitanya

    Hi,
    Check the following Area.
    http://help.sap.com/saphelp_nw04s/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm
    Regards,
    RC

  • Get_Payslip Function

    Dear All
    I have used Get_Payslip Function Module to get Pay Slip in Internal table from that we are sending pay slip through email..
    Problem is
    recently we have change the Pay slip Design.
    While i am tiring for new pay slip design with GET_PAYSLIP function module by pass new pay slip variant , its return me my old pay slip design in internal table. While i want pay slip as per new design.
    Please help me soon as month end is coming.

    Hi Ashish,
        I have used Get_Payslip Function Module to get Pay Slip in Internal table. But After that how to send payslip to email id. How to convert that internal table data in OTF format. Please please tell me the procedure.I am finding on SDN but not getting how to do.
    Thanks.
    Pradip Pawar

Maybe you are looking for