09-25-2009 09:41 AM
Hello All
I am using the Database Connectivity Toolkit to create VI's for logging test results in an atomated test application.
My database consists of just two tables where I wish to setup a relationship between them.
(1) A "header" table where one new row is added each time a test sequence is run.
(2) A "results" table where a new row is written each time a step within a test sequence generates a test result.
So each time a test is run a single record is added to table "Header" but multiple rows are written to table "results"
When the database is queried at a later date I need to be able to tell which record(s) in "Results" are asscoiated with the single record in "Header". How is this association
setup using the VI's in the toolkit? I was told by someone that when a record is added to the header table this generates a unique reference ID that i could then store against each field in the results table. Is this a sensible solution, if so how do i get hold of this unique reference. Or is there another more elegant method of achieving this.
Thanks in anticipation for your help.
ATE Man
09-28-2009 09:11 AM
Hi ATE Man,
It sounds like you need to set a column in your Header table to be the primary key. This will mean that every entry in that specific column will be unique (if your Header table only has one column then that can be set as the primary key). If you then link the Header and Results table, the entries in the Results table can be assigned to the unique values of the primary key. Then you can query entries in the Result table by referring to the primary key.
The following link should give you a brief overview of how the primary key works.
http://www.tekstenuitleg.net/en/articles/software/database-design-tutorial/primary-key.html
In order to link the tables, you will have to call an SQL Query using the DB Tools Execute Query sub-VI included in the Database Connectivity Toolkit.
If you could post your code I will take a look at it to see what you are currently using and help you to implement any changes, such as setting the primary key and linking the tables.
Regards,
Jas.W