locked
DataSets and Relationships RRS feed

  • Question

  • I have a question for a DataSet expert.

    not sure how to do the following.

    I have a table (INSTRUCTIONS)that contains information about lines in a programming language source file.

    each line contains commands, operands, comments, lables, types of commands, special words, etc.

    I also have another table (COUNTS) which contains counts of types of commands per source file.

    I can cross refference the tables using the relationship from INSTRUCTIONS.TYPES OF COMMANDS to COUNTS.TYPES OF COMMANDS and reseting the datasource. when no COUNTS item is selected then the data source is the whole INSTRUCTION table, but when a COUNTS item is selected, I use the GETROWS method that the Dataset Designer provides as a matter of the Relationship being present. this works fine

    now comes a new requirement to provide the same functionality for the SPECIAL WORDS field int the INSTRUCTION table.

    can I have two different relationships from a single table to the same other table? and to make it worse the SpecialWords field can contain many Different Special words so I need to do a Contains on that Relationship, where as the other relationship was an equals relationship.

    any ideas how I can accomplish this?

     


    Peter G. Simmon
    Peter G. Simmon
    Monday, November 21, 2011 7:58 PM

Answers

  • BUT if there is a different set of requirements for the relationship then it will not work.

     

    Peter,

    This is why I think you will have to handle things outside of any established or pre-defined constraints that are on the DataTables.  Additionally, you may have to move away from building your DataSets with the designers, construct your own and programmatically handle the specific data processing requirements for the relationships you wish to define.

     


    James Crandall ~ http://javitechnologies.com Spatial Database Solutions
    • Marked as answer by PeterSimmon Tuesday, January 10, 2012 5:20 PM
    Friday, December 16, 2011 2:47 PM

All replies

  • Hi Peter,

    Welcome!

    >>I have a table (INSTRUCTIONS)that contains information about lines in a programming language source file.

    >>each line contains commands, operands, comments, lables, types of commands, special words, etc.

    I'm not sure about what's the "line" in your datatable, the relationship between two tables is based on the foriegn key, would you please feel free to clarify it, thanks for understanding.

    Have a nice day.

     


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, November 22, 2011 6:24 AM
  • alan, I am writing an application that collects Meta Data about Applications programs.

     

    every programming language has meta data about each line of code. 

    the rows in the data base are based on a line of code from a source file.

     to put it into c#.net terms

    say you analyse a class source file.

    each line will have a right side, an operand, and a left side, and possible comments

    but each right side could be a field, a method, or a literal.

    the key to the database would be the name of the class

    and a line number

    so as we look at each row in the DB we want to count all occurances of == operator.

    once we have counted all occurances we want to put into another table the class name

    and the number of occurances of ==.

    now imagin we want to count all of the different operators there are, -=, +=, =, <.... you get the picture

    now we have two data grid views.  one holds the rows from the Class Analsis DB and the other holds the counts

    table. 

    if you click on a row in the counts table, the rows in the Analsis table that are applicable are displayed.

    so each time you click on the counts row that has the == in it, only the rows in the Analsys table where the operand is "=="

    would be displayed.

    if my research is correct, and it may not be, the equal(object) method is used to determine if row from one table is = or related to a row in another table

    this is the purpose of the relationship.  while the standard version of the relationship is concerned with pkeys, it should be possible to override the equal(object) method and do my own determination, correct?

    now more specificly, based on a strongly typed object, the the equal(object) method is a member of the DGVColumn class.  that being the column that was clicked.

    i.e. you have two columns. sourcename and sourceoperand. both were created when a dataset was formed by the wizard.

    so I would need to override the equal(object) method for the Sourceoperand column class if that was the column that was clicked.

    along with that, the object that is passed would be a dgv counts row object, correct?

    but it is passed as an object, so can I do

    if (object is typeof(countsrowobject) {}

    will this work?

    and what if I need to count the number of time is see == in the operand and the number of times I see it in the comments, I could put a count row in for each different catagory, then is the equal(object) method I could see the column clicked and the value of the cell clicked. then I could based on the value of the clicked cell determine if the correct datarow cell held the value I needed.  and return the 0 or 1 that equals() is known for.

    does that sound like I am on the right track?


    Peter G. Simmon
    Tuesday, November 22, 2011 3:03 PM
  • alan,  is there not a way to override the way that a relationship works?

    i.e. objectA= objectB is the normal way it works

    where each object is a (table, a column, and a name space)

     

    what if I want to have the relationship work as

    objectA (contains) objectB

    in this case I would need to override the bool Equals(object) method in class objectA?  i think

    can you point me to some where this would be discussed please.


    Peter G. Simmon
    Thursday, December 15, 2011 12:02 AM
  • ....I use the GETROWS method that the Dataset Designer provides as a matter of the Relationship being present. this works fine

    any ideas how I can accomplish this?

     

    Your explanation is a bit confusing, but I think to accomplish what you want you are going to have to build your DataSets/Tables outside of those designer thingies and might even have to get away from any relationships established between the DataTables and simply programmatically manipulate things the way you need them to occur.


    James Crandall ~ http://javitechnologies.com Spatial Database Solutions
    Thursday, December 15, 2011 12:21 PM
  • let me see if I can discribe this more fully.

    yes you can use the GetChildRows method, and yes it works fine if and only if the relationship call for an exact match of the data in two different columns.

    BUT if there is a different set of requirements for the relationship then it will not work.

    and as we all know there is always a different set of requirements.

    But More To The Point,

    some one,a method,  has to determine that the two fields/columns/key are equal.  what I want to know is WHAT METHOD SHOULD I OVERRIDE to change the behavior of this determination.

    there is a person out there who knows this, there has to be, because there is code that does this determination. 

    I guess what I am asking for is a person, a book, a class on the internal's of DataSet Relationships. 

    Please help


    Peter G. Simmon
    Thursday, December 15, 2011 4:18 PM
  • BUT if there is a different set of requirements for the relationship then it will not work.

     

    Peter,

    This is why I think you will have to handle things outside of any established or pre-defined constraints that are on the DataTables.  Additionally, you may have to move away from building your DataSets with the designers, construct your own and programmatically handle the specific data processing requirements for the relationships you wish to define.

     


    James Crandall ~ http://javitechnologies.com Spatial Database Solutions
    • Marked as answer by PeterSimmon Tuesday, January 10, 2012 5:20 PM
    Friday, December 16, 2011 2:47 PM