(1) By anonymous on 2021-12-03 18:13:02 [link] [source]
Hi everyone, can anybody help me with SQLite testing. How can I test following init function:
def init(self, dbLast):
try: self.conn = sqlite3.connect(dbLast) except sqlite3.DataError as err: if err.args.startswith('no such table'): exists = False else: raise self.cur = self.conn.cursor() # Conn = connection, cursor is used to execute queries
Create a table for the database:
self.cur.execute("""CREATE TABLE IF NOT EXISTS lastenheft (LastId INTEGER PRIMARY KEY ASC AUTOINCREMENT, LastName TEXT, UId INTEGER, ZielId INTEGER, IstId Integer, sysAnfordId INTEGER, EinfAnfId INTEGER, RahmenId INTEGER, AnsprechId INTEGER, FOREIGN KEY(UId) REFERENCES unternehmen(UId), FOREIGN KEY(UId) REFERENCES ziel(ZielId), FOREIGN KEY(UId) REFERENCES istZustand(IstId), FOREIGN KEY(UId) REFERENCES sysAnforderung(sysAnfordId), FOREIGN KEY(UId) REFERENCES einfAnforderung(EinfAnfId), FOREIGN KEY(UId) REFERENCES rahmenbedingung(RahmenId), FOREIGN KEY(UId) REFERENCES ansprechpartner(AnsprechId))""")
(2) By Keith Medcalf (kmedcalf) on 2021-12-03 20:43:42 in reply to 1 [link] [source]
You could just execute it. However, it will not work (neither as intended nor as designed nor as built).
FIrstly, the parent key of a foreign-key relationship must be unique.
Secondly, the child record cannot reference multiple parents.
The parent:child relationship must be 1:N and cannot be N:1.
While a CODASYL database (in particular, a Network Extended CODASYL database) permits a "child" to have mnore than one "parent" (ie, the parent instance can be a set), such extensions do not apply to either hierarchical databases nor to relational databases.
This has been the state of affairs since about 1956 ...
(3) By J-L Hainaut (JLHainaut) on 2021-12-05 11:09:41 in reply to 2 [source]
N:N: You are probably referring to "MDBS III"? I don't know of any others.
(4) By Keith Medcalf (kmedcalf) on 2021-12-06 02:04:02 in reply to 3 [link] [source]
On bitty-boxen, MDBS and dbVista both implement(ed) CODASYL Network Extended databases. EDMS (Xerox program product running under CP-V -- in this case on a Sigma 7) also provides CODASYL Network Extended database organization. There are others.
Relational or Pure Hierarchical (ie, IMS) need to use a "linkage table" to model N:M relationships.