Modelling a one to many table's in a form

I'm looking at creating a program with two tables, Riders and Group. A Group can have many riders and I'm not sure how I can model this in a form. This is my first attempt at righting a full scale program in Java so would like to do it correctly from the start. I've looked at the MVC pattern to keep the view's updated but I'm having problem's getting my head around how to keep the list updated for the group.
My question to you is to ask for an example, maybe open source, example that I can see how someone managed to create this and learn from it. Any help would be greatly appreciated.

bikingbadger wrote:
I'm looking at creating a program with two tables, Riders and Group. A Group can have many riders and I'm not sure how I can model this in a form. This is my first attempt at righting a full scale program in Java so would like to do it correctly from the start. I've looked at the MVC pattern to keep the view's updated but I'm having problem's getting my head around how to keep the list updated for the group.
My question to you is to ask for an example, maybe open source, example that I can see how someone managed to create this and learn from it. Any help would be greatly appreciated.What I have done in the past is use a DropDown and a List, the selection on the DropDown causes the list to populate with the available options/children.

Similar Messages

  • One-to-many table linking

    Hi all,
    I'm trying to write a report with multiple one-to-many table links.  The issue is I only want a single record from the linked tables.  The main table is an item table and the linked tables are issue and receipt.  I want to display information from the last issue record and the last receipt record along with the item information.  Not sure how to restrict the joins to just a single record (also need to sort desc on dates in the linked tables).  Does this require the use of a view? or a custom sp?
    Thanks for taking your time to help.
    Kevin

    To bring back a single record then you will probably need to use a View , command or SP.
    However, in Crystal you can bring back multiple records and only display the record you want. The easiest way will be to group
    Data on Date and then Item code.
    Place the data you want to see in in Item group footer and suppress details and all other Group headers and footers.
    To get receipt date just use a maximum summary of receipt date in item group footer
    Ian

  • Using models for multiple one-to-many table relationships

    Hi there!
    I have a database with tables that have one-to-many relationships. They
    are laid out with a standard join tables:
    A     A_B     B     B_C     C
    a_id     a_id     b_id     b_id     c_id
    b_id     c_id
    and has 1 A for n of B. In some cases, the B table also joins with
    another table for yet more information.
    My question: what technique should I use to organize a database of this
    type into JATO Models?
    I could create an AModel, for example, that would have a set of query
    field descriptors for the information relevant from tables A and B. But
    then how do I query table C when that information is necessary? Or,
    more to the point, create information in C when a new entry in B is created.
    Do the models use each other, or is that left up to the view bean (seems
    incorrect for data isolation).
    Any pointers appreciated,
    Byron

    Byron,
    You can create a separate "modifying" model for each table and do
    inserts/deletes/updates in a transaction across the tables with the
    three models. That's really the easy part.
    The somewhat more tedious part is the "join" models, but not hard to do.
    You just have to decide what you need from the different tables and
    quite possibly create multiple join models for different select scenarios.
    So let's just run through a simple two table join model.
    Create a SQL model. I usually name them based on the table joins. Let's
    use a somewhat more real example:
    table = customer
    columns = custid, firstname, lastname, email
    table = address
    columns = addrid (seqid), custid (fk), type
    ('w'ork,'h'ome,'b'illing,'s'hipping,'o'ther), address1, address2, city,
    state, zip
    Suppose we want to select a customer and show a list of all his/her
    addresses.
    I would create a SQL model class (extending QueryModelBase of course)
    called CustomerAddressJoinModel (this naming convention gets tough with
    three or more tables, so you have to be creative).
    In that model, I would create the fields just like any single table
    model. You need only include the columns you need. Maybe you create one
    join model that only has custid, lastname, firstname, type, city, zip.
    OK, so we only cut out 2 columns, but you get the point. If you had a
    table with lots of columns with data you rarely need to display and/or
    update, then you can exclude them. Probably a slick way to exclude
    dynamically, but this is straight forward.
    Another join model could have all the columns of both tables.
    So the trick is to set the static where criteria (using the
    setStaticWhereCriteria method) in the model's constructor. I think the
    sql model template has this in it.
    setStaticWhereCriteria(customer.custid=address.custid);
    Now you just set your criteria like any other model, and execute it.
    For a 3 table join, you just set the static criteria like this:
    tableA.aid=tableB.aid AND tableB.bid=tableC.bid
    does that make sense?
    You can also set the "modifying table" (setModifyingTable(table) - i
    think that's right) in the model and inserts/updates/deletes will only
    operate on that table within the model. Problem is maybe in the the
    field binding in your views. You may want to select from one field, and
    modify using another field. Can be done though, just not directly supported.
    In the next release of JATO, you will be able to set a display fields
    binding for read and write using different fields and even different models.
    craig
    Byron Servies wrote:
    Hi there!
    I have a database with tables that have one-to-many relationships. They
    are laid out with a standard join tables:
         A     A_B     B     B_C     C
         a_id     a_id     b_id     b_id     c_id
         b_id     c_id
    and has 1 A for n of B. In some cases, the B table also joins with
    another table for yet more information.
    My question: what technique should I use to organize a database of this
    type into JATO Models?
    I could create an AModel, for example, that would have a set of query
    field descriptors for the information relevant from tables A and B. But
    then how do I query table C when that information is necessary? Or,
    more to the point, create information in C when a new entry in B is created.
    Do the models use each other, or is that left up to the view bean (seems
    incorrect for data isolation).
    Any pointers appreciated,
    Byron
    To download the latest version of JATO, please visit:
    http://www.sun.com/software/download/developer/5102.html
    For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp

  • One to Many table join -- concat field per record grouped by id

    Post Author: wm5
    CA Forum: Formula
    Hello,
    I am using Crystal Reports XI and have two tables that have a one to many relationship and are joined by an JobID (number).
    Below is a sample with relative fields for each table.
    job_table: JobID (number), Manager (text), Status (text)
    jobaudit_table : JobAuditID (number), JobID (Number), FormID (Number)
    There is a one to many relationship with jobaudit_table having multiple records for each JobID in job_table.
    I have created a Group Header using the job_table.JobID and suppressed the detail section.
    In the group header for each JobID I display the JobID, Manager, Status. I also use the below formula to determine if any records in the jobaudit_table has a record where FormID = 90. If so, I display "Yes". If not, "No".
    So my report currently looks like.
    JobID     Manager     Status     Audit Performed
    1           Manager 1  Closed           N
    2          Manager 2   Closed           Y
    Here are the formula's I use to determine if any records in jobaudit_table contains a record where FormID = 90.
    @ja90exists
    if {jobaudit_table.FormID} = 90 then    1else    0;
    if sum({@ja90exists},{job_table.JobID}) = 0 then    "No"else    "Yes";
    Everything so far works fine. What I would like to do now is add a hyperlink to a script to view the job audit when in the above report the "Audit Performed" column is "Yes"
    So Report is now:
    JobID     Manager     Status     Audit Performed
    1           Manager 1  Closed           N
    2          Manager 2   Closed           Y (hyperlink to view audit)
    I cannot figure out how to gather the valid JobAuditIDs where FormID = 90 grouped by JobID to be used in the Group Heading section of the report.
    Also, it is unlikely, but possible that more than one job_audit record exists with FormID = 90 per JobID. So, my hyperlink could look like http://mysite.com/viewjobaudit.aspx?jobid=[jobaudit_table.JobAuditID],[jobaudit_table.JobAuditID] .
    Thanks for any help. And if this post is not clear let me know and I will clarify.
    wm5

    Post Author: bettername
    CA Forum: Formula
    Although I can't think of a way to get multiple hyperlinks, this should be a start.  It (should) hyperlink to the last job/audit in the group that formID of 90.  Oh, I assumed that the hyperlink should have been  xxxx...jobID,jobAuditID! 
    I think there may be a way of getting hyperlinks to every "90" record, but that will involve a subreport, so lets try this first...
    1 - everything from your group header to the group footer...
    2 -  add a formula into the group header that says:
    whileprintingrecords;
    stringvar jobauditID="";
    stringvar jobID:=";
    3 - Then add a formula to the details section:
    whileprintingrecords;
    stringvar jobauditID;
    stringvar jobID;
    if {jobaudit_table.FormID} = 90
    then (jobID:=totext({job_table.job_id},0,""); jobauditID:=totext({jobaudit_table.jobaudit_id},0,"")
    4 - Finally, on your "Audit Performed" formula, have a conditional hyperlink that says:
    whileprintingrecords;
    stringvar jobauditID;
    stringvar jobID;
    if {@audit performed} = "Y" then http://mysite.com/viewjobaudit.aspx?jobid=jobID","+jobauditID

  • One to many table insert in JDBC

    hi all, I have an online form when it submit the value will get into three table, one child table is one to many relation to parent , like
    parent  table have(     UserId        int Not null,     UniversityN      varchar(10) Not null,   ...   PRIMARY KEY  (UserId)   PaymentId          int Not null  auto_increment ,     UserId        int Not null, ) child Table( PaymentId          int Not null  auto_increment , UserId        int Not null, UniversityN      varchar(10) Not null, record1            varchar(50) Not null, record2            varchar(50) Not null, record13          varchar(50) Not null,     PRIMARY KEY  (PaymentId),     FOREIGN Key(UserId) REFERENCES Parent(UserId) on Delete     Cascade on update cascade)Type=InnoDB DEFAULT CHARSET=utf8; )
    then I have
    conn.setAutoCommit(false); calstat1 = (CallableStatement) conn.prepareCall(                     "{ call Insert_Parent(?,?,?,?,?,?,?,?,?,?,?,? )}"); calstat2 = (CallableStatement) conn.prepareCall(                     "{ call Insert_ChildRecords(?,?,?,?,?,?,?,?,?,?,?,? )}");
    and the UniversityN , recored1, record2, record3 all come from the input form, how can i handle this one to many insert? for each submit the parent table always one row, and the child table is a lease one up to five rows the if the did have five the userId , and UniversityN is same, but the recore 1. record2... is different
    thank you

    I think you have a problem with your database table definitions that you need to fix before coding java.
    In the above, I dont think you need the first PaymentId (in the 'have' table). I also dont think your tables are normalized since I see 'UniversityN' in both the parent and child record. Also, you should rename your tables to something meaningfull rather than 'have' and 'table'. Also, rename the fields better. Ideally get your friendly neighborhood DBA to review your tables. Only when they are well defined should you start to work on java.
    Here's an example:
    parent  table:
    Customer(
        id                number, not null, primary key, must be unique, auto increment
        userId         number, not null, natural key, must be unique
        universityN  varchar(10), Not null
    child Table:
    Payment(
        id                      number, not null, primary key, must be unique, auto increment
       customer_id        number, not null, foreign key to the customer table's id field
       record1               varchar(50), not null,
       record2               varchar(50), not null,
       record3               varchar(50), not null,
        Cascade on delete record when parent is deleted
        dont cascase update record
    )Note: in the above, record1,record2, record3 should probably be put in its own table, with a foreign key back to the payment table.
    Note: each table in your database has its own id that is auto generated. Some have a natural key (like userID) that can be used to look up records independent of the auto generated key.
    Note the customer_id (foreign key) has the name of table it refers to (customer) and the key its refering to in that table (id).
    Note: when you insert a new customer, you need to get the newly generated id. Use the natural key to retreive the id in order to put it in the new payment table's customer_id field.
    I suggest you dont cascade delete any child table. Do it programmatically so you can better learn the issues that come up as you insert, update, and delete various parent and child combinations.

  • One to Many table level replication

    Hi All,
    I was configuring Streams replication between one table to many(3) tables in the same database(10.2.0.4)
    Below figure states my requirement.
                                        |--------->TEST2.TAB2(Destination) 
                                        |
    TEST1.TAB1(Source) ---------------->|--------->TEST3.TAB3(Destination)
                                        |
                                        |--------->TEST4.TAB4(Destination)Below are the steps i followed. But replication is not working.
    CREATE USER strmadmin
    IDENTIFIED BY strmadmin
    GRANT CONNECT, RESOURCE, AQ_ADMINISTRATOR_ROLE, DBA to strmadmin;
    BEGIN
    DBMS_STREAMS_AUTH.GRANT_ADMIN_PRIVILEGE(
    grantee => 'strmadmin',
    grant_privileges => true);
    END;
    check  that the streams admin is created:
    SELECT * FROM dba_streams_administrator;
    SELECT supplemental_log_data_min,
    supplemental_log_data_pk,
    supplemental_log_data_ui,
    supplemental_log_data_fk,
    supplemental_log_data_all FROM v$database;
    ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
    alter table test1.tab1 ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
    alter table test2.tab2 ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
    alter table test3.tab3 ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
    alter table test4.tab4 ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
    conn strmadmin/strmadmin
    var first_scn number;
    set serveroutput on
    DECLARE  scn NUMBER;
    BEGIN
      DBMS_CAPTURE_ADM.BUILD(
             first_scn => scn);
      DBMS_OUTPUT.PUT_LINE('First SCN Value = ' || scn);
      :first_scn := scn;
    END;
    exec dbms_capture_adm.prepare_table_instantiation(table_name=>'test1.tab1');
    begin
    dbms_streams_adm.set_up_queue(
    queue_table => 'strm_tab',
    queue_name => 'strm_q',
    queue_user => 'strmadmin');
    end;
    var first_scn number;
    exec :first_scn:= 2914584
    BEGIN
      DBMS_CAPTURE_ADM.CREATE_CAPTURE(
         queue_name         => 'strm_q',
         capture_name       => 'capture_tab1',
         rule_set_name      => NULL,
         source_database    => 'SIVIN1',
         use_database_link  => false,
         first_scn          => :first_scn,
         logfile_assignment => 'implicit');
    END;
    BEGIN
      DBMS_STREAMS_ADM.ADD_TABLE_RULES(
         table_name         => 'test1.tab1',
         streams_type       => 'capture',
         streams_name       => 'capture_tab1',
         queue_name         => 'strm_q',
         include_dml        => true,
         include_ddl        => false,
         include_tagged_lcr => true,
         source_database    => 'SIVIN1',
         inclusion_rule     => true);
    END;
    BEGIN 
      DBMS_STREAMS_ADM.ADD_TABLE_RULES(
              table_name         => 'test2.tab2',
              streams_type       => 'apply',
              streams_name       => 'apply_tab2',
              queue_name         => 'strm_q',
              include_dml        => true,
              include_ddl        => false,
              include_tagged_lcr => true,
              source_database    => 'SIVIN1',
              inclusion_rule     => true);
    END;
    BEGIN 
      DBMS_STREAMS_ADM.ADD_TABLE_RULES(
              table_name         => 'test3.tab3',
              streams_type       => 'apply',
              streams_name       => 'apply_tab3',
              queue_name         => 'strm_q',
              include_dml        => true,
              include_ddl        => false,
              include_tagged_lcr => true,
              source_database    => 'SIVIN1',
              inclusion_rule     => true);
    END;
    BEGIN 
      DBMS_STREAMS_ADM.ADD_TABLE_RULES(
              table_name         => 'test4.tab4',
              streams_type       => 'apply',
              streams_name       => 'apply_tab4',
              queue_name         => 'strm_q',
              include_dml        => true,
              include_ddl        => false,
              include_tagged_lcr => true,
              source_database    => 'SIVIN1',
              inclusion_rule     => true);
    END;
    select STREAMS_NAME,
          STREAMS_TYPE,
          TABLE_OWNER,
          TABLE_NAME,
          RULE_TYPE,
          RULE_NAME
    from DBA_STREAMS_TABLE_RULES;
    begin 
      dbms_streams_adm.rename_table(
           rule_name       => 'TAB245' ,
           from_table_name => 'test1.tab1',
           to_table_name   => 'test2.tab2',
           step_number     => 0,
           operation       => 'add');
    end;
    begin 
      dbms_streams_adm.rename_table(
           rule_name       => 'TAB347' ,
           from_table_name => 'test1.tab1',
           to_table_name   => 'test3.tab3',
           step_number     => 0,
           operation       => 'add');
    end;
    begin 
      dbms_streams_adm.rename_table(
           rule_name       => 'TAB448' ,
           from_table_name => 'test1.tab1',
           to_table_name   => 'test4.tab4',
           step_number     => 0,
           operation       => 'add');
    end;
    col apply_scn format 999999999999
    select dbms_flashback.get_system_change_number apply_scn from dual;
    begin 
      dbms_apply_adm.set_table_instantiation_scn(
      source_object_name   => 'test1.tab1',
      source_database_name => 'SIVIN1',
      instantiation_scn    => 2916093);
    end;
    exec dbms_capture_adm.start_capture('capture_tab1');
    exec dbms_apply_adm.start_apply('apply_tab2');
    exec dbms_apply_adm.start_apply('apply_tab3');
    exec dbms_apply_adm.start_apply('apply_tab4');Could anyone please help me....Please let me where i have gone wrong.
    If above steps are not correct, then please let me know the desired steps.
    -Yasser

    First of all I suggest implement it to one destination side.
    here is a good example, which I have done
    Just use it and test. Then prepare your other schema`s table (3 destination I mean)
    alter system set global_names =TRUE scope=both;
    oracle@ulfet-laptop:/MyNewPartition/oradata/my$ mkdir Archive
    shutdown immediate
    startup mount
    alter database archivelog
    alter database open
    ALTER SYSTEM SET log_archive_format='MY_%t_%s_%r.arc' SCOPE=spfile;
    ALTER SYSTEM SET log_archive_dest_1='location=/MyNewPartition/oradata/MY/Archive MANDATORY' SCOPE=spfile;
    # alter system set streams_pool_size=25M scope=both;
    create tablespace streams_tbs datafile '/MyNewPartition/oradata/MY/streams_tbs01.dbf' size 25M autoextend on maxsize unlimited;
    grant dba to strmadmin identified by streams;
    alter user strmadmin default tablespace streams_tbs quota unlimited on streams_tbs;
    exec dbms_streams_auth.grant_admin_privilege( -
    grantee => 'strmadmin', -
    grant_privileges => true)
    grant dba to demo identified by demo;
    create table DEMO.EMP as select * from HR.EMPLOYEES;
    alter table demo.emp add constraint emp_emp_id_pk primary key (employee_id);
    begin
    dbms_streams_adm.set_up_queue (
         queue_table     => 'strmadmin.streams_queue_table',
         queue_name     => 'strmadmin.streams_queue');
    end;
    select name, queue_table from dba_queues where owner='STRMADMIN';
    set linesize 150
    col rule_owner for a10
    select rule_owner, streams_type, streams_name, rule_set_name, rule_name from dba_streams_rules;
    BEGIN
         dbms_streams_adm.add_table_rules(
         table_name          => 'HR.EMPLOYEES',
         streams_type          => 'CAPTURE',
         streams_name          => 'CAPTURE_EMP',
         queue_name          => 'STRMADMIN.STREAMS_QUEUE',
         include_dml          => TRUE,
         include_ddl          => FALSE,
         inclusion_rule     => TRUE);
    END;
    select capture_name, rule_set_name,capture_user from dba_capture;
    BEGIN
         DBMS_CAPTURE_ADM.INCLUDE_EXTRA_ATTRIBUTE(
         capture_name           => 'CAPTURE_EMP',
         attribute_name     => 'USERNAME',
         include          => true);
    END;
    select source_object_owner, source_object_name, instantiation_scn from dba_apply_instantiated_objects;
    --no rows returned   - why?
    DECLARE
         iscn      NUMBER;
    BEGIN
    iscn := DBMS_FLASHBACK.GET_SYSTEM_CHANGE_nUMBER();
         DBMS_APPLY_ADM.SET_TABLE_INSTANTIATION_SCN(
         source_object_name     => 'HR.EMPLOYEES',
         source_database_name     => 'MY',
         instantiation_scn     => iscn);
    END;
    conn strmadmin/streams
    SET SERVEROUTPUT ON
    DECLARE
         emp_rule_name_dml VARCHAR2(30);
         emp_rule_name_ddl VARCHAR2(30);
    BEGIN
         DBMS_STREAMS_ADM.ADD_TABLE_RULES(
         table_name           => 'hr.employees',
         streams_type           => 'apply',
         streams_name           => 'apply_emp',
         queue_name           => 'strmadmin.streams_queue',
         include_dml           => true,
         include_ddl           => false,
         source_database      => 'my',
         dml_rule_name      => emp_rule_name_dml,
         ddl_rule_name      => emp_rule_name_ddl);
    DBMS_OUTPUT.PUT_LINE('DML rule name: '||emp_rule_name_dml);
    DBMS_OUTPUT.PUT_LINE('DDL rule name: '||emp_rule_name_ddl);
    END;
    BEGIN
         DBMS_APPLY_ADM.SET_PARAMETER(
         apply_name => 'apply_emp',
         parameter => 'disable_on_error',
         value => 'n');
    END;
    SELECT a.apply_name, a.rule_set_name, r.rule_owner, r.rule_name
    FROM dba_apply a, dba_streams_rules r
    WHERE a.rule_set_name=r.rule_set_name;
    -- select rule_name field`s value and write below -- example EMPLOYEES16
    BEGIN
         DBMS_STREAMS_ADM.RENAME_TABLE(
         rule_name           => 'STRMADMIN.EMPLOYEES14',
         from_table_name     => 'HR.EMPLOYEES',
         to_table_name          => 'DEMO.EMP',
         operation          => 'ADD'); -- can be ADD or REMOVE
    END;
    BEGIN
         DBMS_APPLY_ADM.START_APPLY(
         apply_name => 'apply_emp');
    END;
    BEGIN
         DBMS_CAPTURE_ADM.START_CAPTURE(
         capture_name => 'capture_emp');
    END;
    alter user hr identified by hr;
    alter user hr account unlock;
    conn hr/hr
    insert into employees values
    (400,'Ilqar','Ibrahimov','[email protected]','123456789',sysdate,'ST_MAN',30000,0,110,110);
    insert into employees values
    (500,'Ulfet','Tanriverdiyev','[email protected]','123456789',sysdate,'ST_MAN',30000,0,110,110);
    conn demo/demo
    grant all on emp to public;
    select last_name, first_name from emp where employee_id=300;
    strmadmin/streams
    select apply_name, queue_name,status from dba_apply;
    select capture_name, status from dba_capture;

  • WCF RIA zero-one to many ultimate treeview

    Hi,
    I am using ultimate treeview extension (http://visualstudiogallery.msdn.microsoft.com/ca292c74-661c-48ba-8262-d79a2671c33f)
    This requires a zero-one to many table. I have this working with a table.
    However I need to connect to a WCF RIA service from the control. Currently using 
     public class WorksOrderTree
            [Key()]
            public int id { get; set; }
            [Association("ProductPart", "id", "ParentID")]
            public IEnumerable<WorksOrderTree> Children { get; set; }
            [Association("ProductPart", "ParentID", "id", IsForeignKey = true)]
            public WorksOrderTree Parent { get; set; }
            public int ParentID { get; set; }
    This gives the following error
    Error 1
    f0rmoum1..csdl(26,6) : error 0113: Multiplicity is not valid in Role 'WorksOrderTree' in relationship 'ProductPart'. Because all the properties in the Dependent Role are nullable, multiplicity of the Principal Role must be '0..1'.
    Any idea to to how create zero-one to many in the ria service.
    Thanks
    Steve

    Thanks for your reply Paul.
    Yes I read your blog about the Telerik treeview and it was very helpful. the problem is that I want to use the Telerik RadTreeListView control instead, and It seem that it cannot be used with LightSwitch (for threading problems...)
    So I am obliged to create a RIAService ( that I hope) it can return a hierarchical structure without any lazy loading, so the RadTreeListView can work....
    but It seem that RIAService (Or LightSwitch) Insists on lazy load, and I don't know how to avoid it...
    I know that I can create a service in my UserControl project as you say in your blog but I am trying to create a LightSwitch extention ....
    AAK

  • One to Many with multiple tables on One side and one table on Many side

    Sorry for the confusion in the title. Here is my question. In my program, I have 2 different tables which store 2 different type of entities. Each one of entities has a list of attachments which I stored in a common attachment table. There is a one-to-many relationship between entity tables and attachment table.
    ENTITY_ONE (
    ID
    NAME
    ENTITY_TWO (
    ID
    NAME
    ATTACHMENTS (
    ID
    ENTITY_ID
    ATTACHMENT_NAME
    ENTITY_ID in ATTACHMENTS table is used to link attachments to either entity one or entity two. All IDs are generated by one sequence. So they are always unique. My question is how I could map this relationship into EntityOne, EntityTwo and Attachment JAVA class?

    For EntityOne and EntityTwo you can just define a normal OneToMany mapping using the foreign key.
    Are you using JPA, or the TopLink API? JPA requires a mappedBy for the OneToMany, so this may be more difficult. You should be able to just add a JoinColumn on the OneToMany and make the column insertable/updateable=false.
    For the attachment, you could either map the foreign key as a Basic (DirectToFieldMapping) and maintain it in your model, or use a VariableOneToOne mapping in TopLink (this will require the entities share a common interface).
    James : http://www.eclipselink.org : http://en.wikibooks.org/wiki/Java_Persistence

  • Help with multi-table mapping for one-to-many object inheritance

    Hi,
    I have posted on here before regarding this (Toplink mapping for one-to-many object inheritance but I am still having problems mapping my object model to my schema.
    Object model
    The Person and Organisation objects contain base information and have the primary keys person_id and organisation_id. It is important that there is no duplication of person and organisation records, no matter how many times they are saved in different roles.
    There are two types of licenceholder in the problem domain, and the ILicenceHolder interface defines information and methods that are common to both. The PersonalLicenceHolder object represents one of these types of licenceholder, and is always a person, so this class extends Person and implements ILicenceHolder.
    The additional information and methods that are required by the second type of licenceholder are defined in the interface IPremisesLicenceHolder, which extends ILicenceHolder. Premises licence holders can either be people or organisations, so I have two objects to represent these - PremisesLicenceHolderPerson which implements IPremisesLicenceHolder and extends Person, and PremisesLicenceHolderOrganisation which implements IPremisesLicenceHolder and extends Organisation.
    The model is further complicated by the fact that any single Person may be both a PersonalLicenceHolder and a PremisesLicenceHolderPerson, and may be so several times over. In this case, the same basic Person information needs to be linked to several different sets of licenceholder information. In the same way, any single Organisation may be a PremisesLicenceHolderOrganisation several times over.
    Sorry this is complicated!
    Schema
    I have Person and Organisation tables containing the basic information with the primary keys person_id and organisation_id.
    I have tried to follow Donald Smith's advice and have created a Role table to record the specialised information for the different types of licence holder. I want the foreign keys in this table to be licenceholder_id and licence_id. Licenceholder_id will reference either organisation_id or person_id, and licence_id will reference the primary key of the Licence table to link the licenceholder to the licence. Because I am struggling with the mapping, I have changed licenceholder_id to person_id in an attempt to get it working with the Person object before I try the Organisation.
    Then, when a new licenceholder is added, if the person/organisation is already in the database, a new record is created in the Role table linking the existing person/organisation to the existing licence rather than duplicating the person/organisation information.
    Mapping
    I am trying to use the toplink mapping workbench to map my PremisesLicenceHolderPerson object to my schema. I have mapped all inherited attributes to superclass (Person). The primary table that the attributes are mapped to is Person, and I have used the multi-table info tab to add Roles as an additional table and map the remaining attributes to that.
    I have created the references PERSON_ROLES which maps person.person_id to roles.person_id, ROLES_PERSON which maps roles.person_id to person.person_id and ROLES_LICENCE which maps roles.licence_id to licence.licence_id.
    I think I have put in all the relationships, but I cannot get rid of the error message "The following primary key fields are unmapped: PERSON_ID".
    Please can somebody tell me how to map this properly?
    Thank you.

    I'm not positive about your mappings, but it looks like the Person object should really have a 1:M or M:M mapping to the Licenceholder table. This then means that your object model should be similar, in that Person object could have many Licenses, instead of being LicenceHolders. From the looks of it, you have it set up from the LicenceHolder perspective. What could be done instead if a LicenceHolder could have a 1:1 reference to a person data object, rather than actually be a Person. This would allow the person data to be easily shared among licences.
    LicenceHolder1 has an entry in the LicenceHolder table and Person table. LicenceHolder2 also has entries in these tables, but uses the same entry in the Person table- essentially it is the same person/person_ID. If both are new objects, TopLink would try to insert the same person object into the Person table twice. I'm not sure how you have gotten around or are planning to get around this problem.
    Since you are using inheritance, it means that LicenceHolder needs a writable mapping to the person.person_id field- most commonly done through a direct to field mapping. From the description, it looks like roles.person_id is a foreign key in the multiple table mapping, meaning it would be set based on the value in the person.person_id field, but the person.person_id isn't actually mapped in the object. Check to make sure that the ID attribute LicenceHolder is inheriting from person hasn't been remapped in the LicenceHolder descriptor to a different field.
    Best Regards,
    Chris

  • SSAS 2008 snowflake - dimensions with one-to-many relationship (NOT fact table) and hierarchy?

    Hi, below is my data model for SSAS 2008 on snowflake schema.
    Below is SQL Server DW tables:
    DimStudent - StudentID [primarykey], StudentName, DateOfBirth, AddressID
    DimStudentAddresses - AddressID [primarykey], StudentID [foreignkey], ddressLine1, AddressLine2, AddressType
    FactEnrolment - StudentID, EnrolWeek, EnrolFees
    So here FactEnrolement.StudentID is joined to DimStudent.StudentID column,
    and relationship between DimStudent & DimeStudentAddresses is one to many I.e. one student can have multiple addresses like primary or secondry address.
    To design snowflake schema in SSAS 2008 BIDS project :
     [Question-1] how to join one-to-many dimensions (NOT fact table) Like DimStudent & DimAddresses?
     [Question-2] At the end I want to have a single dimension only I.e. Student which should have both DimStudent & DimStudentAddresses tables attributes init. So I can create hierarchy from these two table into a single dimension? How
    to do this?
    Please reply with feedback particular to my above scenario as I refereed other MSDN forums but nothing solid I found.
    Any STEP-BY-STEP guideline please. Many thanks.

    Hello KM,
    Have you solved this issue after refer to Bill's suggestion? Please let us know how things go.
    If you have any feedback on our support, please click
    here.
    Best Regards,
    Elvis Long
    TechNet Community Support

  • 3 way one-to-many through a single link table

    I have 3 tables that are linked through one to many relationships in a single link table. Here's the real relationships:
    assay(id)
    multiplex(id, assays)
    markerset(id, assays, multiplexes)
    Here's the database schema:
    assay(id, name)
    markerset(id, name)
    multiplex(id, name)
    assay_marker_set(assay_id[not null], marker_set_id[not null], multiplex_id[nullable])
    I've mapped one-to-many relationships between markersets and assays, and multiplexes and assays, and BOTH of these one-to-manys need to be writable. In the record creation process, assays are associated with markersets, and then assays are associated with multiplexes, which in turn are associated with markersets.
    Here's our dilemma. When committing multiplexes through a unit of work, the one-to-many with assays can't see the one-to-many with markersets, so the commit fails because the markerset key is null.
    We've gotten around the problem by creating a postSave() method in markerset that writes multiplex changes once they are created. But again, in a unitofwork commit, saving a markerset fires the postSave() method, which writes assays and multiplexes that have not yet been written to the database.
    We've gotten around THAT by only turning on postSave() when creating multiplexes, not when associating assays with markersets.
    My question is, is there a more conventional approach to this problem? Clearly, the database needs to be reworked, but time constraints and the quantity of data to be curated makes changing the schema impossible. Or have we arrived at the most sensible solution to a ridiculous problem? Currently what we have works, it's just incredibly complicated, and nearly unmaintainable.
    Thanks for the time to even read this post, and mocking is permitted ;-)
    Paul Cooper
    GlaxoSmithKline US Bioinformatics

    Looks like your object model does not match your data model.
    From you object model you seem to have,
    Assay
    MarkerSet 1-m Assay, 1-m Multiplex
    Multiplex 1-m Assay
    From your data model you have,
    Assay 1-m AssayMarkerSetAssociation
    MarkerSet 1-m AssayMarkerSetAssociation
    Multiplex 1-m AssayMarkerSetAssociation
    AssayMarkerSetAssociation 1-1 Assay, 1-1 MarkerSet, 1-1 Multiplex
    (your object model seems to be also missing the name)
    I'm not exactly sure how you have your mapping working, but it would seem the best solution is to introduce an AssayMarkerSetAssociation object into your object model.
    If you do not wish to use this object in your model, you could just use it internally to store the relationship and still have get/set methods for the relationships that you want that initialize themselves from the associations.
    So your object model would be,
    Assay
    MarkerSet 1-m AssayMarkerSetAssociation (+ getAssays, getMultiplexes methods)
    Multiplex 1-m AssayMarkerSetAssociation (+ getAssays, method)
    AssayMarkerSetAssociation 1-1 Assay, 1-1 MarkerSet, 1-1 Multiplex
    In general you seem to be able to get your mapping working without changing your object model, but are probably better off for maintainability to change your model slightly.

  • How to create one to many relation database based on existing Tables?

    Let say I have got 10 tables. Out of these 10 tables one table is used to navigate to other tables and at the some time providing some useful information. Therefore other 9 Tables have the identical structure.
    The question is, how can I convert these 10 tables into 2 tables, ie each row of first table correspond to the different data of the other table (one to many relation)?

    Hello,
    >>The question is, how can I convert these 10 tables into 2 tables, ie each row of first table correspond to the different data of the other table (one to many relation)?
    I do not quite understand what you ask and I doubt if Entity Framework supports this scenario, since you mentions these tables already exist, after importing them to the designed windows, we cannot modify them or it would throw an error shows the database
    and model is mismatched.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • ODI Interface - One to many Transactional table to Flat Table

    Hi,
    In my transactional system I have two tables Program and Program Details, Program and Program Details is one to many relationship. I need to create a target table with few columns from Programs and all columns from Program Details as a flat target table, please let me know how to design the interface. Thanks for your time and help.

    HI,
    create a data store with required columns
    and specify the file format as filename.txt at resource name(available at definition tab in data model) then your target will be created at yout logical schema path.
    Thanks,
    Swaroopa
    Edited by: 989684 on Mar 7, 2013 9:03 PM

  • Display Data from multiple models in one table

    Hi Experts,
    Is it possible to display data from multiple models in one table smltnsly.
    I have created a table dynamically.Now I would like to display data from multiple models... If this possible,can anyone give me a lead as to how to do it..
    Regards
    SU

    Hi
    Your Model Nodes be
    Model1
    ---Output_Model1
    Attrib1
    Attrib2
    Model2
    ---Output_model2
    Attrib1
    Attrib2
    and the value node is
    ValueNode
    ---Attrib1
    ---Attrib2
    Now the coding.
    int size;
    IPrivate<ViewName>.IOutput_mode1Node  node1 = wdContext.nodeOuptut_Model1();
    IPrivate<ViewName>.IValueNodeElement elem;
    size = node1.size();
    for(int i=0; i<size; i++)
       elem = wdContext.createValueNodeElement();
       elem.setAttrib1( node1.getOutput_Model1ElementAt(i).getAttrib1() );
       elem.setAttrib2( node1.getOutput_Model1ElementAt(i).getAttrib2();
       wdContext.nodeValueNode().addElement( elem );
    similar code for Model Node 2
    Regards
    Abhimanyu L

  • ONE-to-MANY relationship between tables and forms in APEX

    I recently started using APEX and I have run into an issue.
    I have a ONE-TO-MANY relationship between two tables, A1 and A2, respectively.
    A1:
    A1_ID
    Item
    A2:
    A2_ID
    SubItem
    A1_ID
    I have 2 forms (lets call it F1 and F2) that I use to capture data for A1 and A2.
    On F2, I have the following fields that are setup to capture data:
         A2.A1_ID
    **A1.Item (this is a drop down that is populated using a SELECT statement where the select uses A1.Item field)
         A2.SubItem (user would enter SubItem)
    Note: A2.A2_ID is populated using a SEQ
    Everytime I pick **A1.Item on F2, is there a way to link to A1 table and display A1.A1_ID for every **A1.Item selected on F2?
    If so, I want to store the value captured in F2 for the A1_ID field into A2 table to maintain my 1-to-MANY relationship.
    If this will work, how do I go about implementing this solution?
    Can someone help me?

    I think it sounds like you are asking for a Master-Detail form. Try that and see what you get.
    chris.

Maybe you are looking for

  • Using my new ipod touch as a PDA

    I received an Ipod touch 8GB for Christmas from my husband and I believe he intended for me to be able to use this as a replacement for my Windows Based PDA by Toshiba. I have used a Windows based PDA for many years and really need to have the abilit

  • Receiving binary IDOC via Queue and convert it to XML-IDOC

    Hello, we are focusing the following scenario: We receive an plain, binary IDOC in a MQSeries Queue. We want to pick it, transform it and place it into R/3 (of course using XI 3.0). Afterwards the other way around. I know the Howto for the ABAP mappi

  • International order to US address.

    I have a friend traveling in Japan from the US and they want to order prints from iPhono. They have an account currently setup from their US home address. When they try to order the item, it shows the pricing in yen. How can somebody order prints on

  • Spanning vlans across access switches in distribution block.... please help

    Hi All Can someone please explain why Cisco states that in a Campus Hierarchical modle if Vlans are spanned across Access switches in a distribution block, then the Distrubution to distribution link should be Layer 2. Is this really necesary or just

  • How to change DNS

    I looked on here before and it said change your DNS  to 8 8 8 8. How do you do this?