Matricsoft - software development | |||||||||||||
news - products - downloads - support / feedback | |||||||||||||
products > Quickdb > table creation | |||||||||||||
|
Table creationclass db { void new_table(); int add_field(string const & field_name, EType field_type); int add_field_ref(string const & field_name, string const & table_name); int commit_table(string const & table_name); } Samplemydb.new_table(); mydb.add_field("name", db_string); mydb.add_field("sector", db_string); mydb.commit_table("company"); mydb.new_table(); mydb.add_field("name", db_string); mydb.add_field("surname", db_string); mydb.add_field("age", db_int); mydb.add_field_ref("IDcompany", "company"); mydb.commit_table("employee"); void new_table()This method prepares a new table for the database. mydb.new_table(); Result: you can now set the definitions of the fields of the table. int add_field(string const & field_name, EType field_type)This method creates a new field in the table, with a given name and a given type. mydb.add_field("name", db_string); mydb.add_field("surname", db_string); mydb.add_field("age", db_int); Result: your field are defined, but the definition will not be definitive until you commit the table. int add_field_ref(string const & field_name, string const & table_name)This method creates a field of a special type: db_ref. //supposing that a table "company" has already been defined //supposing that you are creating the "employee" table: mydb.add_field("IDcompany", "company"); Result: this field represents now an index in the foreign table. int commit_table(string const & table_name)This method takes the table definition, makes some optimisations, and save the new table in the database. mydb.commit_table("employee"); Result: your database has been commited. The return value is the index of the table (you can now access this table as "employee" or as 0 (if it is the first table created). |
||||||||||||
Copyright (c) 2001-2002 Matricsoft info@matricsoft.com |