In JDO, can a foreign key be part of a primary key?
Hi, it's possible to have a foreing key a part of a primary key in JDO?
The JDO checker is complaining about that. It says "Primary key field 'person' cannot declare relationship".
For example, if I have an entity 'Person' (id, name) and and entity 'Pet' (name, age). Can I have the primary key of 'Person' (id) as a foreign key in 'Pet', and can I have a compound primary key in 'Pet' with 'name' and 'id' as the compound key?
Thanks in advance.
Rafael
Hi Dino,
First of all, thank you very much for your answer.
I read the article, but the solution proposed isnt clear to me. The theorical solution is: You'll have to map the foreign key columns to individual simple fields in your class rather than a single related object. At runtime, you can use the values of these fields to construct an application identity instance, which you can then use to fetch the related object
I dont understand the second sentence
how would I fecht the related object at runtime?
Did you try it? Could you please send me an example? I change the type of my attributes to primitive types, and I left my .jdo and .map files as if those attributes were only primary keys
how would I specify the relation at runtime with the other table?
My email is [email protected], I would really appreciate your help.
Best regards,
Isidro
Similar Messages
-
Are foreign keys really necessary in a database design?
Hi All,
I am working on a database which has no foreign keys.
Please suggest the necessity of foreign keys in database and can the foreign key implementation enhance the performance of the database.
Thanks & Regards,
Deepak Pushkarna[email protected] wrote:
Hi Orion,
As the application is a legacy application, so it has handled all the integrity part.Until someone touches the data outside the application. Can you spell "sqlplus"? Can you spell "odbc"?
Or until some developer misses .... oh, developers never write buggy code ....
>
Regarding performance, the relation is not very complex but data is huge. So, if I implement foreign key relation, so will there be any improvement.
It's really not about performance at all. It's about data integrity and data integrity is best protected by the dbms itself. In fact, the dbms is the only layer that you can be sure is going to protect your data integrity.
>
Thanks & Regards,
Deepak Pushkarna -
Hi All,
Is there any mean by which we can use Foreign Keys in MDM.
Sighting an example.
We have 3 table with fields:
Products(Main Table): Material No( UF)
Product Regions(Flat): Marerial No ( Foreign Key),Region: Lookup
Prices(Flat): Material No( Foreign Key),Region: Lookup(Foreign Key),Price Type: Lookup.
How is it possible to achieve the above mentioned scenerio.
And are Foreign Keys same as Unique Fields in MDM.
Thanks
Manish
Edited by: manish gupta on Mar 4, 2009 12:30 PMHi Manish,
MDM server sits on the database server.
The database server is a DBMS.MDM repository does not work with the tables and fields structure in exactly the same way as an RDBMS.
So we do not use in the real sense the same Primary key Unique key concept.However we have the linkup/lookup field concept in MDM.
Where a field in the main table can reference another field in the lookup table.
So if you relate this to the RDBMS concept.The primary field in one table is the Foriegn key in another table.So in the lookup table we can refer a field of the main table.
say for eg:
You have a field Regions in the main table of type lookup flat.
This field is actually used in the lookup flat table say lookup regions.
This table has a field regions which is holding a legal set of values.
So the field Regions in main table is used in the Lookup table as well.Where in the main table it was the linking field and in the lookup table it is the field holding the lookup values.
So you can to an extent relate these 2 concepts but it does not precisily work in the same way in MDM.
Hope It Helped
Thanks & Regards
Simona Pinto -
SQl*Modeler - foreign key amendment error
SQl*Modeler 2.0.0 Build 584 (Windows)
Oracle 10.2.0.4 Solaris
If I change an existing foreign key to simply change the delete rule (from say CASCADE to RESTRICT) it changes in memory just fine. If I generate the DDL the change has happened and I get the expected DDL.
However, I then save the model, exit SQL*Modeler, start SQL*Modeler and check the foreign key the change has been lost.
I can workaround this by changing the name of the foreign key and the change is saved correctly. Feature ?
IanHi Ian,
I logged bug for that.
You can use foreign key dialog to do that change without need to change the name - just double-click on FK line or presentation in the browser.
Philip -
Auto Population of foreign key
HI All
can a foreign key of a table be auto populated once the a row for the foreign key referred table has been inserted?.....
i have a common attribute for both the tables.
Please helpsorry for the double posting as my network is
experiencing problemsIf that happens, please have the courtesy to pick one thread as the main one, and provide a link to it in the other thread, so that people don't waste their time duplicating each others' answers. -
Can I create a foreign key when creating Business Components from Tables
Hi,
I would like to use ADF and JSF to create an application on our database. My problem is our database does not "conform". i.e. there are no foreign key constraints.
When I create a "Business Component from Tables" view, can I put in my own joins between tables so enabling the use of the generated views?
Jon L.View object instances show up in the data control palette once you've added them to your application module's data model.
See these sections in the ADF Developer's Guide for more information:
Section 2.6.3, "Using View Objects in the Application Module's Data Model" talks about using view object instance in the data model as part of the overview chapter.
Section 4.5, "Understanding the Active Data Model" explains a little more about this
Section 5.3, "Using a View Object in an Application Module's Data Model" shows how to do this.
Chapter 10, "Overview of Application Module Data Binding" gives details on how the application and its view objects are exposed in the Data Control palette.
You can find the guide on the ADF Learning Center on OTN.
http://www.oracle.com/technology/products/adf/learnadf.html
Look for the ADF Developer's Guide for Forms/4GL Developers. -
Can not insert null into foreign key issue
Hi ,
I am having parent-child relationship table.
In the child table when I am adding a new record , data is getting inserted with foreign key.
After insert if I immediately update the same record. Its giving error that can not insert null into foreign key.
If i click on rollback button I am able to update that record properly.Hi ,
I am having parent-child relationship table.
In the child table when I am adding a new record , data is getting inserted with foreign key.
After insert if I immediately update the same record. Its giving error that can not insert null into foreign key.
If i click on rollback button I am able to update that record properly. -
In ADF how can i insert data in multiple table if they have foreign key
I have started working on ADF and can anybody inform me in ADF how can i insert data in multiple table if they have foreign key,please?
Thnak you very much.Hello,
Still no luck.I am surely doing silly mistakes.Anyway,Here are my workings-
1> student_mst (id(pk),studentname) and student_guard_mst(id(fk),guardianname)
2> created EO from both of the tables,made id in both EO as DBSequence and an association was also generated.
3> i made that association composite by clicking the checkbox
4> i created 2 VO from 2 EO.
5> put those VO in Application Module.
6> dragged and dropped 2 VO on my jspx page and dropped them as ADF Form.
Now what to do please? -
How can I create a new entry without using LOV for foreign keys.
Referring to TUHRA sample application based on HR database schema. JDeveloper 10.1.3.0.4
How can I create a new employee without using LOV for the foreign key "job_id".
On the first page I would like to choose the job_title from adf read-only table.
After clicking on the "create new employee button" a creation form appears in which the job_id field is set with previous selection.
Regards M.Winkler
Edited by: user3541283 on 06.10.2008 03:44
Edited by: user3541283 on 06.10.2008 03:50Hi,
usually the foreign key is only set if the VO you select is dependent from a master. If e.g. you have DepartmentsVO1 that has an EmployeeVO3 as its nested VO, then creating a new instance of employees automatically add the foreign key. If you add EmployeesVO1, which is not dependent to DepartmensVO1, then the foreign key is not set. So if this is the case in THURA (keep in mind that this is not an Oracle demo but a sample used in a book about ADF) then all you need is to take the independent VO when building the new employee form.
Frank -
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,
KevinHi 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 -
Foreign key as part of primary key - bad idea
What are the pros and cons of using the primary key of the parent table as part of the primary key in the child tables versus just having it as a foreign key in the child tables?
Please share your experience on this. Thanks in advance.
Regards,
Richardsb92075 wrote:
but if the relacion is 0-1 to 1-1 ; better design 2 tablesWhy?
Blank columns require no special accommodation.Like most things, there's usually a case (even if it's a small subset of all possible cases) where this makes sense.
http://www.oracle.com/technology/oramag/oracle/09-mar/o29asktom.html “Wide Load Storage”
Would be one such case. -
Can I create constraints "Primary key - Foreign key" on materialized views?
Hello!
Can I create constraints "Primary key - Foreign key" on materialized views like on tables?
My purpose - is to make DB schema "COPY" with set of materialized views or tables, which take data from time to time from other tables situated.into another schema "ORIGINAL".
Also - I want to use reporting tool, like Crystal Reports, to make nice reports from schema "COPY". To make nice reports, I need primary-foreign relationships between materialized views or tables in schema "COPY".
Is it possible to use materialized views?
Or I should use only tables to get such result?
Thank you in advance.
Edited by: kogotok1 on Dec 3, 2010 5:01 PMWhat happens when you try it? Or search the manuals.
http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/statements_6002.htm#i2105365
http://download.oracle.com/docs/cd/E11882_01/server.112/e10706/repmview.htm#REPLN360 -
Can't generate several foreign keys at a time
I thought we could generate a liste of foreign keys with a single wizard.
The order generated had been
ALTER TABLE WORKS ADD ( CONSTRAINT FK_WORKS_10 FOREIGN KEY (DEFAULT_JAVA_POST_EXECUTION,JAVA_EXECUTION,DEFAULT_JAVA_ANTE_EXECUTION) REFERENCES JAVA_PROC(GES_NUMBER))
In fact, each of these foreign keyx should have contained a different instance of ges_number which is the primary key of the source table.
I think I need to use as many wizard as I define different links. Do I?The internal disk of the TC is HFS+ and has no file size limitation. up to the size of the disk. If you use Mac or Linux then the TC will have no file size limitation.
You are not using an external USB are you?? If so that should be formatted HFS+ as well.. windows can work fine to that in network share.
FAT32 will definitely have 4GB file issues.. that is the problem with FAT32. -
How can I show Foreign Key name in the Data model Table window
Hi,
In one of my table, I had a Foreign Key, but that is not indexed. I want to display the name with in the table second window in realtional data model. If it is indexed, then it is showing in third window. How I can show without indexing that column?
Thanks.I want to show Foreign Key name in the second window.
Thank you for considering my question,
Sundar -
Why can't global temporary tables have foreign keys?
Hi,
I have a forms module which shows two blocks. The first block is based on a normal database table EMP and the second one is based on a global temporary table SAL_TEMP. There is a master-detail relation between the two blocks. So far, in Designer I created two normal database tables EMP and SAL_TEMP and created a foreign key with validation level "none" from the table SAL_TEMP to the table EMP. By creating the foreign key, Designer generates code to automatically synchronize the data between the master and the detail block in my form.
In the latest version of Designer it is finally possible to indicate a table as a global temporary table. But when I try to change my table SAL_TEMP to a global temporary table (session) I get an error that this is not allowed because my table contains foreign keys. So the Designer team finally implemented this feature but it is useless to me.
Can someone explain to me the reason of this restriction?
VincentJust out of curiosity - which version of Designer supports the creation of global temp tables? We are running version 9.0.2.80.6 and, as far as I am award, this does not support it (unless I am being really thick!) - is this new 10g Dev. Suite functionality?
thanks,
Pete
Maybe you are looking for
-
How to restore your old music after it has been erased from being synced??
I once had music on my iphone and i synced it on my laptop wth itunes and now everything has been erased!!! How do I get everything back. I tried adding the music again but nothing it working. i EVEN checked my history of songs played on itunes and h
-
Is RoboHelp for Word packaged with RoboHelp 11?
Is RoboHelp for Word packaged with RoboHelp 11?
-
Hello. Guys I`m pretty new to Oracle and I been trying to restore our backup from Live Database to Our Test Database. This is what i did. After installing the Oracle 11g (11.2.0) on our Rhel6 environment, I try to create the folder structure to Test
-
Hi guys, Trying to make a soccer scoreboard. I want to order the teams (Rows) so that the teams with the most points are on top. Anybody know if there is a way to do this? Thanks, Chris.
-
Adobe, please, please do something with significant hue shifts on recovery slider!
I know that this happens due camera profiles have those hue shifts. After reading DNG specification, I understand inner workflow, but may be there is the possibility to apply camera profile after adjustments of recovery slider? Huge hue shifts happen