CREATE TABLE actions (id INTEGER PRIMARY KEY AUTOINCREMENT,itemid INTEGER, actiondate integer, description,invoiceinfo, isauto, entrydate integer);
CREATE TABLE agents  (id INTEGER PRIMARY KEY AUTOINCREMENT, type integer, title, contactinfo, contacts, urls);
CREATE TABLE contract2file(contractid integer,fileid integer);
CREATE TABLE contract2inv(invid integer,contractid integer);
CREATE TABLE contract2item(itemid integer,contractid integer);
CREATE TABLE contract2soft(softid integer,contractid integer);
CREATE TABLE contractevents(id integer primary key autoincrement,siblingid integer, contractid integer, startdate integer, enddate integer, description);
CREATE TABLE contracts(id integer primary key autoincrement, type integer, parentid integer, title, number, description, comments, totalcost, contractorid integer, startdate integer, currentenddate integer, renewals, subtype integer);
CREATE TABLE contractsubtypes(id INTEGER PRIMARY KEY AUTOINCREMENT,contypeid integer, name);
CREATE TABLE contracttypes(id INTEGER PRIMARY KEY AUTOINCREMENT, name);
CREATE TABLE files (id INTEGER PRIMARY KEY AUTOINCREMENT,type,title,fname, uploader, uploaddate, date integer);
CREATE TABLE filetypes (id INTEGER PRIMARY KEY AUTOINCREMENT, typedesc);
CREATE TABLE history (id INTEGER PRIMARY KEY AUTOINCREMENT, date integer, sql, authuser, ip);
CREATE TABLE invoice2file(invoiceid INTEGER,fileid INTEGER);
CREATE TABLE "invoices" ("id" INTEGER PRIMARY KEY ,"number" ,"date" integer,vendorid  integer,buyerid integer , description);
CREATE TABLE item2file(itemid INTEGER,fileid INTEGER);
CREATE TABLE "item2inv" (itemid integer,invid integer);
CREATE TABLE item2soft (itemid INTEGER, softid INTEGER, instdate INTEGER);
CREATE TABLE itemlink (itemid1, itemid2);
CREATE TABLE items (id INTEGER primary key autoincrement,itemtypeid integer, function, manufacturerid integer,model,sn,sn2,sn3,origin,warrantymonths integer,purchasedate integer,purchprice,dnsname,maintenanceinfo,comments,ispart integer,hd,cpu,ram,locationid integer,userid integer,ipv4,ipv6,usize integer,rackmountable integer,macs,remadmip,panelport,ports integer,switchport,switchid integer,rackid integer,rackposition integer,label,status integer, cpuno INTEGER, corespercpu INTEGER, rackposdepth integer, warrinfo);
CREATE TABLE itemtypes (id INTEGER PRIMARY KEY AUTOINCREMENT, typeid, typedesc, hassoftware integer);
CREATE TABLE labelpapers (id INTEGER PRIMARY KEY AUTOINCREMENT,rows integer, cols integer, lwidth real, lheight real,  vpitch real,  hpitch real,  tmargin real,  bmargin real,  lmargin real,  rmargin real, name);
CREATE TABLE locareas(id  INTEGER PRIMARY KEY AUTOINCREMENT,locationid number,areaname,x1 number,y1 number,x2 number,y2 number);
CREATE TABLE locations (id INTEGER PRIMARY KEY AUTOINCREMENT, name, floor, floorplanfn);
CREATE TABLE racks (id INTEGER PRIMARY KEY AUTOINCREMENT, locationid integer, usize integer, depth integer, comments,model,label, revnums integer);
CREATE TABLE soft2inv(invid integer,softid integer);
CREATE TABLE software (id INTEGER PRIMARY KEY autoincrement, invoiceid integer,slicenseinfo ,stype ,manufacturerid integer ,stitle ,sversion ,sinfo ,purchdate integer,licqty integer, lictype integer);
CREATE TABLE software2file(softwareid INTEGER,fileid INTEGER);
CREATE TABLE statustypes (id INTEGER PRIMARY KEY AUTOINCREMENT, statusdesc);
CREATE TABLE tag2item(itemid integer,tagid integer);
CREATE TABLE tag2software (softwareid integer,tagid integer);
CREATE TABLE tags  (id INTEGER PRIMARY KEY AUTOINCREMENT, name);
CREATE TABLE users (id INTEGER PRIMARY KEY AUTOINCREMENT, username, userdesc, pass,cookie1, usertype integer);
CREATE TABLE viewhist(id INTEGER PRIMARY KEY AUTOINCREMENT, url,description);
