Solved - Python: automate input to MySQL query

D'Arcy J.M. Cain darcy at druid.net
Thu Sep 24 09:35:57 EDT 2009


On Thu, 24 Sep 2009 15:03:26 +0200
Tino Wildenhain <tino at wildenhain.de> wrote:
> > 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.

Sure, I was trying to show a hypothetical situation.  In my real
databases I don't do that and in fact I point the manager_id field to
another entry in the same table.  Obviously in that case I am forced to
make it a different name even though it references the same column as
employee_id.

> 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.

Exactly.

> > 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.

I want to name them differently even if they aren't in the same result
set because they are different things that just happen to have the same
type - money.  I wouldn't name every int column "int" and I wouldn't
name every price column "price."

-- 
D'Arcy J.M. Cain <darcy at druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



More information about the Python-list mailing list