void AddDBCasesToCaseset_cs ( caseset_cs*  cases,   dbmgr_cs*  dbmgr,   double  degree,   const nodelist_bn*  nodes,   const char*  column_names,   const char*  tables,   const char*  condition,   const char*  options )

Searches the database attached to dbmgr for cases to add to cases.

The cases are retrieved from the database by invoking the SQL1 SELECT statement:

    SELECT column_names FROM tables WHERE condition.

degree indicates how each case that is retrieved should be weighted. See ReviseCPTsByFindings_bn for more information about the relative weighting of cases.

nodes represents the nodes whose values will be selected. It must not be NULL, and must contain at least one node.

column_names is a comma-delimited list of database column names. The names in this list must be in the exact same order as their corresponding nodes in nodes. If column_names is NULL, then for each Node, Netica will use that Node's title (or, if title not defined, then the name) as the corresponding column name. If you are selecting columns from different tables, then you cannot use the NULL option just mentioned, and you must also prefix the column names with the table name followed by a period, as per the standard SQL syntax.

tables is a comma-delimited list of database table names. If the database has only one conventional (non-system) table, then you can submit NULL for this parameter and Netica will find the implied table for you.

condition is the text following the "WHERE" clause. It may be NULL.

Pass NULL for options; it is only for future expansion.

Thus, for the SQL command   SELECT col1,col2,...,colN FROM table1 WHERE surname="smith", tables should be "table1"; column_names should be "col1,col2,...,colN"; nodes should be a list of nodes in the order node1, node2, ..., nodeN; and condition should be "surname=\"smith\"".

If there is a problem with the SQL SELECT command, a Netica error will be generated explaining the nature of the problem.

NOTICE:After calling this, you should not modify the database until you are done with the caseset_cs.

TEMPORARY LIMITATION: Currently you can only add one file or database retrieval to a caseset.

1 SQL is a standard query language for accessing databases. To properly use this function, you should have basic familiarity with the SQL SELECT statement.

Version:

Versions 3.15 and later have this function.

See also:

NewDBManager_cs    Creates the dbmgr_cs
NewCaseset_cs    Create an empty caseset_cs
AddFileToCaseset_cs    Add cases from text file instead of database

Example:

Here is an example program to use EM learning to learn Bayes net parameters
from a database:
dbmgr_cs *dbmgr = NewDBManager_cs (
     "driver=Microsoft Access Driver (*.mdb); dbq=.\\myDB.mdb; UID=dba1;", 
     "pooling", env);
caseset_cs* cases = NewCaseset_cs ("TestDBCases", env);
AddDBCasesToCaseset_cs (cases, 
                        dbmgr, 
                        1.0,
                        NULL,
                        "Gender, Height, OwnsHouse, NumDogs"
                        "gender, height, \"Owns a house\", \"Number of dogs\"",    
                        "'Owns a house' = 'yes'",
                        NULL);
net_bn*  net = NewNet_bn ("TestDB", env);
// ... Put code here to add nodes and links to net ...
const nodelist_bn* nodes = GetNetNodes_bn (net);
learner_bn* learner = NewLearner_bn (EM_LEARNING, NULL, env); 
LearnCPTs_bn (learner, nodes, cases, 1.0); 
DeleteLearner_bn (learner);
DeleteCaseset_cs (cases);
DeleteDBManager_cs (dbmgr);