You Are Here:

Community: Developer Discussion Boards

#1 Old Primary and foreign key in e32db - 2009-03-13, 12:04

Join Date: Feb 2009
Posts: 72
v divya
Offline
Regular Contributor
Hi all,

Can someone give me a soln on how to set primary key and how to create a foreign key in e32db..

I learn't that COUNTER will act as a primary key in e32db.. I tried it but the counter value is 0 for all my record.. Is there anyother way to set primary key..

Also say me how to set a foreign key in e32db..
Reply With Quote

#2 Old Re: Primary and foreign key in e32db - 2009-03-13, 19:35

Join Date: Jun 2008
Posts: 45
maclun123
Offline
Registered User
I am using like this:
Code:
self.db.execute(u"CREATE TABLE RelatedWLan (Id COUNTER, I_Id SMALLINT, WLan_Id SMALLINT)")
and when adding:
Code:
self.SQLdb.query(u"INSERT INTO RelatedWLan (I_Id, WLan_Id) VALUES (" + str(id) + "," + str(result[0][0]) + ")")
FK you just insert as any other other value. I did that. Above I_Id is a foregin key.

hope this helps.
mac
Reply With Quote

#3 Old Re: Primary and foreign key in e32db - 2009-03-14, 10:32

Join Date: Feb 2009
Posts: 72
v divya
Offline
Regular Contributor
malun123 thanks for ur reply but I didn't understand ur INSERT statement.. How does I_Id became the foreign key.. So, Can it be used in any other table? Can someone pls explain on that code..

Code:
db.execute(u"CREATE TABLE Details_table(Id COUNTER, Name CHAR(20)")
db.execute(u"CREATE TABLE Settings_table(Id, Settings CHAR(20)")
Say for eg I have the above 2 tables and my 2nd table(Settings_table) should use 1st table's(Details_table) field Id value in it.. How to get this done..

Python experts I am waiting for ur replies.......
Reply With Quote

#4 Old Re: Primary and foreign key in e32db - 2009-03-14, 16:52

Join Date: Jun 2008
Posts: 45
maclun123
Offline
Registered User
My example is the manual job. I am using I_Id as a FK in my project.
I am not into SQL that much, but if you are thinking about having something like 'joins', then I am afraid that Pys60 does not support that.

mac
Reply With Quote

#5 Old Re: Primary and foreign key in e32db - 2009-03-14, 18:45

Join Date: Feb 2009
Posts: 72
v divya
Offline
Regular Contributor
Quote:
Originally Posted by maclun123 View Post
My example is the manual job. I am using I_Id as a FK in my project.
I am not into SQL that much, but if you are thinking about having something like 'joins', then I am afraid that Pys60 does not support that.

mac
Thanks for ur suggestion mac :-) I wil this and see..

Is anybody else there who can give few more examples or can help me in creating foreign and primary keys in e32db....

Pls guys I need help.......

Do reply to my post as soon as possible.....

Thanks in advance....
Reply With Quote

#6 Old Re: Primary and foreign key in e32db - 2009-03-14, 21:27

Join Date: Mar 2009
Posts: 8
zarzu
Offline
Registered User
this is how you should get a primary key:
Quote:
CREATE TABLE person (id COUNTER, name VARCHAR)
CREATE UNIQUE INDEX id_index ON person(id)
there is nothing like a foreign key as e32db does not support any kind of joins, so a foreign key concept doesn't make sense (if you are going to query the db twice to form a join in your program you will need your code to make sure that you only can insert valid pseudo foreign keys). e32db is very very limited.
Reply With Quote

#7 Old Re: Primary and foreign key in e32db - 2009-03-15, 10:12

Join Date: Feb 2009
Posts: 72
v divya
Offline
Regular Contributor
Thanks zarzu.. I am now clear on primary keys..

So if I want to access any value from one table to another table, is it not at all possible in e32db?

My database design requires this aspect strictly.. What am i to do if I want to use one table values in another table.. Should i quit e32db and choose something else..

Pls clear my doubts..
Reply With Quote

#8 Old Re: Primary and foreign key in e32db - 2009-03-17, 04:42

Join Date: Feb 2009
Posts: 72
v divya
Offline
Regular Contributor
Hello python experts... I am waiting for ur replies for my previous post... Do help in getting soln to my problem..

Can I access values from one table to another using e32db... I need this aspect in my db.. What should I do to get this done..

Plssssssss do reply as soon as possible....

Thanks in advance...
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Database:primary key-foreign key relation remyag General Symbian C++ 4 2008-07-16 11:27

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia