Many to many relationship for recursive table

HI friends,
I have a use-case where I have several tasks that are inter-dependent on each other. Like one task will execute only if other tasks (which can be more than one) are successful. I am not able to decide what the database design should be for this. If there should be a relationship table with a self-join something like this-
CREATE TABLE Item (
ItemId int,
status varchar,
PRIMARY KEY(ItemId));
CREATE TABLE Item_Relation (
itemId int,
dependsOnItem int,
PRIMARY KEY(itemId, dependsOnItem),
FOREIGN KEY(itemId) REFERENCES Item (ItemId),
FOREIGN KEY(dependsOnItem) REFERENCES Item (ItemId));
is it recommmended because this is the only solution I see for this?
Thanks.

Looks like your trying to embedd business logic in the database tables. It should be in your java project only.
I suggest you keep your database simple with basic associations between tables (foreign keys). The database
is for storing data that many applications aside from yours will want to use. Your specific business logic requirements
should not be in it.
In your java code, you can use transactions in your sql to rollback if something isn't the way it should be.
However, I would not suggest you put your task verification problem code handling in the rollback block of code.
Instead, I suggest you query the database tables and determine if the previous tasks are ok to do the current unit of work.
If so, perform the unit of work (say, write to some other database table). If not, return a message on what the problem is
(better yet, have a validation function that verifies the pervious tasks have been done). All of that should be in a transaction
to play it safe. Why you ask?
The problem is, even if your validation function says the previous tasks are complete, by the time you perform the new unit
of work, the database may have changed and the validation is not longer valid. Therefore you rollback may still occur (ensures the
data in the database is not in an invalid state) Normally in that case, you rollback and tell the user to repeat the operation
(see optomistic concurrency). Exactly how you plan on handling these side issues is up to you.

Similar Messages

  • Lineage relationship for HANA tables is not shown

    Hi,
    We are using Information Steward version 14.2.1.220 and we ran Metadata integrator for SAP HANA. We are able to see the impact relationship for the tables but not lineage realationship. Some tables are populated from other tables by calling the procedures. But we are not able to see this lineage relationship.
    Can anyone please tell the solution for it?
    Regards,
    Bhagyashri

    Bhagyashri,
    At this time SAP HANA Metadata Integrator does not parse SQL procedure and so it cannot automatically establish relationship among tables which are populated by those procedures. You can create a user defined relationship to capture the table relationships in this scenario.
    Thanks,
    Hemant

  • 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

  • Many to Many Relationship using junction table..

    Hello im testing a many to many relation ship on j2ee and found this issue.
    Creating a relation ship table until now without succes to update the relationship table:
    code fragment as is:
    On application flow my session bean call the following method according with the specification i have no reason to call persist in my writer just on parent Object: Any clue on what is wrong ?
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void saveWriter (Book book , Writer writer){
    try {
    Book atBook = entityManager.merge(book);
    Writer atWriter = entityManager.merge(writer);
    book.getWriters().add(atWriter);
    entityManager.persist(atBook);
    entityManager.flush();
    }catch (Exception ex)
    ex.printStackTrace();
    <entity class="com.octech.biblio.domain.Book" name="book">
    <description></description>
    <table name="books" />
    <attributes>
    <id name="id">
    <generated-value strategy="IDENTITY"/>
    </id>
    <basic fetch="EAGER" name="bookName">
    <column insertable="true" length="128" name="bookname" table="" updatable="true"/>
    </basic>
    <many-to-one name="Library" fetch="LAZY" target-entity="com.octech.biblio.domain.Library">
    <join-table name="library_books">
    <join-column name="books_id"/>
    <inverse-join-column name="library_id"/>
    </join-table>
    <cascade/>
    </many-to-one>
    <many-to-many name="Writers" fetch="LAZY" target-entity="com.octech.biblio.domain.Writer">
    <join-table name="writers_books">
    <join-column name="books_id"/>
    <inverse-join-column name="writer_id"/>
    </join-table>
    <cascade/>
    </many-to-many>
    </attributes>
    </entity>
    <entity class="com.octech.biblio.domain.Writer" name="writer">
    <description></description>
    <table name="writers" />
    <attributes>
    <id name="id">
    <generated-value strategy="IDENTITY"/>
    </id>
    <basic fetch="EAGER" name="writerName">
    <column insertable="true" length="128" name="writer_name" table="" updatable="true"/>
    </basic>
    <many-to-many name="Books" fetch="LAZY" target-entity="com.octech.biblio.domain.Book">
    <join-table name="writers_books">
    <join-column name="writer_id"/>
    <inverse-join-column name="books_id"/>
    </join-table>
    <cascade/>
    </many-to-many>
    </attributes>
    </entity>

    sybrand_b wrote:
    The way you write it yes, but there is one minor detail.
    You can have a 0,1 or many relationship: one employee has zero, one or many phone numbers
    but you can not have the opposite, as it doesn't make sense.
    0, 1 or many phone numbers belong to 1 employee.
    It is customary to use 0,1 or m when the relationship is optional.
    Sybrand Bakker
    Senior Oracle DBAIs this correct now ?
    one to many : one employee has 0,1 or multiple phone numbers
    many to one : 1 or multiple phone numbers to one employee

  • Weight factors in a many-to-many relationship with bridge table

    Hi, I have the same N:N relationship schema of this link:
    http://www.rittmanmead.com/2008/08/28/the-mystery-of-obiee-bridge-tables/
    In my bridge table I have a weight factor for every couple (admission,diagnosis). If I aggregate and query in Answers these columns:
    DIAGNOSIS | ADMISSIONS_COSTS
    every single diagnosis has the sum of the WHOLE Admission_cost it refers to, not its contribute to it (for example 0.30 as weight factor). The result is an ADMISSION_COSTS sum larger than the ADMISSION_COSTS sum in the lowest detail level, because it sums many times the same cost.
    How could I use my weight factor and calculate the right diagnosis contribute to its admission? In BI Admin I tried to build a calculated LogicalColumn based on Physical column, but in the expression builder I can select only the ADMISSION_COST measure physical column, and it doesn't let me pick the weight factor from the bridge table.
    Thanks in advance!

    I'm developing a CS degree project with 2 professors, Matteo Golfarelli and Stefano Rizzi, who have developed the Dimensional Fact Model for data warehouses and wrote many books about it.
    They followed the Kimball theory about N:N and used its bridge table concept, so when I said them that in OBIEE there is this definition they were very happy.
    But they stopped this happiness when I said that bridge tables only connect fact tables to dimension tables, and to create N:N between levels at higher aggregation we should use logical joins as you said in your blog. I need to extract metadata concepts from UDML exportation language, and about N:N I can do it only with bridge table analysis, I can't extract and identify a N:N level relationship from a multiple join schema as in your blog... this is the limit of your solution for our project, only this!
    PS: sorry for my english, I'm italian!
    thanks for the replies!

  • One-to-many Relationships for entities with compound PK

    Hi,all,
    I am wondering how the behavior of a setter method would be for one side of the 1-to-many relations Base on EJB spec 2.x ,if we use the setter method to set a new collection,then the old relations are "clear" before the new relationships are established. which means the old referential integrity are removed from the respective tables in Database .But what if the referential table is with a compoud pk.Here
    is one example:
    Two entitybeans,say A and B , where their underlying tables are Table A and B in the Database.For A the primary key is Pk_1,but the B's primary key is (Pk_1,B1),where B1 is another column in table B. we have a setter method in entitybean A for the relationship of bean B,say setB(Collection collectionOfBs),.My questions is based on EJB spec, is container supposed to perform "clean" job, which dissassociate those old rows in table A with Table B before set the those new relationships when we call the setter to set a new relationships.
    Thanks

    My questions is based on EJB spec, is
    container supposed to perform "clean" job, Yes, I think so. EJB spec says nothing special about compound keys in this case.
    which
    dissassociate those old rows in table A with Table B
    before set the those new relationships when we call
    l the setter to set a new relationships.
    Thanks

  • 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.

  • One-to-many relationship: problem with several tables on the one side...

    Hello
    I'm having problems developing a database for a content management system. Apart from details, I've got one main table, that holds the tree structure of the content ("resources") and several other tables that contain data of a particular datatype ("documents", "images", etc.). Now, there's one-to-many relationship between "resources" table and all the datatype tables - that is, in the "resources" table there's "resource_id" column, being a foreign key referenced to the "id" columns in the datatype tables.
    The problem is that this design is deficient. I can't tell form the "resource_id" column from which datatype table to get the data. It seems to me that one-to-many relationship only works with two tables. If the data on the one side of the relationship is contained in several tables, problems arise.
    Anybody knows a solution? I would be obliged.
    Regards
    Havocado

    Hi;
    A simple way may be create a view on referenced tables:
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL>
    SQL> drop table resources;
    Table dropped
    SQL> create table resources(id number, name varchar2(12));
    Table created
    SQL> insert into resources values(1,'Doc....');
    1 row inserted
    SQL> insert into resources values(2,'Img....');
    1 row inserted
    SQL> drop table documents;
    Table dropped
    SQL> create table documents(id number, resource_id number,type varchar2(12));
    Table created
    SQL> insert into documents values(1,1,'txt');
    1 row inserted
    SQL> drop table images;
    Table dropped
    SQL> create table images(id number, resource_id number,path varchar2(24));
    Table created
    SQL> insert into images values(1,2,'/data01/images/img01.jpg');
    1 row inserted
    SQL> create or replace view vw_resource_ref as
      2    select id, resource_id, type, null as path from documents
      3      union
      4     select id, resource_id, null as type, path from images;
    View created
    SQL> select * from resources r inner join vw_resource_ref rv on r.id = rv.resource_id;
            ID NAME                 ID RESOURCE_ID TYPE         PATH
             1 Doc....               1           1 txt         
             2 Img....               1           2              /data01/images/img01.jpg
    SQL> Regards....

  • Problem with 1-to-many relationship between entity beans

    Hi All!
    I have two tables TMP_GROUP and TMP_EMPLOYEE with following fields:
    TMP_GROUP: ID, CAPTION, COMMENT, STATUS.
    TMP_EMPLOYEE: ID, LOGIN, GROUP_ID.
    For this tables i create two entity beans GROUP and EMPLOYEE respectively.
    The relationship looks like this
    descriptor ejb.xml:
    <ejb-relation>
                <description>description</description>
                <ejb-relation-name>employeesOfGroup</ejb-relation-name>
                <ejb-relationship-role>
                    <ejb-relationship-role-name>com.mypackage.GroupBean</ejb-relationship-role-name>
                    <multiplicity>One</multiplicity>
                    <relationship-role-source>
                        <ejb-name>GroupBean</ejb-name>
                    </relationship-role-source>
                    <cmr-field>
                        <cmr-field-name>employees</cmr-field-name>
                        <cmr-field-type>java.util.Collection</cmr-field-type>
                    </cmr-field>
                </ejb-relationship-role>
                <ejb-relationship-role>
                    <ejb-relationship-role-name>com.mypackage.EmployeeBean</ejb-relationship-role-name>
                    <multiplicity>Many</multiplicity>
                    <relationship-role-source>
                        <ejb-name>EmployeeBean</ejb-name>
                    </relationship-role-source>
                </ejb-relationship-role>
            </ejb-relation>
    descriptor persistent.xml:
    <table-relation>
                   <table-relationship-role
                        key-type="PrimaryKey">
                        <ejb-name>GroupBean</ejb-name>
                        <cmr-field>employees</cmr-field>
                   </table-relationship-role>
                   <table-relationship-role
                        key-type="NoKey">
                        <ejb-name>EmployeeBean</ejb-name>
                        <fk-column>
                             <column-name>GROUP_ID</column-name>
                             <pk-field-name>ejb_pk</pk-field-name>
                        </fk-column>
                   </table-relationship-role>
              </table-relation>
    Now i implement business method:
    public Long addEmployee(String login, long groupId) {
              Long result;
              try {
                   EmployeeLocal employee = employeeHome.create(login);
                   GroupLocal group =
                        groupHome.findByPrimaryKey(new Long(groupId));
                   Collection employees = group.getEmployees();
                   employees.add(employee);
                   result = (Long) employee.getPrimaryKey();
              } catch (CreateException ex) {
                   result = new Long(0);
              } catch (FinderException ex) {
                   result = new Long(0);
              return result;
    When i call this method from web service, the following exception is raised:
    com.sap.engine.services.ejb.exceptions.BaseTransactionRolledbackLocalException: Exception in method com.mypackage.GroupLocalHomeImpl0.findByPrimaryKey(java.lang.Object).
    P.S.
    1) I have transaction attribute set to "Required" for all methods of all beans
    2) I have unique index for each table:
    TMP_GROUP_I1: CAPTION
    TMP_EMPLOYEE_I1: LOGIN (however i think GROUP_ID must be added here too)
    3) I tried many:many relationship with this tables and it works fine
    4) I try another implementation of addEmployee method with
    EmployeeLocal employee = employeeHome.create(login, groupId);
    without using GroupLocal cmr-field and GroupLocalHome findByPrimaryKey method, the result is same error.
    Can somebody help me with this problem?
    Thanks in advance.
    Best regards, Abramov Andrey.

    gimbal2 wrote:
    1: The @JoinColumn on the listOfDepartments collection in Company is wrong. It should be something like this for a bidirectional relationship:
    @OneToMany(mappedBy="company") // company is the matching property name in Department
    private List <Department> listOfDepartment = new ArrayList<Department>();Note that I removed the fetch configuration; onetomany is fetched lazy by design. Saves some clutter eh.
    2: use a Set in stead of a List (hibernate doesn't like lists much in entities and will break when you create slightly more complex entity relations)
    3: don't just slap cascades on collections, especially of type ALL. Do it with care. In the many years I've been using JPA I've only had to cascade deletes in very specific situations, maybe once or twice. I never needed any of the other cascade types, they just invite sloppy code if you ask me. When working with persistence you should apply a little precision.I made all changes as you mentioned but still compID in department table shows null value...

  • Problem with 1:many relationship between entity beans.

    Hi All!
    I have two tables TMP_GROUP and TMP_EMPLOYEE with following fields:
    TMP_GROUP: ID, CAPTION, COMMENT, STATUS.
    TMP_EMPLOYEE: ID, LOGIN, GROUP_ID.
    For this tables i create two entity beans GROUP and EMPLOYEE respectively.
    The relationship looks like this
    descriptor ejb.xml:
    <ejb-relation>
                <description>description</description>
                <ejb-relation-name>employeesOfGroup</ejb-relation-name>
                <ejb-relationship-role>
                    <ejb-relationship-role-name>com.mypackage.GroupBean</ejb-relationship-role-name>
                    <multiplicity>One</multiplicity>
                    <relationship-role-source>
                        <ejb-name>GroupBean</ejb-name>
                    </relationship-role-source>
                    <cmr-field>
                        <cmr-field-name>employees</cmr-field-name>
                        <cmr-field-type>java.util.Collection</cmr-field-type>
                    </cmr-field>
                </ejb-relationship-role>
                <ejb-relationship-role>
                    <ejb-relationship-role-name>com.mypackage.EmployeeBean</ejb-relationship-role-name>
                    <multiplicity>Many</multiplicity>
                    <relationship-role-source>
                        <ejb-name>EmployeeBean</ejb-name>
                    </relationship-role-source>
                </ejb-relationship-role>
            </ejb-relation>
    descriptor persistent.xml:
    <table-relation>
                   <table-relationship-role
                        key-type="PrimaryKey">
                        <ejb-name>GroupBean</ejb-name>
                        <cmr-field>employees</cmr-field>
                   </table-relationship-role>
                   <table-relationship-role
                        key-type="NoKey">
                        <ejb-name>EmployeeBean</ejb-name>
                        <fk-column>
                             <column-name>GROUP_ID</column-name>
                             <pk-field-name>ejb_pk</pk-field-name>
                        </fk-column>
                   </table-relationship-role>
              </table-relation>
    Now i implement business method:
    public Long addEmployee(String login, long groupId) {
              Long result;
              try {
                   EmployeeLocal employee = employeeHome.create(login);
                   GroupLocal group =
                        groupHome.findByPrimaryKey(new Long(groupId));
                   Collection employees = group.getEmployees();
                   employees.add(employee);
                   result = (Long) employee.getPrimaryKey();
              } catch (CreateException ex) {
                   result = new Long(0);
              } catch (FinderException ex) {
                   result = new Long(0);
              return result;
    When i call this method from web service, the following exception is raised:
    com.sap.engine.services.ejb.exceptions.BaseTransactionRolledbackLocalException: Exception in method com.mypackage.GroupLocalHomeImpl0.findByPrimaryKey(java.lang.Object).
    P.S.
    1) I have transaction attribute set to "Required" for all methods of all beans
    2) I have unique index for each table:
    TMP_GROUP_I1: CAPTION
    TMP_EMPLOYEE_I1: LOGIN (however i think GROUP_ID must be added here too)
    3) I tried many:many relationship with this tables and it works fine
    4) I try another implementation of addEmployee method with
    EmployeeLocal employee = employeeHome.create(login, groupId);
    without using GroupLocal cmr-field and GroupLocalHome findByPrimaryKey method, the result is same error.
    Can somebody help me with this problem?
    Thanks in advance.
    Best regards, Abramov Andrey.

    I have posted excerpts from my orion-ejb-jar.xml file in this posting: Problem mapping a 1:M relationship between two entity EJBs w/ a compound PK
    Sorry for the duplicate postings, but I was getting errors on the submission.
    April

  • JPA, how to write a service to persist objects in a 1-to-many relationship

    i am using JPA for data persistence. i have two objects that are involved in a one-to-many relationship. for example, i have an object, Company, and Company can have one or more, Employee. i then define a service called, CompanyDao, which has the usual create-read-update-delete (CRUD) operations. my problem is that when i instantiate a new Company with new Employees and call CompanyDao.create(Company), i keep getting an exception.
    Cannot add or update a child row: a foreign key constraint fails (`demo`.`employee`, CONSTRAINT `employee_ibfk_1` FOREIGN KEY (`companyId`) REFERENCES `company` (`id`))
    i have an intuition on why this is happening. when i call CompanyDao.create(Company), the newly instantiated Company doesn't yet have an id (its unique identifier). that is why when it tries to insert the Employees of Company, i get this problem. but, my question is, shouldn't JPA take care of all of this for me? shouldn't it know that it is creating a new Company, will have to insert it, will have to retrieve the unique id (generated) and then populate the employee table with this id?
    i was thinking about this problem, and i thought maybe i could insert the company first and then the employees later. however, the problem is, once i insert the company, how do i get its unique id? i cannot query for it any other way (i.e. by name) that will return a unique result.
    if anyone knows of a good, comprehensive tutorial on how to write a service demonstration CRUD operations on objects with one-to-many relationship, please let me know.

    Hi,
    Could you please send CompanyDao.create(Company) code so that we can dig in to problem.
    Regards
    Murali N

  • Many to many relationship in 11g

    How to define a Many-to-Many relationship with OBI 11g like bridge table in 10g? is there the way to design it?

    Hi ,
    Many to Many relationship for which bridge table was used is now disabled in 11g. This option is being replaced by the option of 'Look up table'.  There is offcourse way to define it. You need to create back end intermediate table which can interact between 2 dims or 2 facts. Best example you can find in the below link given of oracle.
    Working with Logical Tables, Joins, and Columns
    In this scenario , suppose we have 2 dim tables like Jobs, employees.
    1) 1 employees can fulfill multiple job
    2) 1 Job can be fulfilled by multiple employees.
    3) Intermediate table we could create here is assignment which is having both the information. In this employee id will be unique as primary key however for assignment column primary key is its composite key so that for 1 employee lot of rows of assignments could be assigned.
    Thanks,
    Amol
    (Please mark this answer, if you find helpful)

  • Newbie: one to many relationship SQL error

    Greetings all-
    This is probably a slam dunk for you JDO experts. I'm a JDO newbie, working
    with an existing schema in MySQL. I have a one to many relationship between
    two tables:
    Table "company":
    Fields:
    company_id: int(11) -- primary key
    name : varchar(64)
    division : varchar(64)
    Table "company_products"
    Fields:
    company_id: int(11) -- foreign key to table company
    product_name: varchar(64)
    product_description: varchar(64)
    So, I created the corresponding classes:
    public class Company {
    private int companyID;
    private String company_name;
    private String division;
    // Array of CompanyProduct
    private ArrayList companyProducts;
    // .. methods omitted
    public class CompanyProduct {
    private int companyID;
    private String productName;
    private String productDesc;
    // Methods omitted
    Then I created the "package.jdo" file:
    <?xml version="1.0"?>
    <jdo>
    <package name="com.packexpo.db">
    <class name="Company">
    <extension vendor-name="tt" key="table" value="company"/>
    <extension vendor-name="tt" key="pk-column" value="company_id"/>
    <extension vendor-name="tt" key="lock-column" value="none"/>
    <extension vendor-name="tt" key="class-column" value="none"/>
    <field name="companyID">
    <extension vendor-name="tt" key="data-column" value="company_id"/>
    </field>
    <field name="name">
    <extension vendor-name="tt" key="data-column" value="name"/>
    <extension vendor-name="tt" key="column-length" value="64"/>
    </field>
    <field name="division">
    <extension vendor-name="tt" key="data-column" value="division"/>
    <extension vendor-name="tt" key="column-length" value="64"/>
    </field>
    <field name="companyProducts">
    <collection element-type="com.packexpo.db.CompanyProduct"/>
    <extension vendor-name="tt" key="inverse" value="companyID"/>
    </field>
    </class>
    <class name="CompanyProduct">
    <extension vendor-name="tt" key="table" value="company_product"/>
    <extension vendor-name="tt" key="pk-column" value="company_id"/>
    <extension vendor-name="tt" key="lock-column" value="none"/>
    <extension vendor-name="tt" key="class-column" value="none"/>
    <field name="companyID">
    <extension vendor-name="tt" key="data-column" value="company_id"/>
    </field>
    <field name="productName">
    <extension vendor-name="tt" key="data-column" value="product_name"/>
    <extension vendor-name="tt" key="column-length" value="64"/>
    </field>
    <field name="productDesc">
    <extension vendor-name="tt" key="data-column"
    value="product_description"/>
    <extension vendor-name="tt" key="column-length" value="64"/>
    </field>
    </class>
    </package>
    </jdo>
    Enhancement works fine. I successfully query and retrive Company objects
    from the database, but as soon as I try to get the list of CompanyProducts,
    I get an SQL Error:
    javax.jdo.JDODataStoreException: [SQL=SELECT company.COMPANYPRODUCTSX FROM
    company WHERE company.company_id = 82061]
    E0610 Error in executeQuery()
    E0606 executeQuery() error --
    E0701 Error in getResult().
    E0708 Command results in error - 1054 Unknown column
    'company.COMPANYPRODUCTSX' in 'field list'
    NestedThrowables:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper: [SQL=SELECT
    company.COMPANYPRODUCTSX FROM company WHERE company.company_id = 82061]
    E0610 Error in executeQuery()
    E0606 executeQuery() error --
    E0701 Error in getResult().
    E0708 Command results in error - 1054 Unknown column
    'company.COMPANYPRODUCTSX' in 'field list'
    I know i have probably set up the package.jdo file incorrectly, but I'm at a
    loss for what I did wrong.
    Any suggestions?
    Thanks!
    -Mike

    Hi,
    915766 wrote:
    I need to write sql for below requirement:
    table structure is
    serial no LPN
    1 4
    2 4
    3 6
    4 6
    5 6
    6 3
    7 3
    8 3
    9 1
    I have to pick distinct 'LPN' like below:That sounds like a job for "GROUP BY lpn".
    (any serial no can be picked for the distinct LPN)It looks like you're displaying the lowest serial_no for each lpn. That's easy to do, using the aggregate MIN function.
    results needs to be as below:
    serial no LPN
    1 4
    3 6
    6 3
    9 1
    Please suggest with sql.Here's one way:
    SELECT    MIN (serial_no)   AS serial_no
    ,         lpn
    FROM      table_x
    GROUP BY  lpn
    ORDER BY  lpn     -- if wanted
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • Using data from one-to-many relationship

    Hi,
    i have an one-to-many relationship among two tables similar to the structure as in the below reference:-
    [One-to-many-reference|http://docs.oracle.com/cd/E23507_01/Platform.20073/RepositoryGuide/html/s1204repositoryexamplefonetomanymappi01.html]
    taking this as an example, i have the city's name with me. using this data in the addr_tbl in the 'address' item-descriptor, i need to get the value of the 'name' in the usr_tbl in the 'user' item descriptor. i will have the list of 'city' with me which i have to iterate and display the corresponding 'name'.
    will i be able to perform this in the jsp itself or does it have to be done in java? a sample code snippet or reference for doing this will be of much help.
    thank you.

    Thanks a lot, Sheik.
    if i have to do the reverse, ie for the 'name' in the usr_tbl of user item-descriptor i have to fetch the 'city' values in the addr_tbl, will it suffice if i do the following?
    <dsp:droplet name="/atg/dynamo/droplet/RQLQueryForEach">
    <dsp:param name="queryRQL" value="name=\"sirius\""/>
    <dsp:param name="repository"
    value="/com/MyRepository"/>
    <dsp:param name="itemDescriptor" value="user"/>
    <dsp:oparam name="output">
    <dsp:valueof param="element.address.city"/>
    </dsp:oparam>
    </dsp:droplet>

  • UML: From ER to UML to JAVA : many-to-many relationship implementation.

    Hi All,
    Basically, I just want to know if we have point 1 (ER), then is point 2 (UML) and point 3 (JAVA) correct? 1M Thanks.
    1. ER-wise, we have a many-to-many relationships between 2 tables A and B. Its implementation is:
    Table_A
    ID PK
    Table_B
    ID PK
    Table_AB
    ID FK REFERENCED TO TABLE_A
    ID FK REFERENCED TO TABLE_B
    DateCreated (a third column)
    2. UML-wise, we would have 2 classes Table_A, Table_B and an association class Table_AB. Is this correct? OR is there any other possibility depending on the nature of these classes Table_A, Table_B?
    3. Java-wise, we would have 3 below classes. Is this correct?
    OR is there any other possibility depending on the nature of these classes Table_A, Table_B?
    public class Table_A
         private int ID;
    public class Table_B
         private int ID;
    public class Table_AB
         private DateTime DateCreated;
         private Table_A a;
         private Table_B b;

    Hi MOD,
    1. Actually, the original question:
    Table_A<---many-to-many--->Table_B
    can be break down to
    Table_A<---1-to-many--->Table_AB and Table_AB<---many-to-1--->Table_B
    where Table_AB is an association class with an attribute.
    2. As for the Implementation, I have a reviewed version based upon point 1. for the point 3 of original post.
    import java.util.*;
    public class Table_A
         private int ID;
         List abList = new ArrayList();  // This is Table_A<---1-to-many--->Table_AB
         public Table_A(int ID)
              this.ID=ID;
         public void addTable_AB(Table_AB ab)
              abList.add(ab);
              ab.setTable_A(this);
         //...other methods
    public class Table_B
         private int ID;
         List abList = new ArrayList();  // This is Table_B<---1-to-many--->Table_AB
         public Table_B(int ID)
              this.ID=ID;
         public void addTable_AB(Table_AB ab)
              abList.add(ab);
              ab.setTable_B(this);
         //...other methods     
    public class Table_AB
         private Date DateCreated;     
         private Table_A a;     // This is Table_AB<---many-to-1--->Table_A
         private Table_B b;     // This is Table_AB<---many-to-1--->Table_B
         public Table_AB(Date DateCreated)
              this.DateCreated=DateCreated;
         public void setTable_A(Table_A a)
              this.a= a;
         public void setTable_B(Table_B b)
              this.b= b;
         //...other methods     
    }

Maybe you are looking for