Can the Primary Key also be Primary key in another table

Hi all,
I am working on a project. The project specification says:
Project table contains details of projects and the project number *(proj_no)* is the key.
project ( proj_no , proj_date, proj_desc, proj_type, proj_status, s_no, cust_no)
purchase_order table contains details of the purchase orders for each project and the combination of project
number and a purchase order number *(proj_no, po_no) form the key.*
purchase_order ( proj_no , po_no, po_date)
How can I have proj_no in the project table and in the purchase_order as primary keys?
If I create a composite key in the purchase_order table making the ( proj_no, po_no) as primary key. How can I make the project_no in the project table a primary key too?
Is there a solution for it?
CREATE TABLE purchase_order(
po_no NUMBER(5) NOT NULL,
proj_no NUMBER(5) NOT NULL,
po_date date,
CONSTRAINT p_o_po_no_proj_no_pk PRIMARY KEY (po_no,proj_no));
Thanks!!!

Hi,
I think I'd set the project no in the projects table a primary key, and project no in the purchase orders table a foreign key constraint to the projects table, combined with a unique, not null constraint in the table.
That, in addition to a unique, not null constraint on the purchase orders column, and a composite primary key should fulfill the requirements.
Best of luck!
Johan

Similar Messages

  • HT1665 I have a World Travel Adapter Kit for use with my iPad. can the plug adapters also be used on the Mac Pro charger to charge up my laptop when travelling or is a special converter needed.M

    I have a World Travel Adapter Kit for use with my iPad when traveling abroad. I know this charger can be used on an iPhone, can the plug adapters also be used with the charger of a Mac Book Pro or is a special converter required?

    Is there any concern about the type of travel adapter kit? For instance, some instructions indicate they are for heat creating appliances (hairdryers, curling irons, etc.). I bought such a set, but do they present any issues if used with more delicate electronic circuitry (for iPads, iPods, or with camera battery chargers). I am leaving for the UK on Monday and need to get it right - are they too strong for the Apple products if they are not to be used with computers? What other options are out there?

  • Can the home app also use the saved passwords of the desktop Firefox version?

    I rely on the saved password feature of Firefox for my bookmark sites. Can those saved passwords also be transferred to the Home Firefox on my iPad and iPhone?
    Also is there a way to have the iPad version in a higher resolution?
    Thanks

    I'm sure I'm missing something obvious here. I've signed up for a Firefox Sync account and installed Firefox Home on my iPad - but I can't see any sign of saved passwords being synced. Where would they be on the iPad? They're not auto-suggested even in the browser embedded in the Home app.
    Ideally, I'd like them to be available directly in Safari too, but I realise that this might be harder to do.

  • How to show data in table on the basis of click on a row of another table

    Hi All,
    I want to show two tables. In first table the main objects show in turn there is another collection in that main object for which i want to show data in separate table.
    e.g.,
    ObjectA
      have the collection of ObjectBs
    when i select ObjectA in main table then all the collection Objects of ObjectBs shows in separate table. Plz help me how to handle this case ??

    hi,
    You can create two value nodes for storing these collections. The first one would be singleton node as it is the main list. Under that create the second node with singleton = false.
    e.g.
    ---NodeA
        --attrA1
        --attrA2
        --NodeB(singleton = false)
                --attrB1
                --attrB2
    Now populate collection of object A in NodeA and after adding element in NodeA populate respective elements in NodeB.
    IPrivate<View>View.INodeANode nodeA = wdContext.NodeAnode();
    for (Iterator  it = collectionA.iterator(); it.hasNext(); )
         ObjectA objA= it.next();
         IPrivate<View>View.INodeAElement nodeAElem= nodeA.createNodeAElement();
         wdCopyservice.copy Corresponding(objA,nodeAElem);
         nodeA.addElement(nodeAElem);
         Collection collectioB =objA.getCollectionB();
         for (Iterator  it1 = collectionB.iterator(); it1.hasNext(); )
             ObjectB objB= it1.next();
            IPrivate<View>View.INodeBNode nodeB = nodeAElem.nodeBnode();
            IPrivate<View>View.INodeAElement nodeBElem= nodeB.createNodeBElement();
            wdCopyservice.copy Corresponding(objB,nodeBElem);
            nodeB.addElement(nodeBElem);
    Bind NodeA to the first table and NodeB to second one.
    After that when you select record in first table automatically its corresponding records will be populated in second table.
    Hope this helps!
    Monalisa

  • Can the PIXMA MG2220 also be used for documents?

    I recently purchased a Canon PIXMA MG2220. Can this model also be used for printing, scanning documents as well?

    Hello p_lainhart1952!  You have nothing to worry about!  The PIXMA MG2220 can print and scan both photos and documents.  We hope this information is useful to you!

  • Can the AET be used to create a new Z table?.

    I understand that new user tables can be created/changed via EEWB, but, I keep reading that in CRM 7 we should now be using the AET tool. Can I create a new user table in AET, and if so, how?.
    I only know of one way to launch the AET via the WebUI, and that's via the screen configuration tool. Of course this method would only allow us to ammend an existing structure/table and not create a new one, hence my question.
    Anyone.
    Jason

    As far as I know EEWB never supported Z-tables except for those related to the SAP Business Partner.  It's always been next to impossible to use the EEWB to add Z-tables for the business transaction model.
    Jason can you please back your rant with some examples what the EEWB did with Z-tables that is not supported by the AET, for specific business object types.  EEWB was never used to create stand alone z-tables.  Also technically the EEWB was a big failure because it never supported currency and quantity type fields, so you could never automate your work.
    I'm just little concerned that if you don't clarify your statement about the EEWB you are going to confuse people who read this thread in the future.
    On another note the new tools available in EHP1 for enhancements are great and not hard to figure out.  They definitely fill some needed gaps.  Now just don't get me started about EHP1 not being in GA.
    Take care,
    Stephen

  • Can the Data Foundation Of Business View Manager Handle 100 tables or views

    Post Author: palm
    CA Forum: Crystal Reports
    Hi All,
    I am working on the DF which will take 100 Oracle Views , some may be tables in it
    Do any one know the limit of tables or views to include in DF  Or is DF can handle any number of tables or views in it that are joined in anyways?
    And one more , i had around 30 table in my DF , when i double click the table or view that are inserted in DF it will expand and minimize
    But i face this problem , when i expand a table by double clicking it in DF and then save that DF  , the BVM window closes
    Do any one know about this , please help me
    Thanks!

    Post your question to the BV forums: Semantic Layer

  • CMR - Can a primary key also be a foreign key?

    Hi,
    Has anyone come across the following problem? Although I mention Jdeveloper below I believe it is a general J2EE issue!
    I have two tables
    customer
    customer_id (PK)
    individual
    customer_id (PK)
    customer_id in individual is the primary key for that table. It is also a foreign key ( related back to customer).
    If I use JDeveloper to drag in the two tables ( into a class diagraqm), I have a problem.
    JDeveloper "sees" the Individual bean foreign key mapping and generates a getCustomer() method (which returns a handle to the appropriate customer bean).
    However as it "removes" the getCustomer_id() method(which returns the actual customer_id), the primary_key reference is dropped.
    When I try and compile, JDeveloper quite rightly complains with "where is the primary key".
    Can anyone help? Do I need to make it a rule that the foreign key is not also the primary key?
    thanks in advance,
    Kevin

    Hi Kevin,
    I would not pursue this model if I was you. The only thing OC4J supports without killing yourself is to let each table has its own primary key (preferably not composed) and to make all foreign key's optional !
    We have spent months trying to make it work and we are getting little or no support from oracle, even though we are paying many euros for a partnering contract.
    greetz,
    Jurgen

  • How can I use the SQL to create a primary key for a existing table?

    create table a(bm number,mc varchar2(20));
    when the table was created,i want to make the column bm as
    the primary key and my SQL is "alter table a enable primary key bm",the system show
    me error,how can I write the right one?

    create table a(bm number,mc varchar2(20));
    when the table was created,i want to make the column bm as
    the primary key and my SQL is "alter table a enable primary key bm",the system show
    me error,how can I write the right one? You do not have any primary key defined on your table yet, so, it does not make sense to enable it (if at all possible) !
    You need to add PRIMARY KEY using something like this:
    SQL> alter table a add constraint pk_a_bm primary key (bm) ;

  • How to code the ejbCreate() method without initailizing primary key?

    Hi all,
    I've just started learning about EJBs, and now am at the stage of learning how to create, deploy and test a CMP Entity Bean.
    Ran into a problem which I'm hoping someone can help out with.
    I'm using SQL Server 2000 as my backend database, and have created a simple table called TEST with 2 fields, id and name. id is set as the primary key, and as an identity conlumn. What this means is that when we do inserts, we don't need to specify a value for the id column. SQL Servers automatically generates that value.
    Here's my ejbCreate method in my bean class:
    public Integer ejbCreate(String name) throws CreateException {
        this.setName(name);
    }When I tried to run the create method from a web client, I got this error:
    javax.ejb.CreateException: [EJB:010148]In EJB 'SampleEJB', the primary key field 'id' was not set during ejbCreate. All primary key fields must be initialized during ejbCreate. at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:186) at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:284) at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:244) at everbright.ejb.SampleEJB_uzc4wg_HomeImpl_813_WLStub.create(Unknown Source) at jsp_servlet.__index._jspService(__index.java:152) at weblogic.servlet.jsp.JspBase.service(JspBase.java:33) at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6452) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3661) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2630) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
    So it seems like I can't leave the id field uninitialized in the ejbCreate method. However I don't know what to initialize it with either, because in order to know what value I need to initialize it to, I'll need to run a db query to retrieve the next primary key value for the id field. This doesn't sound very efficient to me.
    I tried to initailize it to null, but that gave me a NullPointerException.
    Why do we need to initialize the primary key field in ejbCreate? Should the container do the insert and then get it from the table accordingly?
    Is there any other way I can get this set-up working?
    Thanks!

    Hi Fusion777,
    Ya, I've been searching around forums for an answer also. Apparently this is indeed a problem that has no general solution. It depends on 2 factors:
    1) Whether or not the database supports autogenerate key (which most does) and how (Oracle does it by sequences while SQL Server by identities)
    2) Whether or not the application server supports 1).
    In my case, I'm using SQL Server and Weblogic Server 8.1 and most fortunately, Weblogic does support identities and sequences. Just define the <auto-key-generation> stanza in your weblogic-cmp-rdbms-jar.xml deployment descriptor, as follows:
    <automatic-key-generation>
         <generator-type>ORACLE</generator-type>
         <generator-name>test_sequence</generator-name>
         <key-cache-size>10</key-cache-size>
    </automatic-key-generation>
    <automatic-key-generation>
         <generator-type>SQL-SERVER</generator-type>
    </automatic-key-generation>
    <automatic-key-generation>
         <generator-type>NAMED_SEQUENCE_TABLE</generator-type>
         <generator-name>MY_SEQUENCE_TABLE_NAME</generator-name>
         <key-cache-size>100</key-cache-size>
    </automatic-key-generation>I've tried that and it works :-)
    I gather from your reply that those who are using JBoss are equally fortunate :-)
    So I thought I'll share this in case some other poor fellow is facing the same problem as we are. At least worse come to worse, he'll have the option of switching to either JBoss or Weblogic and know that it works in both :-)
    Some other users seem to be against the idea of using auto-generated keys for precisely the reason that it is not a standard across database and application servers. See this thread:
    http://forum.java.sun.com/thread.jspa?forumID=13&threadID=329896
    I've in fact stopped working on EJB 2.0 and am exploring something called Hibernate, which seems to have a more generic way of dealing with the auto-generated key issue. In fact, I've heard news that EJB 3.0, which is the upcoming standard for EJB, will be heavily inspired by Hibernate as far as CMP Entity Beans are concerned.
    You can check out Hibernate at http://www.hibernate.org.

  • How can I see all references to primary key

    How can I make a query for my primary key to see the detail foreign keys and see which key is not available?

    select a.table_name, a.constraint_name, b.table_name as Ref_Table, b.constraint_name as Ref_Constraint
    From ALL_CONSTRAINTS a, ALL_CONSTRAINTS b
    where a.r_constraint_name = b.constraint_name
    and a.constraint_type = 'R'
    and b.table_name = 'TABLE_NAME';
    OR, more exactly:
    select a.table_name, a.constraint_name, b.table_name as Ref_Table, b.constraint_name as Ref_Constraint
    From ALL_CONSTRAINTS a, ALL_CONSTRAINTS b
    where a.r_constraint_name = b.constraint_name
    and a.constraint_type = 'R'
    and b.constraint_type = 'P'
    and b.table_name = 'TABLE_NAME';
    null

  • Can we have more than one primary key constraint to a Oracle Table?

    Hi,
    Can we have more than one primary keys to a single table in oracle? ( Not the composite key)
    Please somebody answer..
    Regards,
    Alaka

    811935 wrote:
    Can we have more than one primary keys to a single table in oracle? ( Not the composite key)
    In principle a table can have multiple keys if you need them. It is a very strong convention that just one of those keys is designated to be "primary" but that's just a convention and it doesn't stop you implementing other keys as well.
    Oracle provides two uniqueness constraints for creating keys: the PRIMARY KEY constraint and the UNIQUE constraint. The PRIMARY KEY constraint can only be used once per table whereas the UNIQUE constraint can be used multiple times. Other than that the PRIMARY KEY and UNIQUE constraints serve the same function (always assuming the column(s) they are applied to are NOT NULL).

  • Update primary key that’s also a foreign key in another table

    Hi Developers,
    I need to update the primary key for a record but it's also the foreign key in another table.
    Example,
    Table 1 Details
    Name : Parent_Table
    Columns : ID, Name, Age
    Primary Key : ID
    Table 2 Details
    Name : Child_Table
    Columns : ID, Parent_ID, Name, Age
    Primary Key : ID
    Foreign Key : Parent_ID (Primary Key in Parent_Table)
    Parent_Table
    ID Name Age
    1001 Sam 26
    1002 George 25
    Child_Table
    ID Parent_ID Name Age
    1010 1001 Sam 26
    1020 1002 George 25
    Now I want to update ID (1001) in Parent_table as 2001 and also, I want to update Parent_ID (1001) in Child_Table as 2001.
    How we will write the java code to update these columns.
    Thanks in advance.

    dcminter wrote:
    If you're looking at changing the primary keys in your data then there's probably something wrong with your data structure.Depends how you feel about business primary keys versus surrogates. Personally I prefer the latter so I'm with you in theory. In practice, however, a DB that uses a business PK may well find that it's a legitimate use case to change the key value (but then that's why I like surrogates in the first place!)Primary keys should not have meaning.

  • I can't seem to decide between the 13" or the 15" MacBook Pro. I had a 14.5 in Dell which crashed on me for the third and last time. It was also my primary home computer. Is the 15" necessary or should I just get the 13"?

    I can't seem to decide between the 13" or the 15" MacBook Pro. I had a 14.5" I'm just used to that size. Dell which crashed on me for the third and last time. It was also my primary home computer. Is the 15" necessary or should I just get the 13"? I probably won't be doing any graphics or anything like that.

    It is really a matter of your personal preference. You have to choose between the extra carrying convenience of the smaller machine and the greater "real estate" of the bigger. I use a 15", and have not found it inconvenient for carrying, even on aircraft, where it has to share backpack space with an SLR camera and assorted lenses.

  • We need to buy Adobe Framemaker version 11. The distributor is only able to provide us with version 12. Can someone suggest me how is it possible to get the license for ver 11 serial  key after purchasing ver 12 and also how to get the download details ?

    We need to buy Adobe Framemaker version 11. The distributor is only able to provide us with version 12. Can someone suggest me how is it possible to get the license for ver 11 serial  key after purchasing ver 12 and also how to get the download details ?   Urgent response will be helpful.D

    Adobe Support helped us with a similar query. We ended up with exactly what you need.

Maybe you are looking for