hello,

I'm just an amateur  struggling with databases,
so forgive if  I ask  a question every database user should know.

The situation is like this (simplified):

I've a table with persons: name, address, phone, etc.
I've another table with vehicles: car_or_bike, brand, type, build-year, etc.
The 2 tables are bounded by bind table: person_ID, vehicle_ID

I know that every person has 1 car and 1 bike

I want to show up a table, with 3 columns:
      persons.name          vehicle.brand[car]            
vehicle.brand[bike]


I can get the result in the following way:

1. create view Cars: persons join vehicle, where car_or_bike = car
2. create view Bikes: persons join vehicle, where car_or_bike = bike 
(and change the relevant colum names)
3. join the above view 1 and 2

The first problem is that the above approach is quiet slow.
Both starting tables (persons and vehicles are also views),
and maybe it would be faster to create (temporary) tables ?

The second problem is that in the real situation
I'm not converting 1 column  to 2 columns,
but it can be as large as 1 column to 10 columns.

btw I'm running SQLite from Python, so maybe I should do some data 
handling outside SQL (in Python) ?

Any suggestions to make it faster and /or more structural will be 
greatly appreciated.

thanks,
Stef Mientki


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to