One-to-one relation

I don't have much experience with database programming.
If someone could please explain to me why in practice is not recommended to use 1:1 relation?
I was searching for answer on forum but i couldn't found it.
Thanks

" is not recommended to use 1:1 relation"
Where have you read this....????
If this type of relation is driven by the business rules then you should apply this..... such as a particular student does have a specific copy of a specific book.
On the contrary the relations x:y (many to many) should be divided to an intermediate entity.... and not used as x->y.
Greetings...
Sim

Similar Messages

  • Table design one-to-one relation

    For a big table such as this: PROJECT_TABLE which contains 75 columns. But, only 40 columns are frequently searched against, i.e., the user enter some criteria on a web page, then start the search. The rest 35 columns are used on as-needed basis, i.e., only if the user want to view a specific record (in the returned search result). I am afraid that as the records grow, someday, the search will slow down (due to the large number of columns in the table).
    So, I plant to break the PROJECT_TABLE into two separate tables PROJECT_PARENT (project_id) and PROJECT_CHILD (project_id) and reference them by one-to-one relation. By this way, when the user conducts the search, it will be done against the PROJECT_PARENT table; while when user wants to view a specific record, it will then retrieve the data by using one-to-one join of the two tables.
    Like to know if it really help by breaking into two tables. What is your comment?
    Thanks
    Scott

    scottjhn wrote:
    For a big table such as this: PROJECT_TABLE which contains 75 columns. But, only 40 columns are frequently searched against, i.e., the user enter some criteria on a we page, then start the search. The rest 35 columns are used on as-needed basis, i.e., only if the user want to view a specific record (in the returned search result). I am afraid that as the records grow, someday, the search will slow down (due to the large number of columns in the table).
    So, I plant to break the PROJECT_TABLE into two separate tables PROJECT_PARENT (project_id) and PROJECT_CHILD (project_id) and reference them by one-to-one relation. By this way, when the user conducts the search, it will be done against the PROJECT_PARENT table; while when user wants to view a specific record, it will then retrieve the data by using one-to-one join of the two tables.
    Like to know if it really help by breaking into two tables. What is your comment?if you proceed, performance will be worse than if you do nothing.
    Do you suffer from Compulsive Tuning Disorder?
    Are you bored & looking for some activity to keep you busy?

  • Is it possible to have 2 mail programmes on my macbook pro? one for business related emails and one personal. I dont want all the emails in one mail programme!

    Is it possible to have 2 mail programmes on my macbook pro? one for business related emails and one personal. I dont want all the emails in one mail programme. At the moment i have 2 personal email address being sent to my mail but because of receiving huge numbers of work emails it would be good to keep them seperate, what is the best way of doing this?

    if i use the one mail programme can it separate the incoming mail from the different email accounts into 2 folders without me having to do it manually?
    Yes, you can.  Nearly all email software can do this.  It involves creating two folders and a Rule for each folder.
    Maybe call one folder Personal Mail, the other Work Mail (Apple Mail calls folders Mailboxes).  One Rule would route all mail from your personal email account into the Personal Mail folder; the other Rule would route all mail from your work email account into the Work Mail folder.  It's actually easy to do, all you have to do is click a few things and the rule is set up.  Once the Rule is written you can also apply it to existing messages already downloaded to your Mac.
    In Apple Mail, Rules are under Preferences > Rules.  Follow the prompts to create a rule like this:
    If = Any
    Account = my Personal account (select the name of your personal email account)
    Perform the following actions: Move Message to Mailbox = my Personal Mail (select the name of your Personal Mail folder (aka mailbox))
    This rule says,  "take any message that comes in from my Personal Account and move it to my Personal Mail mailbox (folder)"
    Create a similar rule for your Work email.

  • Problem with one to one unidirectional relation

    Hi,
    I have one problem with one to one relation ship. While i am trying to persist the objects it is showing that "parent key not found" exception. Is there any problem with my class configuration ?..
    Table description:having two tables with same composite primary key
    ECommSchema table has one composite primay key and the ECommSchemaDet table also has the same composite primary key. In second table (ECommSchemaDet) composite primary key fields are refering(foreign key relation ship) from the first table.
    My entity classes are....
    @Entity(name = "E_COMM_SCHEMA")
    @Table(name = "E_COMM_SCHEMA", uniqueConstraints = {})
    public class ECommSchema extends ParentEntity implements java.io.Serializable{
    // Fields
    private ECommSchemaDet eCommSchemaDet;
    // Constructors
    /** default constructor */
    public ECommSchema(){
    /** minimal constructor */
    public ECommSchema(ECommSchemaId id, String descBriefEng, Date effectiveFrom, Currencies currencies){
    this.id = id;
    this.descBriefEng = descBriefEng;
    this.effectiveFrom = effectiveFrom;
    this.currencies = currencies;
    /** full constructor */
    @OneToOne(cascade = { CascadeType.ALL })
    @PrimaryKeyJoinColumns({ @PrimaryKeyJoinColumn(name = "COMP_CODE", referencedColumnName = "COMP_CODE"),
    @PrimaryKeyJoinColumn(name = "CODE", referencedColumnName = "SCHEMA_CODE") })
    public ECommSchemaDet getECommSchemaDet(){
    return eCommSchemaDet;
    public void setECommSchemaDet(ECommSchemaDet commSchemaDet){
    eCommSchemaDet = commSchemaDet;
    @SuppressWarnings("serial")
    @Entity(name = "E_COMM_SCHEMA_DET")
    @Table(name = "E_COMM_SCHEMA_DET", uniqueConstraints = {})
    public class ECommSchemaDet implements java.io.Serializable{
    private ECommSchema ECommSchema;
    // Constructors
    /** default constructor */
    public ECommSchemaDet(){
    /** minimal constructor */
    public ECommSchemaDet(ECommSchemaDetId id, ECommSchema ECommSchema, String calcBase, String multiTier, String distMethod,
    Double brokerRebate, Double ticketCharge){
    this.id = id;
    this.ECommSchema = ECommSchema;
    this.calcBase = calcBase;
    this.multiTier = multiTier;
    this.distMethod = distMethod;
    this.brokerRebate = brokerRebate;
    this.ticketCharge = ticketCharge;
    /** full constructor */
    public ECommSchemaDet(ECommSchemaDetId id, ECommSchema ECommSchema, String calcBase, String multiTier, String distMethod,
    Double brokerRebate, Double ticketCharge, String distMethodClient){
    this.id = id;
    this.ECommSchema = ECommSchema;
    this.calcBase = calcBase;
    this.multiTier = multiTier;
    this.distMethod = distMethod;
    this.brokerRebate = brokerRebate;
    this.ticketCharge = ticketCharge;
    this.distMethodClient = distMethodClient;
    // Property accessors
    @OneToOne(cascade = { CascadeType.REFRESH }, fetch = FetchType.EAGER, mappedBy = "eCommSchemaDet")
    public ECommSchema getECommSchema(){
    return this.ECommSchema;
    public void setECommSchema(ECommSchema ECommSchema){
    this.ECommSchema = ECommSchema;
    Error message is
    Local Exception Stack:
    Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-02291: integrity constraint (ETRADE_4BM.FK_ECOMM_SCH_DET) violated - parent key not found
    Error Code: 2291
    Call: INSERT INTO E_COMM_SCHEMA_DET (DIST_METHOD, BROKER_REBATE, CALC_BASE, TICKET_CHARGE, DIST_METHOD_CLIENT, MULTI_TIER, SCHEMA_CODE, COMP_CODE) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
         bind => [T, 23.0, A, 23.0, T, N, 8, 1]
    Query: InsertObjectQuery(com.path.tradeManager.entities.ECommSchemaDet@44fbf5)
         at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:311)
         at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:654)
         at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:703)
         at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:492)
         at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:452)
         at oracle.toplink.essentials.internal.sessions.AbstractSession.executeCall(AbstractSession.java:690)
         at oracle.toplink.essentials.internal.sessions.IsolatedClientSession.executeCall(IsolatedClientSession.java:150)
         at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
         at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:214)
         at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.insertObject(DatasourceCallQueryMechanism.java:346)
         at oracle.toplink.essentials.internal.queryframework.StatementQueryMechanism.insertObject(StatementQueryMechanism.java:191)
         at oracle.toplink.essentials.internal.queryframework.StatementQueryMechanism.insertObject(StatementQueryMechanism.java:205)
         at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.insertObjectForWrite(DatabaseQueryMechanism.java:564)
         at oracle.toplink.essentials.queryframework.InsertObjectQuery.executeCommit(InsertObjectQuery.java:89)
         at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.performUserDefinedWrite(DatabaseQueryMechanism.java:750)
         at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.performUserDefinedInsert(DatabaseQueryMechanism.java:714)
         at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.insertObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:602)
         at oracle.toplink.essentials.queryframework.WriteObjectQuery.executeCommitWithChangeSet(WriteObjectQuery.java:162)
         at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:390)
         at oracle.toplink.essentials.queryframework.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:109)
         at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:628)
         at oracle.toplink.essentials.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:555)
         at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:138)
         at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:110)
         at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2233)
         at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:952)
         at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:909)
         at oracle.toplink.essentials.internal.sessions.CommitManager.commitNewObjectsForClassWithChangeSet(CommitManager.java:269)
         at oracle.toplink.essentials.internal.sessions.CommitManager.commitAllObjectsForClassWithChangeSet(CommitManager.java:246)
         at oracle.toplink.essentials.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:202)
         at oracle.toplink.essentials.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:2657)
         at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1044)
         at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:403)
         at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithPreBuiltChangeSet(UnitOfWorkImpl.java:1160)
         at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.writeChanges(RepeatableWriteUnitOfWork.java:276)
         at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.flush(EntityManagerImpl.java:350)
         at com.sun.enterprise.util.EntityManagerWrapper.flush(EntityManagerWrapper.java:626)
         at com.path.tradeManager.dao.ECommSchemaDaoBean.save(ECommSchemaDaoBean.java:86)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
         at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
         at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
         at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
         at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:203)
         at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:117)
         at $Proxy133.save(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:233)
         at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:152)
         at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:225)
         at com.path.tradeManager.daoInterface.__ECommSchemaDaoInterface_Remote_DynamicStub.save(com/path/tradeManager/daoInterface/__ECommSchemaDaoInterface_Remote_DynamicStub.java)
         at com.path.tradeManager.daoInterface._ECommSchemaDaoInterface_Wrapper.save(com/path/tradeManager/daoInterface/_ECommSchemaDaoInterface_Wrapper.java)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.path.tradeManager.tunnelGate.RequestHandler.callMethodByReflection(RequestHandler.java:181)
         at com.path.tradeManager.tunnelGate.RequestHandler.handle(RequestHandler.java:150)
         at com.path.tradeManager.tunnelGate.TunnelServlet.doPost(TunnelServlet.java:37)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
         at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:290)
         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
         at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
         at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
         at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
    Caused by: java.sql.SQLException: ORA-02291: integrity constraint (ETRADE_4BM.FK_ECOMM_SCH_DET) violated - parent key not found
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:304)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:271)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:622)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:180)
         at oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPreparedStatement.java:542)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1027)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2887)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:2959)
         at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:647)
         ... 92 more
    Jul 8, 2008 4:17:07 PM com.sun.enterprise.server.logging.SystemOutandErrHandler$LoggingByteArrayOutputStream flush
    INFO: FATAL[08-07-08 16:17:07][com.path.tradeManager.dao.ECommSchemaDaoBean->save][javax.persistence.PersistenceException: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-02291: integrity constraint (ETRADE_4BM.FK_ECOMM_SCH_DET) violated - parent key not found
    Thanks in advance
    Anish

    Hello,
    I'm not sure what the FK_ECOMM_SCH_DET constraint refers to, but I assume it is to the only OneToOne reference defined. Based on the mappings shown, you have told TopLink that ECommSchema has a 1:1 to ECommSchemaDet, so that ECommSchemaDet has to be inserted first. My guess is your constraint is the oposite, requiring that ECommSchema be inserted before ECommSchemaDet. If so, just change the by directional 1:1 so that ECommSchema->ECommSchemaDet is mapped by the ECommSchemaDet->ECommSchema relationship (ie switch things).
    Best Regards,
    Chris

  • How to get data from three tables (A,B,C) having one to many relation between A and B .and having one to many reation between b and c

    i have  three tables A,B,C.  there is one to many relation between A and B. and one to many relation existed between table b and c . how will get data from these three tables

    check if this helps:
    select * --you can always frame your column set
    from tableA a
    left join tableB b on a.aid=b.aid
    left join tableC c on c.bid=b.bid
    This is just a general query. However, we can help you a lot more, if you can post the DDL + sample data and required output.
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • Get One to One relation information from SMO

    Hello I have 2 tables.
    Business & categories. Both are connected using one to one relation.
    In business table I created ForeignKey relation to Category & then I made CategoryId column of Business Table Unique Key in index.
    In this way I create One to one relation between them.
    So from Business I can get Category by using Following SMO Code:
    foreach (Microsoft.SqlServer.Management.Smo.Table table in lstTableName)
    var ReferenceData=table.ForeignKeys;
    It is fine. But Now from category Table I also want to see Business Object. I know that I can travers EnumForeignKeys() But in that I can get its SetCollection data.
    But I want o know the information regarding One to One relationship . that meance I want to see cardinality information from SMO.
    Is there any way that I can have that information using SMO?
    If ismo is not possible then some kind of SQL query is also ok for me.
    Thanking you in advance..
    Regards
    Vipul Langalia

    Hi,
    IMO this does not seem possible using SMO or any other method as well.
    You cannot create a 1..1 relationship directly in SQL Server.
    To implement such a relationship we need to create a FOREIGN KEY and then create a UNIQUE constraint on the foreign key column, this again does not guarantee 1..1 relationship but 0..1 relationship.
    So what you can do is check if UNIQUE constraint is defined on the foreign key column in the referencing table.
    - Vishal
    SqlAndMe.com

  • One to one relation webapplication and portal?

    Going through the documentation and the newsgroups for WLCS 3.5 and
    Personalization Server 3.5 I can't seem to find out wether or not
    there is a one to one relation between a webapplication and a portal.
    I mean, can I have more than one portal in a webapplication? The
    folder structure in the webapplication seems to indicate so:
    exampleportal/portals suggests that multiple portals can be found in
    this webapplication, with the repository as a folder shared by all
    portals.
    And if this is the case, where do I configure which user goes to what
    portal within that one webapplication?
    Anybody has any suggestion or pointers to relevant documentation (not
    being the bea edocs site...)?
    Regards
    EJ

    Thanks for your response!
    I have different problem.
    I have two submit buttons. First is to save the data into DB. Second is to add an Answer object to arraylist (Answers) and this answer object filled in the same form. When I click the second button, I don't see the arraylist growing. But it overwrites. I hope you are understanding my question.
    Please help me

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

  • How to create one to one relation in database diagram

    Hi!
    I'd like to create a database diagram in JDeveloper 10g. Is there any possibility to create a one-to-one relation between two tables?
    Thanks in advance,
    Jim

    This seems to be the same problem that I am having. I was trying to create a database diagram with tables imported from the database. I have two tables having a 1 --> 0..1 relationship. However when I pulled these tables on to a database diagram , it displayed as a 1 --> * relationship. I also realized that JDeveloper does not allow you to change the cardinality in a database diagram.
    As a workaround, I created a class diagram and named the classes the same as the database tables. Then I used UML connectors to show the relationships with the correct cardinality. Since I did not need to show the column names on the diagram, it was sufficient for my purpose. I hope this bug is fixed soon, otherwise I will have to use some other tool to create database diagrams.

  • Query to achieve exclusively one-to-one relation data

    Hi,
    I am looking for a query to find rows with one-to-one relation ship.
    To make it simple here is the sample code.
    CREATE TABLE my_storegroup_gbcust
      store_grp_id        NUMBER(6)                 NOT NULL,
      group_buy_cust_num  NUMBER(5)                 NOT NULL
    INSERT INTO my_storegroup_gbcust (store_grp_id, group_buy_cust_num ) VALUES (1002, 70001);
    INSERT INTO my_storegroup_gbcust (store_grp_id, group_buy_cust_num ) VALUES (1003, 70001);
    INSERT INTO my_storegroup_gbcust (store_grp_id, group_buy_cust_num ) VALUES (1004, 70001);
    INSERT INTO my_storegroup_gbcust (store_grp_id, group_buy_cust_num ) VALUES (1005, 70001);
    INSERT INTO my_storegroup_gbcust (store_grp_id, group_buy_cust_num ) VALUES (1006, 70001);
    INSERT INTO my_storegroup_gbcust (store_grp_id, group_buy_cust_num ) VALUES (2001, 65000);
    INSERT INTO my_storegroup_gbcust (store_grp_id, group_buy_cust_num ) VALUES (28001, 21800);
    INSERT INTO my_storegroup_gbcust (store_grp_id, group_buy_cust_num ) VALUES (35001, 27010);
    INSERT INTO my_storegroup_gbcust (store_grp_id, group_buy_cust_num ) VALUES (35001, 37927);
    select * from MY_STOREGROUP_GBCUST
    STORE_GRP_ID     GROUP_BUY_CUST_NUM
    1002               70001
    1003               70001
    1004               70001
    1005               70001
    1006               70001
    2001               65000
    28001               21800
    35001               27010
    35001               37927The data in the table describes 3 types of relations.
    Many-to-One => Many store groups to one group buy => Example : 1002,1003,1004,1005,1006 mapped to 7001
    One-to-One => One store group to one group buy only => Example : 2001 mapped to 65000 ; 28001 mapped to 21800
    One-to-Many => One store group to many group buy => Example: 35001 mapped to 27010,37927
    Now I am able to achieve through query One-to-Many and Many-to-One by as below :
    select group_buy_cust_num,count(*) from MY_STOREGROUP_GBCUST group by group_buy_cust_num having count(*) > 1
    select store_grp_id,count(*) from MY_STOREGROUP_GBCUST group by store_grp_id having count(*) > 1    But how do I get One-to-One exclusively.
    Thanks,
    Raj.

    This is what I get by changing > to = sign.
    select group_buy_cust_num,count(*) from MY_STOREGROUP_GBCUST group by group_buy_cust_num having count(*) = 1
    GROUP_BUY_CUST_NUM     COUNT(*)
    21800               1
    27010               1
    65000               1
    37927               1
    select store_grp_id,count(*) from MY_STOREGROUP_GBCUST group by store_grp_id having count(*) = 1
    STORE_GRP_ID     COUNT(*)
    28001               1
    1005               1
    2001               1
    1003               1
    1002               1
    1004               1
    1006               1But I need just this
    STORE_GRP_ID     COUNT(*)
    2001               1
    28001               1

  • JPA: Issue with loading One To Many relation

    Hi All,
    I have a One to Many relation mapped as below
    @Entity
    @Table(name="ACCOUNT_TABLE")
    public class UserAccount {
         // Attributes
         @Id
         @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="USER_SEQ")
         @SequenceGenerator(name="USER_SEQ", sequenceName="USERS_SEQ",allocationSize=1)
         @Column(name="CLIENT_ID")
         private Long clientId;
         @Column(name="USER_ID")
         private String userId;
         @OneToMany(fetch=FetchType.LAZY, mappedBy="userAccount")
         @JoinColumn(name="USER_ID", referencedColumnName="USER_ID", insertable=false, updatable=false)
         private List<UserRole> assignedRoles;
    @Entity
    @Table(name = "ROLE_TABLE")
    public class UserRole extends BaseEntity implements Serializable {
         private static final long serialVersionUID = -1651953276532642312L;
         @Id
         @Column(name = "USER_ID", length = 30, nullable=false, insertable=false, updatable=false)
         private String userId;
         @Column(name = "BUSINESS_CODE", length = 10, nullable=false, insertable=false, updatable=false)
         private String businessCode;
         @Column(name = "ROLE_NAME", length = 30, nullable=false, insertable=false, updatable=false)
         private String roleName;
         @ManyToOne()
         @JoinColumn(name="USER_ID", referencedColumnName="USER_ID", insertable=false, updatable=false)
         private UserAccount userAccount;
    As you may have noticed, the tables are not joined on the Primary key of parent. This is legacy schema and I have to work with it.
    Account and Role are joined by the USER_ID column. This I specified by providing JoinColumn.
    Then I have a DAO to retrieve the relation based on user id.
    public class UserAccountDAOJPAImpl UserAccountDAO{
         private static final String USER_ACCOUNT_BY_USERID = "select distinct ua " +
         "from UserAccount ua " +
         "left outer join fetch ua.assignedRoles ar " +
         "where ua.userId = ?1 ";
         public UserAccount findByUserName(String userName){          
              UserAccount userAccount=null;
              List<UserAccount> userAccounts =null;
         Query query = this.entityManager.createQuery(USER_ACCOUNT_BY_USERID);
         query.setParameter(1, userName.toUpperCase());
         userAccounts = query.getResultList();
         if(!userAccounts.isEmpty()) {
              userAccount=userAccounts.get(0);
              return userAccount;
    When I test this code ( for the user Id I used in test there are 11 roles )
    The SQL generated is correct, when I run the SQL in PL/SQL Developer, it returns the results as expected.
    But the DAO method above returns one UserAccount object with List of 11 UserRole objects as expected. But all of these 11 UserRole objects are same, where as the query returns 11 different roles.
    I couldn't figure out what I was doing wrong.
    Any help is appreciated.
    thanks,
    Raghavan

    @OneToMany(fetch=FetchType.LAZY, mappedBy="userAccount")
    @JoinColumn(name="USER_ID", referencedColumnName="USER_ID", insertable=false, updatable=false)
    private List<UserRole> assignedRoles;
    }What do you get when you remove this @JoinColumn annotation? It shouldn't be necessary. (user_id seems a little suspect as the join column name by the way, I would have expected role_id here...)

  • Primary one-to-many relation

    What is the best practice to identify the primary entity in a one-to-many relation?
    Lets asume the following:
    I have persons. (Table: PERSON, Primary Key: PERSON_ID)
    I have contact points (Table: CONTACT_POINTS, Foreign Key to PERSON_ID)
    In the E-Business Suite we have a field PRIMARY_FLAG on the CONTACT_POINTS table. This is either Y or N. Now it is upon the application, to verify that only one primary contact point is set. But there is no check in the database. You can have 2 lines, with primary_flag = 'Y'.
    This would make it heavy to do a simple select as:
    SELECT p.first_name, p.last_name, cp.phone_number FROM PERSON p, CONTACT_POINTS cp WHERE cp.PERSON_ID(+) = p.PERSON_ID AND cp.PRIMARY_FLAG(+) = 'Y'
    Because if you have, by mistake, 2 lines with PRIMARY_FLAG = 'Y', you would get 2 result lines in the query above, which is not wanted.
    A second way would be to have the PRIMARY_FLAG field is filled either with Y or NULL. In addition I can set a unique constrain over PERSON_ID and PRIMARY_FLAG and the database will block every try to add a second Y for one person. In that way I can be sure that I either have a primary contact point or I do not have one. So the query will result the same number of lines as there are in the PERSON table. BUT: whenever I go that way, I have to verify my application logic, that every change on the primary flag must set the old primary entry off and then insert or update the new primary entry.
    Which one is the best way, in practice? Are there other solutions? What are advantages ?
    Best Regards
    Alexander

    You can create unique function based index on your CONTACT_POINTS table as follows:
    (person_id, case when primary_flag = 'Y' then primary_flag else null end)
    So as soon as you'll insert another row with Y, you'll get error, but with other values like N, all will be OK.
    And yes - I think it is worth to check data integrity in DB :)
    Gints Plivna
    http://www.gplivna.eu

  • TopLink11 Tutorial problems with one-to-many relation

    Hi,
    I installed TopLink 11 and the related tutorial to work in a simple Eclipse project.
    Everthing works fine except for the storing of the one-to-many relation in the database.
    The tutorial works with employee, address and phone tables/classes. Plain Objects can be stored and one-to-one relations too. However when trying to store a one-to-many relation not the key of the related object (which is at that tome well known) but the object is tried to be entered
    in the Logfile I find:
    [TopLink Fine]: 2008.01.10 10:27:28.748--DatabaseSessionImpl(12916846)--Connection(9550256)--Thread(Thread[main,5,main])--INSERT INTO EMPLOYEE (EMP_ID, L_NAME, F_NAME, ADDR_ID, VERSION) VALUES (?, ?, ?, ?, ?)
         bind => [1501, Pascal, Blaise, 2252, 1]
    [TopLink Finer]: 2008.01.10 10:27:28.748--DatabaseSessionImpl(12916846)--Connection(9550256)--Thread(Thread[main,5,main])--commit transaction
    [TopLink Finer]: 2008.01.10 10:27:28.748--UnitOfWork(14858725)--Thread(Thread[main,5,main])--end unit of work commit
    [TopLink Finer]: 2008.01.10 10:27:28.748--UnitOfWork(14858725)--Thread(Thread[main,5,main])--release unit of work
    [TopLink Finer]: 2008.01.10 10:27:28.748--UnitOfWork(14858725)--Thread(Thread[main,5,main])--release unit of work
    [TopLink Finest]: 2008.01.10 10:27:28.748--UnitOfWork(18511661)--Thread(Thread[main,5,main])--Register the object Employee: Blaise Pascal
    [TopLink Finest]: 2008.01.10 10:27:28.748--UnitOfWork(18511661)--Thread(Thread[main,5,main])--Execute query DoesExistQuery()
    [TopLink Finer]: 2008.01.10 10:28:58.370--UnitOfWork(18511661)--Thread(Thread[main,5,main])--begin unit of work commit
    [TopLink Finer]: 2008.01.10 10:28:58.370--DatabaseSessionImpl(12916846)--Connection(9550256)--Thread(Thread[main,5,main])--begin transaction
    [TopLink Finest]: 2008.01.10 10:28:58.370--UnitOfWork(18511661)--Thread(Thread[main,5,main])--Execute query UpdateObjectQuery(Employee: Blaise Pascal)
    [TopLink Finest]: 2008.01.10 10:28:58.386--UnitOfWork(18511661)--Thread(Thread[main,5,main])--Execute query InsertObjectQuery(PhoneNumber[desk]: (603) 123-4567)
    [TopLink Fine]: 2008.01.10 10:28:58.386--DatabaseSessionImpl(12916846)--Connection(9550256)--Thread(Thread[main,5,main])--INSERT INTO PHONE (P_NUMBER, EMP_ID, AREA_CODE, TYPE) VALUES (?, ?, ?, ?)
         bind => [1234567, {Employee: Blaise Pascal}, 603, desk]
    [TopLink Warning]: 2008.01.10 10:28:58.511--UnitOfWork(18511661)--Thread(Thread[main,5,main])--Local Exception Stack:
    Exception [TOPLINK-4002] (Oracle TopLink - 11g Technology Preview 3 (11.1.1.0.0) (Build 071214)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: Ungültiger Spaltentyp Error Code: 17004
    the highlighted section should be 1501 (the key of the employee record)
    Any ideas how to fix this?
    Thanks Erika

    Erika,
    You need to specify the other side of the relationship (on the PhoneNumber side), which is done by putting a @ManyToOne annotation on the "employee" attribute in PhoneNumber. That will cause TopLink to know that it is a relationship and not a basic mapping.
    -Mike

  • Can one move one layer relative to another in Elements 11?

    Can one move one layer relative to another in Elements 11?

    Yes. Open the layers pallet:
    Window >> Layers
    You can drag layers up and own the stack. Wait until you see a blue line and then drop.

  • One on one relation

    Dear all,
    I have a master block in table form that displays 20 rows.
    Is it possible to have a detail block (one on one relation), also displaying 20 rows (on the right side of the master block.
    Example:
    Masterfield1 Masterfield2 Masterfield3 Detailfield1
    Masterfield1 Masterfield2 Masterfield3 Detailfield1
    Masterfield1 Masterfield2 Masterfield3 Detailfield1
    Masterfield1 Masterfield2 Masterfield3 Detailfield1
    Masterfield1 Masterfield2 Masterfield3 Detailfield1
    Masterfield1 Masterfield2 Masterfield3 Detailfield1
    When I try to do this, the detailfields I fill in are all connected to the first masterrecord.
    Is it possible to create a one-on-one relation?
    Thanks.

    That's not that big problem.
    - Set the fields of your ERP view to "query only"
    - Create a view with an outer join with the table and your erp view (with respect to performance create a view
    directly on the tables, not on your view)
    - use the primary key of the table as the primary key of the block
    - set the dml data target name of the block to that of your table
    - rewrite the on_insert and on_update and on_insert triggers like...
    on_insert:
    well, I think it's not allowed
    on_update:
    if primary key is null then
    insert ...
    (check that you got the primary key after inserting)
    else
    update ...
    end if;
    on_delete:
    I think you can use the original one.
    That should work.
    Regards,
    Torsten

  • Invoice number sales order number one to one relation

    Hi all,
    How to check the sales order whether open(invoice) or closed(invoiced).From VBFA table it is difficult to find.
    Is there any other way to find. Ex. one sales order no is there 1014421. how to find it is open or not.
    From Document Flow i can get VBFA table .But it it is not one to one relatation

    Hi
    In VA02 or VA03 after givinging the sales order number Press Document Flow  (F5) button.
    you can see the document flow of that particular Sales order, whether it is delievered or invoiced and passed on to accounting.
    Regards
    Neelima

Maybe you are looking for

  • I NEED HELP BAD

    ok..i had a account on my laptop..but it got takein off..so i never pluged my ipod back in my laptop..well than i did..and i read the ipod name and stuff..but not the songs..i can only update it with new songs..,but how do i take whats on my ipod and

  • How to set Statistical wbs element?

    hi,everyone. i'm a green hand in PS. i know Statistical wbs element is different from normal wbs element from you guys. but i don't know how to set a Statistical wbs element, i mean how to make a normal wbs element  become a Statistical wbs element?

  • How to fetch env. variable from OC4J instance

    At the launch of my application I want to fetch a variable value we have created on the iAS server at the application's OC4J instance level and under "Server Properties". I am unable to fetch anything using getHttpServletRequest() method. Does anyone

  • Colors are dropping out

    I have a strange thing happening. I'm sure it's something simple, but I can't figure it out. I have a layered image. I've been dragging photos onto it without any problems. But... there are two images that are now acting weird. The first is my daught

  • Sync mac to iphone

    help; old macbook pro but with Mountain Lion and iphone latest updates and itunes.  i just want my music library on my phone.  how please???