OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

foreign key

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
DBR
Newbie
Newbie


Joined: 03 Feb 2012
Posts: 2

PostPosted: Fri Feb 03, 2012 1:04 pm    Post subject: foreign key Reply with quote

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
View user's profile Send private message AIM Address
probe1
Moderator
Moderator


Joined: 18 Aug 2004
Posts: 2560
Location: Chonburi Thailand Asia

PostPosted: Fri Feb 03, 2012 7:04 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
DBR
Newbie
Newbie


Joined: 03 Feb 2012
Posts: 2

PostPosted: Sat Feb 04, 2012 1:41 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
probe1
Moderator
Moderator


Joined: 18 Aug 2004
Posts: 2560
Location: Chonburi Thailand Asia

PostPosted: Sat Feb 04, 2012 2:20 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
newbee391
General User
General User


Joined: 04 Jan 2012
Posts: 17
Location: New York, USA

PostPosted: Sat Feb 04, 2012 12:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group