windows9download

You Here : Home > Linux

ZDB 0.1

OS Support:


Publisher

Publisher Old version

Update:

July 5 2011

Download:

ZDB 0.1


Description

ZDB (Zazzybob.com DataBase) can be used to maintain simple lists and databases (such as telephone directories, address lists, etc). The project implements mechanisms for basic queries and reporting, and also allows us to join two tables by a primary key, and display query results based thereon.ZDB is not a relational database. If you want a relational DB then use a proper DBMS!ZDB is, however, highly useful for small, non-critical database needs, especially where "flat-files" are all that's really required, but where maintaining a long list of data manually would be too labour intensive.ZDB requires the "usual-suspects" with regards to tool dependencies. All of the required tools will be present in any modern UNIX/Linux system. The scripts are implemented as bash scripts, but if you change the shebang line to match the path to your shell, and as long as your shell supports the ((...)) arithmetic construct, you'll be okay! There aren't any bash-specifics in the scripts.Some of the scripts (especially query scripts) may run fairly slowly depending on your system. There is a lot of data processing going on in the background (involving many invocations of awk!). On a P4 2.66GHz the results will be instantaneous, whereas on a PII 233MHz you might not be so lucky.Package ContentsThe ZDB package consists of the following scripts: zdb_constantsContains constants needed by all scriptszdb_create_tableCreates a new tablezdb_insert_valuesInsert values into a tablezdb_join_tablesQuery two tables using a joinzdb_remove_tableDrop a tablezdb_remove_valuesRemove values from a tablezdb_select_allDisplay an entire tablezdb_select_rowsQuery a table by rowzdb_select_valuesQuery a table by column namezdb_get_by_keyGet a single row by it's key valueAlso included in the download is zdb_test which is an example showing how each of the commands is used, creating tables, inserting values, querying the tables, and finally deleting the tables. As you can see, I haven't implemented a "change row" script. I don't see the point, as it would just duplicate the functionality of a call to zdb_remove_values followed by a call to zdb_insert_values. I have shown an example of this in the zdb_test script, included with the download. Overview of Data StructureEach table is made of two parts. A .def (Definition) file, and a .dat (Data) file. The .def file is created when the table is first created, and contains a list of all the column names in that table, and thus, provides that tables definition. The .dat file is created when the first row of values is inserted (and is deleted when the last row of data is removed). This is a flat file using ":" as a column delimeter. Therefore, do NOT use ":" in any of your data! The idea of the .def file is to provide column name to field position translation, so that we can query in the form column_name=value (kind of like a WHERE clause in SQL). They are saved as table_name.{dat,def} in the directory specified by the ZDB_DIR constant (see below). The first (left-most) column in each table is considered to be it's key and must be unique for each row in the table. SyntaxThe syntax of each command is discussed below. zdb_constants SyntaxN/AIn the current implementation, this script contains only one constant, ZDB_DIR, which is the full path to the directory containing your database (.dat/.def) files. It is important that the directory exists, and that this constant is set correctly to reference the directories path, otherwise nothing will work! ExampleZDB_DIR=/home/kevin/databases/db_onezdb_create_table Syntaxzdb_create_table table_name col_1 [ col_2 ... col_n ] Create a table within ZDB_DIR named table_name as specified by the first argument to the command. The column names are specified by subsequent arguments to the command. At least one column must be specified. This command creates a file in ZDB_DIR named table_name.def. Examplezdb_create_table my_table id f_name s_name t_namezdb_insert_values Syntaxzdb_insert_values table_name val_1 [ val_2 ... val_n ] Insert values specified by val_1, etc, into table_name. This has various error checking mechanisms implemented, and will check for the correct number of values (i.e. the same number of values as there are columns in the table). val_1 in the left-most column is considered to be a primary key for that row of data, and must be unique within that table. Values are added sequentially, and are thus "appended" to the table in the order that they are added. No sorting takes place. If any single value contains spaces, it must be quoted, e.g. "example value with spaces". Examplezdb_insert_values my_table 1 Kevin Waldron 0208-111-1111zdb_join_tables Syntaxzdb_join_tables table_one table_two [ searchterm | col=searchterm ] Join two tables by their key field, and print fields from both tables where the row key matches. Other rows are not printed. An optional searchterm can be specified. This searchterm MUST be a single word, and can be of the form "searchterm" where all fields are searched, or "col=searchterm" whereby only the specified column name "col" is searched. ExampleSuppose we have two tables populated with data, the following session depicts command usage and possible output$ zdb_join_tables my_info my_table name=Kevin id name number data_1 data_21 Kevin Smith 02081111234 zdb_data more_data2 Kevin Jones 02078392111 data_value more_data68 Mr Kevin 9230192912 0291 19192 zdb_remove_table Syntaxzdb_remove_table table_name If table_name exists, both it's .def and .dat files will be deleted. Examplezdb_remove_table my_tablezdb_remove_values Syntaxzdb_remove_values table_name key Removes the row from table_name specified by key, where key is the unique identifier for that row (the entry in the first column of the table for that row). ExampleTo remove the row with key "4" from my_table zdb_remove_values my_table 4zdb_select_all Syntaxzdb_select_all table_name Displays all data from table_name preceeded by a header row detailing the column names Examplezdb_select_all my_tablezdb_select_rows Syntaxzdb_select_rows table_name searchterm|col=searchterm Shows all rows from table_name where searchterm can be found. Accepts both forms of searchterm specification, as discussed in the zdb_join_tables section above. Examplezdb_select_rows my_table Kevinzdb_select_values Syntaxzdb_select_values table_name col_1 [ col_2 ... col_n ] Selects and displays all data from the specified columns in table_name ExampleYes, multiple instances of the same column can be specified, to repeat their output zdb_select_values my_table f_name f_name s_namezdb_get_by_key Syntaxzdb_get_by_key table_name key Select only the single row from table_name that has the unique key key. Examplezdb_get_by_key my_table 1


Related Downloads


  • OzDB 0.02
  • OzDB is a database interface module for Perl OzBot. OzDB is a database interface module for Perl OzBot.SYNOPSISuse OzDB; OzDB Perl module manages authentication and access control based OzBot spam bots utility. The basic format of data is the...

    Software Tags

    Zdb | Zdb 0.1 | Zdb Free Download | Zdb Reviews | Download Zdb

    Size :

    Next/Pre