I redesigned my database. Until today I had only one table, not normalized,
it was only to have something to play with. Now I made 4 tables out of it,
which are connected by id values. The main table is "Produkt_T", which
contains besides others a column "Marke_TId", that points to the table
"Marke_T".
So i have the "problem" of having to join queries (FYI: "marke" means
"brand", "marken" means "brands", "produkte" means "prodcts", "_T" means
"it's a table", "_VC" means "varchar"):
# Search for 'marke', which e.g. is "Faber"
marken = store.fetchObjectsOfClass('Marke_T', clauses="WHERE Name_VC LIKE
'%s%%'" % marke)
assert len(marken) == 1, "len(marken) == 1"
# Now we have a 'marke', where marke.serialNum() equals to 2
marke = marken[0] # Just to be sure...
print "Serial # =", marke.serialNum() # Prints the value '2'
# produkte = store.fetchObjectsOfClass('Produkt_T', clauses="WHERE
Marke_TId=%d" % marke.serialNum())
##### Does not work because Marke_TId in Produkt_T equals to
9328975928786727 or something like that
produkte = store.fetchObjectsOfClass('Produkt_T') # Not good, it yields
the *whole* table
# Now we *could* scan thru the 'produkte' and find the one with
# produkt.marke_TId().serialNum() == marke.serialNum()
Id's in "Produkt _T", e.g. "Marke_TIds" (which points to "Marke_T"), aren't
id's but references to objects, I guess.
So two questions arise:
1) How can I achieve what I intended to do?
2) How is Webware able to find and create the objects ref'ed by bigint's
like 897658726582765. I did not find them elsewere in the database.
Concerning (1): Or am I on the wrong way at all? If so, how would you do it?
Best regards
Franz
|