| View previous topic :: View next topic |
| Author |
Message |
DBR Newbie

Joined: 03 Feb 2012 Posts: 2
|
Posted: Fri Feb 03, 2012 1:04 pm Post subject: foreign key |
|
|
Hello
I'm starting using OpenOffice and I cannot create a foreign key. The help is empty, can you help me?
Thanks. |
|
| Back to top |
|
 |
probe1 Moderator


Joined: 18 Aug 2004 Posts: 2478 Location: Chonburi Thailand Asia
|
Posted: Fri Feb 03, 2012 7:04 pm Post subject: |
|
|
Which OOo version?
Which operating system?
Which database you use (see statusbar of ODB)
Where you want to create the FK? _________________ Cheers
Winfried
My Macros
DateTime2 extension: insert date, time or timestamp, formatted to your needs |
|
| Back to top |
|
 |
DBR Newbie

Joined: 03 Feb 2012 Posts: 2
|
Posted: Sat Feb 04, 2012 1:41 am Post subject: |
|
|
It is a 3.3 version, I downloaded it free.
operating system : XP
database : OpenOffice.org Base
Sorry for my post, I'm not fluent in English. |
|
| Back to top |
|
 |
probe1 Moderator


Joined: 18 Aug 2004 Posts: 2478 Location: Chonburi Thailand Asia
|
Posted: Sat Feb 04, 2012 2:20 am Post subject: |
|
|
I assume you use the internal HSQLDB v1.8
Most important:
| probe1 wrote: | | Where you want to create the FK? |
_________________ Cheers
Winfried
My Macros
DateTime2 extension: insert date, time or timestamp, formatted to your needs |
|
| Back to top |
|
 |
newbee391 General User

Joined: 04 Jan 2012 Posts: 17 Location: New York, USA
|
Posted: Sat Feb 04, 2012 12:36 pm Post subject: |
|
|
Just to clear the air let's take it a step back and see how are you applying your primary key and foreign key.
Remember that a foreign key is a relationship or link between two tables which ensures that the data stored in a database is consistent.
The foreign key link is set up by matching columns in one table (the child) to the primary key columns in another table (the parent.)
Now that we know the how a primary key and a foreign g key works lets see an example:
Say that you have a table call Category, and another call Product, and you want to create a relationship from Category (Parent) to Product (Child.) This will be a "one-to-many" relationship (One category will have many products.)
The GUI way will be as follows:
Now that you have successfully created your two tables you can go to:
Tools --> Relationships
And start creating your relationships, in our case we one to add the category identifier to many products. So you will select the Category Primary Key to the Product Table, and you have now a foreign key.
The alternative will be going the SQL way, in which you will have to create the table product as follows:
CREATE TABLE "PRODUCT[
PRIMARY KEY[ product_id]..... FOREIGN ID[category_id]
Hope this helps!
_________________
If your problem has been solved please add "[Solved]" to the beginning of your first post title (edit button). |
|
| Back to top |
|
 |
|