diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..a844758 --- /dev/null +++ b/Readme.md @@ -0,0 +1,76 @@ +# Binary Database + +This is a complete database library made for (Principal of Programming course in University of Shiraz) + +## How to use it +* first create a `Context` object +* open/create database +* execute commands with `ctx.exec` to control your data +* read result of each command at `context.res()` and access to result data on `context.rows()` +* at last its better to `close` the context, also `clean` context after you're done with its result + +## Commands +1. `Select(, , )` OR `Select(, , )` + * select some `DataRow`s from table and read their requested columns that matched in requested Query + * you can + * `` name of target table bare or wrapped in `"` or `'` or ` (**str-format**) + * `` list of column names styled like above and wrapped in `[ ... ]` to load these columns on each result rows, if not provided: all columns of table will be loaded, if you just want `Row` without their data, just pass an empty list (`[]`) + * `` if provided, limits the resulting rows to match the required *Query* +2. Comparators Commands: `(col, data)` + * use bellow functions in `` to preform compare Queries + * `EQ` as equals, `NEQ` and `NE` as not-equals + * `GT` as greater-than, `GE` as greater-than-or-equals + * `LT` as less-than, `LE` as less-than-or-equals + * `NGT` is `LE` , `NGE` is `LT` , `NLT` is `GE` , `NLE` is `GT` + * `In( , )` check value in `` (**lst-format** required) +3. Logical Commands: + * `NOT( )` inverse the result returned by query inside + * `AND( , , ... )` join all query results and return results presented on all queries + * `OR( , , ... )` merge all query results and return results presented at least on one query +4. Table Commands: + * `CreateTable( , {, ...} )` + * create a table named `` with columns with requested type. columns must send in **set-format** `{ ... }` each follows `:` format. + * `DeleteTable( )` Delete table `` from database +5. Data Commands: + - `Insert( , { }, { }, ...)` + - insert data into `
` each data represented by its `` argument (**set-format** is required). + - each `` contains set of `=` to assign data to each data cell + - `` type must match `` type + - `Update(
, { }, )` + - update all rows matched in `` with `` parameter + - every parameter matches exactly like other functions described above + - `Remove(
, )` + - Remove all rows in `table` matches in `query` + +## Data Type +There is 4 dataType implemented in this Database: +1. `Byte` or`Char` and their arrays `Byte[fixed]`, `Char[fixed]` +2. `Int` and `Int[fixed]` hold any Integers +3. `Real` and `Real[fixed]` holds all Double/Float numbers +4. `Text` variable size string without any restrictions +5. In later versions other types than Text, may able to have Variable-Size array + +## VarArgs +You can call `exec` to run requested actions, also you can pass list of `varargs` to fill in the gaps. +* VarArgs Gap Style `${:}`: + * `` is optional and if its not provided every gap gets its own index start from 1 and continues. + * `` follows like any DataType parameter rules mentioned above. + +## Formats +1. String Format: `" ... "`, `' ... '` +2. List Format: `[ ..., ... ]` +3. Set Format: `[ ..., ... ]` +4. Function Format: `( ..., ... )` +4. Parenthesis Format: `( ... )` +4. VarArgs Format: `${:}` + +## Example +``` +CREATETABLE(students, id:int, name:text, grade:real, year:byte) +InserT(students, {id=1}, {id=2}, {id=3}) +uPDATE(students, {id=10}, eq(id, 2)) +select(students,[year]) +SELECT(students,eq(year,255) +Select(students,and( neq(year,94) , neq(id,1374) )) + +```