How to link foreign keys & primary keys using python?
Steve Holden
steve at holdenweb.com
Mon Jun 12 04:04:26 EDT 2006
sonal wrote:
> Hi Mr. George,
> Sorry for confusing u so much...
> Let me try it again...
>
> I am not using any relational database to store the required tables
> with primary keys & foreign keys....
>
> When I say PRIMARY KEY =>
> 1. It means an index is created on the specified fields
> (Out of various fields given in the comma separated txt file)
> FileFormat: CODE, FIRST_NAME, last_name, area_of_expertise, country
> Eg: A1,Harry,George, python, XYZCOUNTRY--------(1st record)
>
> 2. The index can be formed on a single field or on multiple fields
> Eg: a. 'CODE' (single field ) {pk_code}
> b. 'CODE' & 'NAME' (multiple fields ) {pk_code_fname}
>
What, in Python, *are* these indexes - lists, dictionaries, tuples or
something else?
> Now when I say FOREIGN KEY =>
> 1. If the foreign Key is formed on the field 'CODE' in another text
> file
> Format: subsriber_code,CODE,first_name, no_of_posts,active(Y/N)
> Eg: SUB_001, A1, Harry, 50, Y
>
> This means the CODE (A1) given here is checked in the index formed
> above
> with primary key: pk_code...
>
> 2. If the foreign Key is formed on the fields 'CODE' & 'FIRST_NAME'
> Format: subsriber_code,CODE,FIRST_NAME, no_of_posts,active(Y/N)
> Eg: SUB_001, A1, Harry, 50, Y
>
> This means the CODE (A1) & FIRST_NAME (Harry) given here
> are checked in the index formed above with primary key:
> pk_code_fname...
>
> I am done till here.....
>
> The problem starts if I have defined an index on multiple fields
> (composite PK)
> say: CODE & FIRST_NAME (pk_code_fname)
> and if I need to define a FK on a single field out of these
> say: CODE
>
> I am unable to do that...
> Mr. George, I thought i must explain the code i am dealin with,
> for better understanding.., but i am sorry i confused you all the more
> (incase, u want to view the code please refer to the code snippets in
> my first query posted)
>
> Thanks & regards,
> sonal
>
A lot depends on the data structure that the code uses to represent the
"indexes". Perhaps you could explain how things are looked up in them?
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Love me, love my blog http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
More information about the Python-list
mailing list