RJLRef; $PH/06f523/asgnt3/asgnt3KeyExistsFdbk2am061106.txt > From alison_lea@yahoo.com Sun Nov 5 08:59:59 2006 > From: Alison Miles > Subject: Re: keyExists_cg_rl061103.txt in $PH/06f522/asgnt3: > To: Bob Lechner > Cc: cguffey@gmail.com, agabriel@cs.uml.edu, nitin_sonawane@verizon.net, > kbagley@us.ibm.com > > These aren't the REAL comments, which I didn't get to > as we didn't get to the last hotel until 2:30 this > morning. Here are the preliminary ones though, mostly > in the form of questions. > > --- Bob Lechner wrote: > > > > >>>>>>>>>>>>>>>>>>>>>>>>> > > bool keyValueListExists(char* tableType, /* a > > TTabbrev */ > > char* CKname, /* a CK > > name */ > > char* valueList) /* list of > > CK-field values */ > > > > RJL: NoNo. I have said this over and over: What is > > not understood? names are not values. > > CK only declares the NAMES of fields (or table > > columns) to be matched. > > The table with ttabbrev tableType (NOT table type > > CK) must be searched, > > for a candidate key VALUE which is a list of field > > values. Field names translate to > > table columns. Not all fields are tested - only > > those that are fname components of CK. > > OK, so... > > tableType's something like "TT", "CA", etc. RJL: tableType must match the ttabb field value in some TTrow and schema table. > > CKname is a string containing one or more fields > within > that particular tableType to be searched. > RJL: READ THE CK table definition: CKname is a field type c## (no whitespace); it must be the NAME of a candidate key (simple or composite). > valueList is a string containing one or more values > for the CKnames (number of tokens in that string > should match). RJL: NO: table CK has an int which counts CKey compoments (1 to 4 in Nitin's examples). The values are for FIELDS not CKnames. That's why I called them fvalue1, fvalue2, etc. The field NAMES are specified in the TA-rows referenced in the CA-children of CK not in Ck itself. (draw your own ERDiagram for tables TT TA CK and CA in metaschemaCK.sch (include fieldnames inside entity boxes). > > Like: Table's "CA", CKname could be "TAid CKid" and > valueList could be "TA103212 CK310203"? This isn't > what we'd want to do for this case of course, but is > that the idea? RJL: I have to say no - your example is much too inconsistent with the reality of the data model. Fields can NOT have whitgespace inside (except CQ's valuelist which is the last field, of type t## holding a list of words containing QSCII values. (Similarly the raw input to specify CK--->CA could have included a list of field NAMES in its last field. But this would be a different table than CK in our schema.) > > > > Table CK does NOT have a list of field values. Each > > CandidatekeyQuery (CQrow to me) > > IS such a list of values, for the fields NAMED in > > CK, a key spec for table type tableType; > > [Generalization: fields may actually be in ancestors > > or superclasses of table tableType.] > > > > ------------------------ > > > > > Why do you expect fnames in table CK? They are in > > CA-children of CK. > > You MUST have file metaschemaCK.sch in front of you > > when coding, Only its fnames > > (or pointers derived from fkeys) are legal in each > > table. > > { > > if (0 == strcmp(CKname, CKcurr->fname)) > > { > > nCKFound = true; ////RJL Why 'n' ? > > break; > > } > > } > > if (false == CKFound) return false; > > > > OK, so a child_loop on the CA children of the CK table > table is appropriate to strcmp the fnames? > RJL: Yes, iff you strcmp to CAcurr->TAid_pp->fname (or ftype, which determiknes if type conversion is required from ASCII char* to int or hcg_key). > > > /* find the TT row, my understanding is that > > pr_find has some hidden functionality, > > in that it populates a global variable with a > > pointer to the TT row if found NULL if not found > > ////RJL: That is correct! READ the chgen UserManual > > section on pr_find. > > //// TTid is an encoded pkey - an unsigned int! > > tableType is TTcurr->ttabbr NOT TTid. > > //// I don't know where you got the nTTid and nTAid > > below.??? > > ///RJL: pr_find(TT,...) updates TTcurr as an > > intended side effect. > > > > pr_find(TT, TTid, tableType); > > if (0 == TTcurr) return false; > > > > /* parse value list somehow */ > > /* the ck and tt ids need to be encoded before > > being passed into child_loop */ > > > > ////RJL: Why CK above and TA below???? > > int nTTid; > > int nTAid; > > encode(TTcurr->TTid, &nTTid); > > encode(TTcurr->TAid_pp->TAid, &nTAid); > > > > ////RJL: TA is NOT the parent of TT, so TT does NOT > > have TAid_pp inside. (Undeclared fieldname) > > ////Again. look at the .sch file (or metaschemaCK.h > > if you need it to remember the derived ptr fields) > > OK, TTcurr->TAid_fcp to access the first TA of table > TT. We can encode its key and do a child_loop to walk > all of them. RJL: Do a child_loop which starts from TAid_fcp. I don't know what you mean by 'encode its key' - YOu need to be more specific. > > Yahoo mail truncated the rest of the quoted e-mail so > I'll do those comments in installment #2. Will also, > pending comments, give the code a crack tonight since > Chris has done so much work on it. > > -Alison >