Re: using Modeling w/o primary keys

Duncan McGreggor <[email protected]> Mon, 28 Jun 2004 13:29:11 -0400
Newsgroups gmane.comp.python.modeling
Message-ID <[email protected]>
On Jun 28, 2004, at 12:44 PM, Sebastien Bigaret wrote:

>
>   Hi Duncan,
>
> Does this mean that you need to access an already existing database 
> where *no*
> primary key are defined???

Most of their tables do, but some don't. The ones that don't may just 
be lookup tables, in which case there's no need to model them... The 
project has been a "black box": they want a generalized wrapper for 
some of their custom utilities, so os tools, and Modeling. I've been 
getting more info from them, though...

> PKs are important, yes, just because you need a PK to map an object w/ 
> its
> corresponding row in the database (even if you do not have a single
> relationship defined in the schema). Any objkect-relational mapper 
> will need a
> way to uniquely identify a row/an object (it does not mean, however, 
> that there
> should be an attribute explictely marked as the PK in the db, only 
> there is
> exists a set of attributes (generally one) that can be taken as the 
> PK).

Yes, as you can see, not only does what you say make perfect sense, but 
I am rather ignorant of database modeling below anything other than a 
purely superficial level.

> I bet you have PK defined in your tables, or am I wrong?

I don't have access to their databases, but have the understanding that 
most of them do, but some don't. Based on what you said above, I think 
it's perfectly acceptable to perform a PK check during metadata 
extraction, and throw an exception for any table without a PK.

> Secondly, could you
> tell whether you wish read-only access to the db? (I suspect you do, 
> but better
> be sure).

You would think, based on my initial question, that it would be 
read-only. If I have known what I was talking about, I would not have 
asked the question... your answer and questions are very instructive: I 
see now that in order for object mappers to be able to manipulate and 
save data back to the database, there must be primary keys (or some 
means of object identification).

Given that, I will write the code necessary to extract PK info from db 
metadata tables (postgres and oracle), and use that to create a db 
model. I'll give that a try and see how it works.

I don't know if any of the client tables have multiple columns that 
define PKs, however, I just did a search on the mail list and saw this:
http://sourceforge.net/mailarchive/message.php?msg_id=6801413
Has there been any move to support multi-column PKs since then?

Thanks for your patience and help!

Duncan



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com