Eine komplizierte Variante des alten Buch - Autor Problems.
Ein Buch hat 0,1 oder mehrere Autoren
Ein Autor hat 1 oder mehr Bücher
Suchstring soll sowohl in Buch wie Autor gefunden werden und Buch + Autor( evtl. leer) ausgegeben werden.
Das ganz soll noch auf SQLite3 auf einem Smartphone laufen, SQLite3 hat nicht alle SQL Funktionalität: SQL92 minus Right und Full Join, im wesentlichen.
Table book { bookid, title}
Table author {authorid, name}
Table bookauthorrelation {bookid, authorid}
Beispiel:
book
1 U-Bahn London (kein Autor)
2 Londoner Tagebuch
3 Der Holzfäller
4 Wolfsblut
5 Lockruf des Goldes
author
1 Bernd Meier
2 Jack London
3 Horst Esch
bookauthorrelation
2 1 (Buch 2 hat 2 Autoren)
2 3
3 3
4 2 (Autor 2 hat 2 Bücher)
5 2
Wenn ich nun nach "London" suche, möchte ich alle Bücher, bei denen London als Substring im Titel ODER Autor vorkommt, also
Book, author
U-Bahn London, (null)
Londoner Tagebuch, Bernd Meier (der erste der Autoren genügt)
Wolfsblut, Jack London
Lockruf des Goldes, Jack London
Wie kann ich das am einfachsten erreichen? Wenn möglich mit nur einem sql-statemnt, und ohne Erzeugung von temporären tables. SQLite kann einen left outer join.
Notfall auch mit 2 Selects, deren Ergebniss ich dann addieren müsste (aber ohne dabei Duplikate zu erzeugen, bite).
Für Ideen oder Tips schon mal Danke im voraus.
Ein Buch hat 0,1 oder mehrere Autoren
Ein Autor hat 1 oder mehr Bücher
Suchstring soll sowohl in Buch wie Autor gefunden werden und Buch + Autor( evtl. leer) ausgegeben werden.
Das ganz soll noch auf SQLite3 auf einem Smartphone laufen, SQLite3 hat nicht alle SQL Funktionalität: SQL92 minus Right und Full Join, im wesentlichen.
Table book { bookid, title}
Table author {authorid, name}
Table bookauthorrelation {bookid, authorid}
Beispiel:
book
1 U-Bahn London (kein Autor)
2 Londoner Tagebuch
3 Der Holzfäller
4 Wolfsblut
5 Lockruf des Goldes
author
1 Bernd Meier
2 Jack London
3 Horst Esch
bookauthorrelation
2 1 (Buch 2 hat 2 Autoren)
2 3
3 3
4 2 (Autor 2 hat 2 Bücher)
5 2
Wenn ich nun nach "London" suche, möchte ich alle Bücher, bei denen London als Substring im Titel ODER Autor vorkommt, also
Book, author
U-Bahn London, (null)
Londoner Tagebuch, Bernd Meier (der erste der Autoren genügt)
Wolfsblut, Jack London
Lockruf des Goldes, Jack London
Wie kann ich das am einfachsten erreichen? Wenn möglich mit nur einem sql-statemnt, und ohne Erzeugung von temporären tables. SQLite kann einen left outer join.
Notfall auch mit 2 Selects, deren Ergebniss ich dann addieren müsste (aber ohne dabei Duplikate zu erzeugen, bite).
Für Ideen oder Tips schon mal Danke im voraus.
Comment