Solved - Python: automate input to MySQL query

Tino Wildenhain tino at wildenhain.de
Thu Sep 24 09:03:26 EDT 2009


Hi,

...

>> code, even that is not needed, as the columns are returned in the order
>> specified so code /knows/ that the first column is<name>  from /this/
>> table and the other column with<name>  is from /that/ table).
>
> Unless you get a dictionary return.
>
> In any case, I have a strong philosophical objection to using the same
> name to refer to two different things regardless of any operational
> issues.  The manager.firstname and employee.firstname are not the same
> thing and should have different names to reflect that.

This seems to be a shortcome in your datamodel, in fact I'd see
a firstname of an employee as the same type of information as the
firstname of a manager.

So what you really would have is a table with all the people
and another which declares who is manager of who.

recommended of course is to name different data differently
and also to keep the name of the foreign keys the same on
every table so you can use:

SELECT a,b,c FROM tablea JOIN tableb USING (ab_id)

since this avoids duplicate columns in the result.



> A similar issue comes up in the classic situation of the inventory table
> price field and the sale item price field.  They sound like the same
> thing but they are not.  One is the current price in the catalogue and
> the other is the price it was sold for at a particular time.  They need
> different names for that reason.

Yes and you should name them different in your query when they appear
in the same result set.

Regards
Tino


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3254 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20090924/b62d50e6/attachment-0001.bin>


More information about the Python-list mailing list