Design decision: good to use delete cascade in database?

Hello,
Suppose there are two tables: customer and address.
These two tables are linked as one (customer) to many (address), and delete cascade. Every time when the application deletes a customer record, the linked address(es) will be deleted as well.
For my opinion, this is good because of performance and less coding.
But bad for maintenance, since the address is implicitly deleted, the developer may not know this in advance if the system is not documented well.
What is your opinion? What facts will affect your decision to use it or not?

The design should say that when a customer record is deleted, the linked address records must also be deleted. Otherwise your database loses referential integrity.
So for me, if the database supported cascading deletes, I would use them. Why would I do extra programming which the database is offering to do for me, especially since my version of the code is likely to be less robust than the database's version? The only exception would be if some other action needed to be taken besides just deleting the dependent records, and that action couldn't be handled within the database.
As for your comments about maintenance, it's true that if the system is not documented then developers may have difficulty in maintaining it. However I don't exactly foresee designers saying to themselves "Oh, this system isn't well documented so I won't use Feature X".

Similar Messages

  • Using Delete Cascade a best practice?

    Hi,
    My current requirement need to delete specific records from  parent and also from child tables.
    So, DELETE CASCADE will be helpful.
    I need to know whether it is a good practice to use that? I hope it is.
    And also I think the performance will be better than deleting manually.
    please throw me a light on this.
    Thank you.

    > However if you allow CASCADE DELETE, data in both child1 and child2 will be wiped out when deleting the parent key which may not be the intended behavior. Since it could cause unintended data loss, I would not use it if I am designing the table.
    We need to be realistic about CASCADE DELETE. How do you audit trail all the rows deleted in related tables?
    Assume you work for AdventureWorks Cycles and a manager is telling you: delete that old mountain bike from the product table. As soon as you do that, a month later another manager demands is back for some reporting.
    The point is don't ever DELETE data. Move it over to history/audit table so you can provide it if somebody asks for it again (guaranteed someone will).
    And my point: CASCADE DELETE should be part of a bigger db maintenance procedure. Therefore, I prefer stored procedure implementation with proper audit trail.
    Audit trail example:
    http://www.sqlusa.com/bestpractices2005/auditwithoutput/
    Kalman Toth Database & OLAP Architect
    SELECT Video Tutorials 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Foreign keys without ON DELETE CASCADE; Database Design question

    This is the 3rd company i am working, where i see Foreign Keys created without
    ON DELETE CASCADEclause.
    My colleague says that it is created without ON DELETE CASCADE clause in order to make deletion of data (child records) difficult. So, for Purge/Archive codes, before we delete from Parent table we have to delete from the Child table first.
    Occasinaly , something goes wrong and we'll end up disabling all FKs and then do Purging, Archiving, etc..
    So, isn't it better to create Foreign keys with ON DELETE CASCADE clause rather than having all these hassles?
    From you experience, what do you guys think?

    ON DELETE CASCADE is usually not a good idea - something 'magical' happens in the background and rows go away. Instead, consider making the FK DEFERRABLE INITIALLY DEFERRED. That way you can delete the parent and child rows in any sequence and the constraint will not be checked until commit time. You want to use an API (stored procedure/package) to make sure DML is executed in the proper sequence and in the proper way for your business rules.

  • URGENT - EJB 2 BMP Entities - Is it OK to use On Delete Cascade?

    Hi All
    i have a system that im currently working on in EJB 2 using bean managed persitence and need to implement a cascade delete funtionality when i delete a particular entity.
    am i going to break the EJB spec or the system if I use the On Delete Cascade clause on my database tables so all rows are automatically removed from the DB?
    Unfortuantely its an existing system to upgrading to EJB 3 isnt an option.
    i know i could use multiple sql statements to delete associated entites or even use the delete methods on associated entity beans, but i feel that using on delete cascade would be far more efficient than all of the above.
    i really need a quick answer on this (ive got to have the code done by wed morning) so if anyone could give me a quick pointer on which method i use id be extremely grateful.
    Thanks in advance.
    Gaz.
    Message was edited by:
    mrblue

    Hello jcannon,
    Designing filters is heavily signal-dependent.  There is no overall best filter, most appropriate passband ripple, or stopband attenuation.  For some guidelines, please see the following links:
    Filter choice:
    http://digital.ni.com/public.nsf/allkb/B5C159262A4976DD86256C2F005EAB94?OpenDocument
    LabVIEW Elliptic Filter PtByPt VI:
    http://zone.ni.com/reference/en-XX/help/371361G-01/ptbypt/elliptic_filter_ptbypt/
    Filter Specifications:
    https://ccrma.stanford.edu/~jos/sasp/Lowpass_Filter_Design_Specifications.html
    I would suggest simply adjusting these values until your filter behaves the way you need according to your application.
    Patrick W.
    Applications Engineer
    National Instruments

  • Why lock-order can use in cascade delete?

    Hi.
    http://edocs.beasys.com/wls/docs81/ejb/DDreference-cmp-jar.html#1113798
    #Function
    #Use this flag to specify the database locking order of an entity bean
    #when a transaction involves multiple beans and exclusive concurrency.
    #The bean with lowest number is locked first.
    #This flag should only be used to prevent a deadlock situation and,
    currently,
    #only applies when a transaction performs cascade deletes.
    #This flag is only used for cascade delete currently.
    Why lock-order can use only cascade deletes sisuation?
    This is fake fuction ins't it....
    Makoto Shibata

    I'm not sure that I understand what you mean by 'fake function', but
    as I recall, the reason why this feature works for cascade delete is because
    the feature was specifically introduced because deadlocks were detected
    when using cascade delete in heavily concurrent environments.
    -thorick

  • PL/SQL  on delete cascade..   ( how  to view the child record deleted..?)

    Hai
    i have 70 tables integrated with foreign and child key constraints. i have on delete cascade for all the child tables. if i delete the parent table automatically child table record get deleted.
    Kindly tell me how can i check howmany child record has been deleted ..? how can i monitor this...?
    one thing i can do... i can make count of child table before and after...
    is there anyother way..?
    S

    Peter,
    I subscribe to the general consensus around trigger usage. Allthough I allways diffentiate between triggers that,
    - perform pl/sql with embedded DML (that is: delete, insert, update)
    versus triggers
    - that perform pl/sql with embedded queries only.
    The latter use of triggers is good (in my opinion), and most frequently used to enforce (non declarable) data integrity constraints.
    The former use of triggers is bad. Because it makes things happen automagically.
    Just google "asktom triggers are evil", you'll find statements such as:
    ~quote
    because things happen automagically
    because side effects are bad
    because explicit linear code is more maintainable then "happens as a by product of something in the background"
    magic should be avoided. Experience tells me this.
    ~quote
    And to me a CASCADE DELETE clause on a foreign key definition, is a TRIGGER. Allbeit not one for which you had to write CREATE TRIGGER statements, but one that you can declaratively introduce. And this trigger holds embedded DML, it is of the former case, and is therefor bad.
    You the designer of the application may be aware that you have your FK's as cascade delete. But your successor(s) might not be aware of this when they write maintenance code to delete Orders. They might be expecting the database to throw them an FK violation message when they try to delete an Order that still has Lines attached to it.
    Everybody knows the effect of an INSERT, a DELETE, an UPDATE. But the moment you've introduced triggers with embedded DML in them, the effect of these three well known primitive SQL statements suddenly becomes unknown. With triggers you can create any effect for any of these three primitives, that you want. And more often than not other people maintaining your codebase later on in the future, do not realize these side effects happen, because they didn't check the presence of any triggers, nor investigated the side effects caused by them.
    Btw. for exactly the same reasoning I consider use of DEFAULT-clause on table columns, or even use of (fixed length) CHAR datatype, evil also. Again they are in effect declarative triggers with side effects. Allbeit that their side effects usually are less worse than those caused by handwritten triggers with embedded DML.
    Toon

  • JPA Arhitectural Design Decision

    Hi,
    I'm building a 1 tier web shop, using mostly Ajax, Servlets and JPA and I need your advice on a design decision.
    When a user demands to see the products belonging to a particular category of products, my DAO object returns to the servlet a java.util.List<Product>, where Product is a JPA entity. In the servlet class I "manually" create the Ajax XML response, the user gets to see the products, everything is nice and great.
    I am not happy with the fact that the list of products remains detached in the servlet class, sort of say, and when another user demands to see the same products another list gets greated. These are objects that have method scope, but still they are on the stack, right? For 100 users who want to see 100 products each, the no. of objects created could cause the application to have a slower reponse time.
    So my question is about the design of the application.
    I obtain the list of products in the servlet class and construct the XML response. Right before sending the response, should I pass the list of products back to the DAO, and ask the EntityManager to merge the products? Will this reduce the no. of objects my application creates? Shouldn't I do this because I'm merging entities that have not been changed and the merge operation is time consuming?
    Should I not pass back the products to the DAO and set each product in the list to reference null and call System.gc() ?
    Keeping in mind, that my main concern is application response time, not reduced development time, are there any other suggestions you can make?

    first of all, a merge is only used to synchronize a changed entity that is not managed by an entity manager with the database. Why did you even come to the conclusion that you might need this?
    No you don't nullify the entities in the list. You let the entire list go when you are done with it. Manually nullifying can hinder the garbage collector, just don't do it unless you have a very good reason for doing so.
    Your main problem seems to be that you don't like the fact that you are fetching 100 objects for both users, putting duplicate objects in memory on the server. Are you sure this is a problem? You shouldn't be thinking about optimizations while you are still developing you know. I would wait until you are done, then profile the application to see where bottlenecks are; if fetching those 100 products turns out to take a lot of system resources, THEN optimize it.
    You may want to look into caching. If for example under water you use Hibernate as the persistence provider, search for "hibernate cache" using google.

  • HELP !!!!!! Design decision...!!!!!

    Hello,
    I am in a dilemma of making a design decision . We are developing a business tier component. This is going to talk to webservices on the backend. Right now it is going to integrate with 2 different backend systems through web services. In future it might support more of such backend systems.
    And there are clients (web app, xml app) who interface with the component.
    Most of the data elements passed over to backend systems is similar for both the systems, but some are different.
    Now is it a good design to make 2 different client interfaces for 2 backend systems ? so that ,clients upfront decide which interface to use. This is more cleaner and easier implementation.
    Or is it good to have a generic interface, and component then figures out which data to use and to which backend system to talk to.
    Please help,
    Thanks

    There are several patterns that could apply, but the most widly used is probably the MVC (Model View Controller) pattern.
    With the pattern the View layer is the front end (in your case this would be the web app / xml app).
    The Controller would be your middle tier, this layer is responsible for relaying requests of the View layer to the Model layer.
    The Model layer would be your backend webservices.
    As said, the controler is responsible for relaying the requests from the view layer to the correct webservice. This means you need to have some way to know how to do this. You can employ several methods to do this.
    You could have different methods for the different webservices, this is the most straight forward way.
    Or you could look at the provided parameters and decide where you need to go based on that. This is slightly more difficult, but when you have two or more webservices that do almost the same thing, this might be the better way to go.
    If you really wanted to make things fancy, you could employt the second method and have the checks be based on rules you configure through a dynamically loaded file, this way, you could (theoratically) build your middle tier in such a way that you can add new front ends / back ends without having to redo the middle tier. This might eventually be the cleanest / best way to go, but it is also the most difficult and takes a lot of planning beforehand.
    Mark

  • How do I delete cascade with a PL/SQL procedure?

    This script will create a PL/SQL procedure that deletes cascade. This is a post to contribute to the Oracle community. Take the code as is and test it before you use it in production. Make sure this is what you want.
    Procedure Delete Cascade (prc_delete_cascade)
    Description
    =============
    The principle is very simple. The procedure uses a table called TO_BE_DELETED to keep a list of records to be deleted. This
    table keeps the table name and the rowid of those records that need to be deleted. The procedure also uses a function called
    DELETE_BOTT_ROW which takes one record of the table and tries to delete it. If the deletion fails with a foreign key constraint
    violation, the function parses the SQL error message (SQLERRM) to get the name of the constraint. With the name of the constraint,
    the function finds the name of the child table, all the child records that have references to the parent table primary or unique key,
    and the parent key primary or unique key column name. Once the child records of the failed delete are identified, the function takes their table name and rowids
    and records them into the TO_BE_DELETED table by inserting records of their table name and their rowids. Al the records inserted also contain the level (which
    is 1 for the original records, 2 for child records, 3 for granchild records, etc.) and the sequence number of the order in wich they
    are recorded. This way, when the function picks up a record to be deleted, it takes the one with the highest level and the highest
    inserted sequence, or the "bottom" record. Once all the child records of the failed delete are appended to the TO_BE_DELETED table, it calls itself
    recursevely, and the function takes the record at the "bottom" of the table and tries to delete it. If it succeeds, it calls
    itself recursevely to delete the next record. If it fails, it goes and finds the child records as described before and once they are
    inserted into the TO_BE_DELETED table, it calls itself again recursevely to try to delete again the "bottom" record. All records
    that are successfully deleted are flagged as deleted usig the flag_del column so they are not pickt up again. Once all the (parent,
    child, grandchild, etc.) records are deleted, the procedure ends without commiting, giving the option to the user to commit or
    rollback deletions. The table TO_BE_DELETED is, at the end of the procedure, a list of all the records that were deleted, including their table names
    and the order in with they were deleted. The user then can review its content and decide to commit or rollback.
    Restrictions
    ============
    1. Single tables only. The procedure only takes one table name and a WHERE clause to identified the records to be deleted.
    2. Single columns only. Ther procedure only works with single-column primary, unique and foreign key constraints.
    3. Single schema only.
    4. Unpredictable results with circular references.
    drop table to_be_deleted purge;
    create table to_be_deleted
    (tname varchar2(30)       -- table name
    ,rid rowid                -- rowid
    ,lvl number               -- level: 1=parent, 2=child, 3=grandchild, etc.
    ,seq_ins number           -- sequence order of record inserted
    ,flg_del char             -- flag deleted: Y=record deleted
    ,seq_del number           -- global order of record deletion
    set serveroutput on size 1000000
    create or replace procedure prc_delete_cascade
    (p_tname varchar2  -- table name
    ,p_where varchar2  -- where clause identifying records to be cascade deleted
    is
      dummy         char;
      v_sqlcode     number;
      v_sqlerrm     varchar2(32767);
      v_param_val   integer := 0;
      v_sql         varchar2(4000);
      v_ret_cde     number;
      e_bad_params  exception;
      v_iter        number;
      v_plvl        number;
      v_seq_del     number;
      v_max_iter    number := 1000000000;
      function delete_bott_row
      return number
      is
        v_sql        varchar2(4000);
        v_ptname     varchar2(30);  -- parent table name
        v_ppkname    varchar2(30);  -- parent primary key constraint name
        v_ppkcname   varchar2(30);  -- parnet primary key column name
        v_prowid      rowid;
        v_crowid      rowid;
        v_ctname     varchar2(30);  -- child table name
        v_cfkname    varchar2(30);  -- child foreign key constraint name
        v_cfkcname   varchar2(30);  -- child foreign key column name
        v_ins        number;
        v_seq_ins    number;
        v_sqlerrm    varchar2(4000);
        v_sqlcode    number;
        e_const_viol exception;
        pragma exception_init(e_const_viol, -2292);
        e_max_iter_reached exception;
      begin
        v_iter := v_iter + 1;
        if v_iter >= v_max_iter then
          raise e_max_iter_reached;
        end if;
        dbms_output.put_line('- Iter '||to_char(v_iter));
        dbms_output.put_line('----------');
        dbms_output.put_line('- Starting function delete_bott_row');
        v_sql := 'select tname, rid, lvl, seq_ins from (select * from to_be_deleted where flg_del = ''N'' order by lvl desc, seq_ins desc) where rownum=1';
        --  dbms_output.put_line('- SQL: '||v_sql);
        execute immediate v_sql into v_ptname, v_prowid, v_plvl, v_seq_ins;
        dbms_output.put_line('- Selected row: table name: '||v_ptname||', level: '||v_plvl||', seq: '||v_seq_ins);
        v_sql := 'delete from '||v_ptname||' where rowid='''||v_prowid||'''';
        dbms_output.put_line('- SQL: '||v_sql);
        execute immediate v_sql;
        dbms_output.put_line('- Row deleted !!!');
        v_ret_cde := 1;
        v_seq_del := v_seq_del + 1;
        dbms_output.put_line('- Mark the row deleted');
        v_sql := 'update to_be_deleted set flg_del = ''Y'', seq_del = '||to_char(v_seq_del)||' where tname='''||v_ptname||''' and rid='''||v_prowid||'''';
        -- dbms_output.put_line('- SQL: '||v_sql);
        execute immediate v_sql;
        -- dbms_output.put_line('- Updated table to_be_deleted, row marked deleted');
        -- dbms_output.put_line('- End of iter '||to_char(v_iter));
        dbms_output.put_line('----------');
        -- call function delete_bott_row recursively
        v_ret_cde := delete_bott_row;
        return 0;
      exception
        when no_data_found then
          dbms_output.put_line('- Table to_be_deleted is empty, delete cascade has completed successfully.');
          v_ret_cde := 0;
          return 0;
        when e_const_viol then
          v_sqlcode := SQLCODE;
          v_sqlerrm := SQLERRM;
          v_ret_cde := v_sqlcode;
          dbms_output.put_line('>Constraint Violation. Record has children');
          -- dbms_output.put_line('Error code: '||to_char(v_sqlcode));
          v_cfkname := substr(v_sqlerrm,instr(v_sqlerrm,'.')+1,instr(v_sqlerrm,')') - instr(v_sqlerrm,'.')-1);
          dbms_output.put_line('>Child FK name: '||v_cfkname);
          select table_name, column_name
            into v_ctname, v_cfkcname
            from user_cons_columns
           where constraint_name=v_cfkname;
          dbms_output.put_line('>Child table name: '||v_ctname||'. FK column name: '|| v_cfkcname);
          select constraint_name, column_name
            into v_ppkname, v_ppkcname
            from user_cons_columns
           where constraint_name = (select r_constraint_name
                                      from user_constraints
                                      where constraint_name=v_cfkname);
          dbms_output.put_line('>Parent PK/UK name: '||v_ppkname||'. Parent PK/UK column: '||v_ppkcname);
          v_sql := 'insert into to_be_deleted(tname, rid, lvl, seq_ins, flg_del) '||
                   'select '''||v_ctname||''', rowid, '||to_char(v_plvl+1)||', rownum, ''N'' '||
                   'from '||v_ctname||' '||
                   'where '||v_cfkcname||' =any (select '||v_ppkcname||' from '||v_ptname||' where rowid =any (select rid from to_be_deleted where tname = '''||v_ptname||'''))';
          -- dbms_output.put_line('- SQL: '||v_sql);
          execute immediate v_sql;
          select count(*)
            into v_ins
            from to_be_deleted
           where lvl = v_plvl+1
             and tname = v_ctname
             and flg_del = 'N';
          dbms_output.put_line('>Found '||to_char(v_ins)||' child records which were added to table to_be_deleted');  
          v_ret_cde := delete_bott_row;
          return  v_ret_cde;
        when e_max_iter_reached then
          dbms_output.put_line('Maximum iterations reached.  Terminating procedure.');
          raise;
        when others then
          raise;
      end delete_bott_row;
    begin
      dbms_output.put_line('Beginning');
      dbms_output.put_line('================================');
      -- validate p_table
      begin
        select 'Y'
          into dummy
          from user_tables
         where table_name=upper(p_tname);
      exception
        when no_data_found then
        v_param_val := 1;
        dbms_output.put_line('Table '||p_tname||' does not exist.');
        raise e_bad_params;
      end;
      dbms_output.put_line('- Parameter p_tname validated');
      -- validate p_where
      begin
        execute immediate 'select ''Y'' from '||p_tname||' where '||p_where INTO dummy;
      exception
        when no_data_found then  -- where clause returns no records
          dbms_output.put_line('Record(s) not found.  Check your where clause parameter');
          v_param_val := 2;
          raise e_bad_params;
        when too_many_rows then  -- found multiple records means it is ok
          null; 
        when others then  --  any other records means where clause has something wrong.
          dbms_output.put_line('Where clause is malformed');     
          v_param_val := 2;
          raise e_bad_params;
      end;   
      dbms_output.put_line('- Parameter p_where validated');
      if v_param_val > 0 then raise e_bad_params; end if;
      v_iter := 0;
      v_plvl := 1;
      v_seq_del := 0;
      v_sql := 'insert into to_be_deleted(tname, rid, lvl, seq_ins, flg_del) select '''||upper(p_tname)||''', rowid, '||to_char(v_plvl)||', rownum, ''N'' from '||p_tname||' where '||p_where;
      dbms_output.put_line('- Inserting initial record');
      dbms_output.put_line('- SQL: '||v_sql);
      execute immediate v_sql;
      dbms_output.put_line('- Record(s) inserted');
      dbms_output.put_line('- Calling function delete_bott_row to delete last row of table to_be_deleted');              
      dbms_output.put_line('-----------------------------------');              
      v_ret_cde :=  delete_bott_row;
      -- dbms_output.put_line('- Back from function delete_bott_row');              
      -- dbms_output.put_line('Return code: '||to_char(v_ret_cde));              
      dbms_output.put_line('- End of procedure');              
    exception
      when e_bad_params then
        dbms_output.put_line('Bad parameters, exiting.');
    end;
    show errors
    spool prc_delete_cascade.log
    --  Call to the procedure
    exec prc_delete_cascade('xent','xent_id between 1669 and 1670')
    select tname "Table Name", count(*) "Rows deleted"
      from to_be_deleted
    group by tname;
    spool off
    set lines 120
    select *
      from to_be_deleted
    order by seq_del;
    prompt  Now commit or rollaback deletions.
    -- commit;
    -- rollback;Edited by: Rodolfo4 on Mar 23, 2011 10:45 AM

    Interesting.
    I see a few areas where this could be useful. Elimiating specific test records from a Test DB for example.
    Some comments:
    <li>Since this is a recursive logic you must add a stop criteria. In this case I would add a max iteration variable. If that one is reached, raise an error message and let the procedure stop with that error.</li>
    <li>The when others exception at the end should be removed completely</li>
    <li>The when others exception in the middle should be replaced by a specific exception that handles the -2292 error</li>
    <li>A list of tables where no record should be deleted could be usefull. If the logic would encounter such a table, it should also stop. This would be to prevent that data from some system critical tables could be deleted per accident.</li>
    <li>The reference from the FK constraint to the PK constraint should include the table name and if possible the owner (as long as you use user_* views the owner is always the same. But we could extend this to the ALL_* views). I never met a system where different tables have the identical FK constraint names, however just make this fool proof.</li>

  • Using delete in SQL Joins

    What is wrong in this query am getting incorrect syntax near ','.error.I am using sql server 2014
    DELETE ab, b
    FROM Authors AS a INNER JOIN AuthorArticle AS ab ON a.AuthID=ab.AuthID
    INNER JOIN Articles AS b ON ab.ArticleID=b.ArticleID
    WHERE AuthorLastName='Tom';

    What is wrong in this query am getting incorrect syntax near ','.error.I am using sql server 2014
    DELETE ab, b
    FROM Authors AS a INNER JOIN AuthorArticle AS ab ON a.AuthID=ab.AuthID
    INNER JOIN Articles AS b ON ab.ArticleID=b.ArticleID
    WHERE AuthorLastName='Tom';
     you cannot delete multiple table rows using a single delete command... you need either separate delete commands - each for one table  or better go with foreign key set up and on delete cascade.
    refer : http://blog.sqlauthority.com/2012/09/27/sql-server-not-possible-delete-from-multiple-table-update-multiple-table-in-single-statement/
    Hope it Helps!!

  • Problem on DELETE CASCADE

    my following tables not allow me to delete the parent table student and the corperate recode in child table also get delete , why
    create table Student(       student_id  int(10) not null  ,       sure_name VARCHAR(25)  not null,       english_name Varchar(25) default null,       chinese_name varchar(35) CHARACTER SET utf8 COLLATE utf8_general_ci not NULL,       student_hkid  varchar(12) not null,       address varchar(100) default null,       mobile_No  varchar(15) default null,       home_Telephone  varchar(15) default null,       email    varchar(20) not null,       faculty  varchar(70) default null,       department varchar(100) default null,       local_student varchar(3) default 'No',       fresh_student varchar(3) default 'No',       fulltime_student varchar(3) default 'No',       first_Ustudent varchar(3) default 'No',        userIp  VARCHAR(45)  not NULL,       accessTime  VARCHAR(45)  not NULL,       primary key(student_id))TYPE=MyISAM CHARACTER set utf8; create table Student_financial_info(   student_id  int(10) not null,   grant_loan varchar(3) default 'No',   uploadfile  text default null,   notification_time varchar(10) default null,   father_name  varchar(25) default null,   father_HKID  varchar(12) default null,   father_Salary decimal(6,2) ,   father_live_together varchar(3),   mother_name  varchar(25) default null,   mother_HKID  varchar(12) default null,   mother_Salary decimal(6,2) ,   mother_live_together varchar(3),   1th_sibling_name  varchar(25) default null,   1th_sibling_HKID  varchar(12) default null,   1th_sibling_Salary decimal(6,2) ,   1th_sibling_together varchar(3),   2th_sibling_name  varchar(25) default null,   2th_sibling_HKID  varchar(12) default null,   2th_sibling_Salary decimal(6,2) ,   2th_sibling_together varchar(3),   3th_sibling_name  varchar(25) default null,   3th_sibling_HKID  varchar(12) default null,   3th_sibling_Salary decimal(6,2) ,   3th_sibling_together varchar(3),   4th_sibling_name  varchar(25) default null,   4th_sibling_HKID  varchar(12) default null,   4th_sibling_Salary decimal(6,2) ,   4th_sibling_together varchar(3),   addition_income Varchar(200) default null,   primary key(student_id ),   FOREIGN KEY(student_id) REFERENCES student(student_id) ON DELETE CASCADE ON UPDATE CASCADE)TYPE=MyISAM CHARACTER set utf8;

    HJava wrote:
    hi thank you!
    I change my table Engine under Mysql Query Browser, but Foreign Key settinis not action at all ( thank you you mention the foreign key is ignore), quite stronge for me, I have to drop the table and change the table engine to InnoDB in my create table code and run it under command line client,
    now, It work.
    are there any different to  use command line Client and Mysql Query Brower?
    thank you!Not really, other than appearance. But, the "GUI" might let you simply change the type of table on an already created database (I don't know, haven't tried it), unfortunately, that won't activate any foreign keys when changing a MyISAM to InnoDB (although it will destroy keys on an InnoDB when changing to MyISAM), as, like the above quote says, the keys are not only not used, they are not even stored. I.E. MySQL no longer even knows, nor cares, that you even attempted to create a foreign key for that table. So, you must drop and recreate the table, you can't simply "change" it. Although you could change it (if the GUI even does this) and then add the foreign key constraints.

  • COPA vs. BCS design decisions (ex. profitability by customer in BCS)

    We are trying to meet a business goal of identifying gross profit by customer.
    We realize "customer" as a field in BCS is problematic, so we are thinking of only storing certain customers in BCS with a catch-all "Others" customer - with the goal of keeping the BCS data volume reasonable.
    Consider the scenario: US company sells material X qty 1 to Spain company for 100 with cost of 30 (therefore profit of 70)
    Spain sells same material X qty 1 to third-party customer for 120.
    Spain from a local perspective profits 20, however the group from an overall perspective profits 90 ( the US revenues of 100 eliminate against the Spain COGS of 100 so you are left with revenue of 120, COGS 30, profit 90 - from the group perspective ).
    We want to know how to see, on a customer level, the 90 profit from these transactions. 
    We do not believe COPA can do this, can this may be accomplished in BCS? 
    If you do a "one-sided" elimination (elimination driven by the revenue side only) of the intercompany revenue the system would not be able to reference customer on the elimination. We are wondering if this scenario of analyzing overall profit by customer can be accomplished by BCS functionality and are particularly interested in knowing what functionality you used to accomplish this requirement and in what sequence within the BCS close (BCS monitor).
    Thank you in advance for any input you may have.
    Also we are interested in any opinions/comments anyone may have about design decisions regarding BCS vs. COPA in BW.  BCS business content identifies a sample design for a BCS data model including item, company, movement type, trading partner, functional area, etc.  COPA (as configured in R3/ECC and extracted to BW) commonly features analysis by customer, material, etc.  Considering BCS features elimination functionality, what design concerns have people faced with respect to fields that they include in both reporting systems?  Obviously a prominent concern is sizing of the systems, but what common characteristics has anyone decided to feature in both systems? What considerations drove the decisions as to what common characteristics to feature in both BCS and COPA?

    Hi John,
    Reg, your last question - might be useful info in here, if you have not seen it yet:
    Re: Reports using COPA cube, BCS Cube

  • Delete cascade not working?

    Hi,
    I am using Eclipse Link and I was surprised to know that Delete Cascade does not seem to work. Basically, I have an entity which is a composite of another entity and has a OneToMany relationship. I have used Cascade.all.
    When I remove the secondary entity from the list of the primary entity, the operation succeeds and it seems that the entity has been deleted. However, a delete SQL is not generated and the record still remains in the DB.
    However, after removing the entity from the list and then if I call explicitly EntityManager.remove(), then the record is removed.
    Is this a bug? Seems so.
    Please let me know, thanks.

    Hello,
    Cascade delete is similar to cascade persist etc, in that only the remove operation on the parent will cascade. Ie, you must call persist or remove on the parent for the operation to cascade to the child. What you are expecting is more along the lines of private ownership in EclipseLink.
    Depending on the version you are using, you can mark the mapping as private owned using the @PrivateOwned annotation. Or you can mark it in code using a customizer as described here:
    http://www.nabble.com/TopLink-equivalent-to-Hibernate-delete-orphan-cascade-type-td8164369.html
    Best Regards,
    Chris

  • JPA - How can i add ON DELETE CASCADE constraint ?

    I have a three tables.
    1. A (name)
    2. B (name)
    and relationship(manytomany) table of A and B
    3. C (a_name,b_name)
    I am using 2 JPA entities@Entity
    public class A {
         @id
         String name;
         @ManyToMany
         @JoinTable(name="C",
                   joinColumns=@JoinColumn(name="a_name"),
                   inverseJoinColumns=@JoinColumn(name="b_name"))
         private List<B> bs = new ArrayList<B>();
         //getter setter methos
    }and@Entity
    public class B {
         @id
         String name;
         @ManyToMany(mappedBy="bs")
         private List<A> as = new ArrayList<A>();
         //getter setter methos
    }DDL of table C which is generated by JPA is something like thatCREATE TABLE C (
    "a_name" VARCHAR,
    "b_name" VARCHAR,
    CONSTRAINT "c_a_name_fkey" FOREIGN KEY ("a_name")
    REFERENCES a(name)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
    CONSTRAINT "c_b_name_fkey" FOREIGN KEY ("b_name")
    REFERENCES b(name)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
    )but i want to add constraint ON DELETE CASCADE* instead of ON DELETE NO ACTION_ in above relationship table C.
    how can i do this ?
    Thanks in advance.

    Right click the message and select Edit as New.

  • Design decision / purpose / aim of audit trail

    Hi,
    since the audit trail doesn't contain so many data and BAM is great for real time monitoring my question is: What is the design decision, or the purpose / aim of the audit trail?
    What was the main target to implement a audit trail? Is it primarily for debugging? To see the flow the process instance has taken?
    Obviously the audit trail isn't the right way for real time monitoring, right? So maybe you can tell me, why there is an audit trail at all. What was the design decision behind it?
    Greetings
    Mike

    Hi Mike,
    While I am certainly not one of the people who designed it, I think I can answer your question.
    The audit trail is what the name implies - it keeps track of all the steps preformed by the process instance. It lets you view the instance history, variable content etc. and lets you see the current state of an in flight instance or to be more exact lets you see the last dehydration point. You can minimize the trail data, or even disable it.
    BAM however is real time monitoring of business or operational data or KPI. You send data to the BAM engine using sensors, and you only send the data you want to send when you want to send it. IF you don't need real real-time monitoring with all the fantastic visual features, alerts etc. of BAM, you can send the same data to a database or JMS server instead and built your own monitoring.
    hth,
    ~ronen

Maybe you are looking for

  • Any clues on how to create a resource object to push a user object into res

    I am working on a situation where I have to push a user object via a resource object and not having assigned to the user (in other words not linked to the user). any ideas? My approach is some thing like this IN the "user" object I do set all the att

  • Mail will not search in the "on my mac" folder

    Hi everyone, I've been trying to come up with a useful solution to essentially archive messages from an email account that is no longer active. I would like to keep these messages searchable in Mail though. I thought if I put them in the "On My Mac"

  • IPhoto 08 Unreadable file msg.

    I am trying to import my photos off of both a Canon PS and a Samsung. The files import to the library but then I get a message that all files are unreadable. Any help would be great. thanks.

  • SUS-MM integration in Classic Scenario for SRM

    Hello All, We are using SAP SRM in classic Scenario. We also plan to integrate SUS with MM . Looks like in the Classic Scenario with SRM , only the Direct material procurement is possible using MM- SUS. How would the SUS-MM integration work for Indir

  • Records Missed in PSA from R/3 for BI Content Data Sources

    Hi Friends,                       I'm extracting the data for the data target "0CCA_C11" using the data sources 0CO_OM_CCA_9 & 0CO_OM_CCA_1, but for the data source 0CO_OM_CCA_1, it is showing 25000 records in R/3 while checking in RSA3 transaction,