CREATE TABLE Actions(
	ID SERIAL PRIMARY KEY,
	NeedPause INTEGER NULL,
	NeedCancel INTEGER NULL,
	NeedSave INTEGER NULL,
	NeedAccount INTEGER NULL,
	NeedPinCode VARCHAR(32) NULL,
	NeedReport TEXT NULL,
	NeedReportLastUsage TIMESTAMP NULL
);
CREATE TABLE Quota(
	ID SERIAL PRIMARY KEY,
	MaxCost FLOAT NULL,
	MaxPages INTEGER NULL,
	Period INTEGER NULL,
	Budget FLOAT NULL,
	IncreasePeriod INTEGER NULL,
	IncreaseAmount FLOAT NULL,
	LastIncreaseDate TIMESTAMP NULL,
	RestrictedKeywords VARCHAR(255) NULL,
	ActionID INTEGER NULL,
	BudgetLimit FLOAT NULL,
	FOREIGN KEY(ActionID) REFERENCES Actions(ID)
);
CREATE TABLE DateNumbers(
	DateNumber INTEGER NOT NULL,
	AbbrevDayName VARCHAR(255) NULL,
	AbbrevMonthName VARCHAR(255) NULL
);
CREATE INDEX IDX_DateNumber ON DateNumbers 
(
	DateNumber ASC
);
CREATE TABLE Applications(
	ID SERIAL PRIMARY KEY,
	AppName VARCHAR(255) NOT NULL,
	Icon BYTEA NULL
);
CREATE UNIQUE INDEX IX_Applications ON Applications 
(
	AppName ASC
);
CREATE TABLE Computers(
	ID SERIAL PRIMARY KEY,
	CompName VARCHAR(64) NOT NULL
);
CREATE UNIQUE INDEX IX_Computers ON Computers 
(
	CompName ASC
);
CREATE TABLE PaperGroup(
	ID SERIAL PRIMARY KEY,
	GroupName VARCHAR(64) NOT NULL
);
CREATE UNIQUE INDEX IX_PaperGroup ON PaperGroup 
(
	GroupName ASC
);
CREATE TABLE Projects(
	ID SERIAL PRIMARY KEY,
	ProjName VARCHAR(255) NOT NULL
);
CREATE TABLE Servers(
	ID SERIAL PRIMARY KEY,
	SrvName VARCHAR(64) NOT NULL,
	Installed INTEGER NOT NULL DEFAULT 0,
	QuotaID INTEGER NULL,
	ActionID INTEGER NULL,
	Master INTEGER NULL DEFAULT 0,
	LastAlive TIMESTAMP NULL,
	PollingURL VARCHAR(255) NULL,
	PollingInterval INT NOT NULL DEFAULT 0,
	ServerURL VARCHAR(255) NULL,
	ExtractJobData INT NOT NULL DEFAULT 0,
	FOREIGN KEY(QuotaID) REFERENCES Quota(ID),
	FOREIGN KEY(ActionID) REFERENCES Actions(ID)
);
CREATE UNIQUE INDEX IX_Servers ON Servers 
(
	SrvName ASC
);
CREATE TABLE Groups(
	ID SERIAL PRIMARY KEY,
	GroupName VARCHAR(255) NOT NULL,
	QuotaID INTEGER NULL,
	Description VARCHAR(255) NULL,
	ActionID INTEGER NULL,
	GroupType INTEGER DEFAULT 0,
	FOREIGN KEY(QuotaID) REFERENCES Quota(ID),
	FOREIGN KEY(ActionID) REFERENCES Actions(ID)
);
CREATE UNIQUE INDEX IX_Groups ON Groups 
(
	GroupName ASC
);
INSERT INTO Groups(GroupName,GroupType) VALUES('Default',1);
CREATE TABLE Printers(
	ID SERIAL PRIMARY KEY,
	PrnName VARCHAR(255) NOT NULL,
	BaseCost FLOAT NULL,
	MonoCost FLOAT NULL,
	DuplexCost FLOAT NULL,
	Enabled INTEGER NOT NULL DEFAULT 0,
	OldAttributes INTEGER NULL,
	JobLanguage INTEGER NULL,
	ServerID INTEGER NOT NULL,
	QuotaID INTEGER NULL,
	OldSD TEXT NULL,
	IpAddress VARCHAR(32) NULL,
	ActionID INTEGER NULL,
	PrnComment VARCHAR(255) NULL,
	PrnLocation VARCHAR(255) NULL,
	Status INTEGER NULL,
	UpTIMESTAMPstamp INTEGER NOT NULL DEFAULT 0,
	UseKeepPrintedJobs INTEGER NULL,
	FOREIGN KEY(ServerID) REFERENCES Servers(ID),
	FOREIGN KEY(QuotaID) REFERENCES Quota(ID),
	FOREIGN KEY(ActionID) REFERENCES Actions(ID)
);
CREATE UNIQUE INDEX IX_Printers ON Printers 
(
	ServerID ASC,
	PrnName ASC
);
CREATE TABLE Users(
	ID SERIAL PRIMARY KEY,
	UserName VARCHAR(255) NOT NULL,
	FullName VARCHAR(255) NULL,
	QuotaID INTEGER NULL,
	GroupID INTEGER DEFAULT 1,
	ActionID INTEGER NULL,
	FOREIGN KEY(QuotaID) REFERENCES Quota(ID),
	FOREIGN KEY(GroupID) REFERENCES Groups(ID),
	FOREIGN KEY(ActionID) REFERENCES Actions(ID)
);
CREATE UNIQUE INDEX IX_Users ON Users 
(
	UserName ASC
);
CREATE TABLE Accounts(ID SERIAL PRIMARY KEY, ActionID INT NULL, QuotaID INT NULL, NeedAccount INT NULL, Description VARCHAR(255) NULL, Enabled INTEGER NOT NULL DEFAULT 1, AccountName VARCHAR(255), FOREIGN KEY(ActionID) REFERENCES Actions(ID), FOREIGN KEY(QuotaID) REFERENCES Quota(ID));
CREATE TABLE PRNDATA(
	ID SERIAL PRIMARY KEY,
	PrinterID INTEGER NOT NULL,
	UserID INTEGER NOT NULL,
	ComputerID INTEGER NOT NULL,
	DocName VARCHAR(255) NULL,
	Pages INTEGER NULL,
	JobSize BIGINT NULL,
	SubmitDate TIMESTAMP NULL,
	PaperSize INTEGER NULL,
	Color INTEGER NULL,
	Duplex INTEGER NULL,
	Copies INTEGER NULL,
	Cost FLOAT NULL,
	ProjectID INTEGER NULL,
	ApplicationID INTEGER NULL,
	JobData BYTEA NULL,
	LanguageType INTEGER NULL,
	JobDataSize BIGINT NULL,
	AccountID INTEGER NULL,
	LocalFile VARCHAR(255) NULL,
	CompleteDate TIMESTAMP NULL,
	FOREIGN KEY(PrinterID) REFERENCES Printers(ID),
	FOREIGN KEY(UserID) REFERENCES Users(ID),
	FOREIGN KEY(ComputerID) REFERENCES Computers(ID),
	FOREIGN KEY(ProjectID) REFERENCES Projects(ID),
	FOREIGN KEY(ApplicationID) REFERENCES Applications(ID),
	FOREIGN KEY(AccountID) REFERENCES Accounts(ID)
);
CREATE INDEX SubmitDate ON PRNDATA 
(
	SubmitDate ASC
);
CREATE INDEX IX_PRNDATA_ComputerID ON PRNDATA 
(
	ComputerID ASC
);
CREATE INDEX IX_PRNDATA_PrinterID ON PRNDATA 
(
	PrinterID ASC
);
CREATE INDEX IX_PRNDATA_UserID ON PRNDATA 
(
	UserID ASC
);
CREATE TABLE PaperSize(
	ID INTEGER NOT NULL,
	PaperName VARCHAR(64) NOT NULL,
	PaperGroupID INTEGER NULL,
	FOREIGN KEY(PaperGroupID) REFERENCES PaperGroup(ID)
);
CREATE UNIQUE INDEX IX_PaperSize ON PaperSize 
(
	PaperName ASC
);
CREATE TABLE PaperCost(
	PrinterID INTEGER NOT NULL,
	PaperGroupID INTEGER NOT NULL,
	GroupCost FLOAT NOT NULL,
	PRIMARY KEY
	(
		PrinterID,
		PaperGroupID
	),
	FOREIGN KEY(PrinterID) REFERENCES Printers(ID),
	FOREIGN KEY(PaperGroupID) REFERENCES PaperGroup(ID)
);
INSERT INTO PaperGroup(ID,GroupName) VALUES (1,'LARGE');
INSERT INTO PaperGroup(ID,GroupName) VALUES (2,'VERY LARGE');
INSERT INTO PaperGroup(ID,GroupName) VALUES (3,'EXTRA LARGE');
INSERT INTO PaperSize VALUES (1,'Letter 8 1/2 x 11 in',null);
INSERT INTO PaperSize VALUES (2,'Letter Small 8 1/2 x 11 in',null);
INSERT INTO PaperSize VALUES (3,'Tabloid 11 x 17 in',1);
INSERT INTO PaperSize VALUES (4,'Ledger 17 x 11 in',1);
INSERT INTO PaperSize VALUES (5,'Legal 8 1/2 x 14 in',null);
INSERT INTO PaperSize VALUES (6,'Statement 5 1/2 x 8 1/2 in',null);
INSERT INTO PaperSize VALUES (7,'Executive 7 1/4 x 10 1/2 in',null);
INSERT INTO PaperSize VALUES (8,'A3 297 x 420 mm',1);
INSERT INTO PaperSize VALUES (9,'A4 210 x 297 mm',null);
INSERT INTO PaperSize VALUES (10,'A4 Small 210 x 297 mm',null);
INSERT INTO PaperSize VALUES (11,'A5 148 x 210 mm',null);
INSERT INTO PaperSize VALUES (12,'B4 (JIS) 250 x 354',1);
INSERT INTO PaperSize VALUES (13,'B5 (JIS) 182 x 257 mm',null);
INSERT INTO PaperSize VALUES (14,'Folio 8 1/2 x 13 in',null);
INSERT INTO PaperSize VALUES (15,'Quarto 215 x 275 mm',null);
INSERT INTO PaperSize VALUES (16,'10x14 in',1);
INSERT INTO PaperSize VALUES (17,'11x17 in',1);
INSERT INTO PaperSize VALUES (18,'Note 8 1/2 x 11 in',null);
INSERT INTO PaperSize VALUES (19,'Envelope #9 3 7/8 x 8 7/8',null);
INSERT INTO PaperSize VALUES (20,'Envelope #10 4 1/8 x 9 1/2',null);
INSERT INTO PaperSize VALUES (21,'Envelope #11 4 1/2 x 10 3/8',null);
INSERT INTO PaperSize VALUES (22,'Envelope #12 4 ¾ x 11',null);
INSERT INTO PaperSize VALUES (23,'Envelope #14 5 x 11 1/2',null);
INSERT INTO PaperSize VALUES (24,'C size sheet',2);
INSERT INTO PaperSize VALUES (25,'D size sheet',3);
INSERT INTO PaperSize VALUES (26,'E size sheet',3);
INSERT INTO PaperSize VALUES (27,'Envelope DL 110 x 220 mm',null);
INSERT INTO PaperSize VALUES (28,'Envelope C5 162 x 229 mm',null);
INSERT INTO PaperSize VALUES (29,'Envelope C3  324 x 458 mm',null);
INSERT INTO PaperSize VALUES (30,'Envelope C4  229 x 324 mm',null);
INSERT INTO PaperSize VALUES (31,'Envelope C6  114 x 162 mm',null);
INSERT INTO PaperSize VALUES (32,'Envelope C65 114 x 229 mm',null);
INSERT INTO PaperSize VALUES (33,'Envelope B4  250 x 353 mm',null);
INSERT INTO PaperSize VALUES (34,'Envelope B5  176 x 250 mm',null);
INSERT INTO PaperSize VALUES (35,'Envelope B6  176 x 125 mm',null);
INSERT INTO PaperSize VALUES (36,'Envelope 110 x 230 mm',null);
INSERT INTO PaperSize VALUES (37,'Envelope Monarch 3.875 x 7.5 in',null);
INSERT INTO PaperSize VALUES (38,'6 3/4 Envelope 3 5/8 x 6 1/2 in',null);
INSERT INTO PaperSize VALUES (39,'US Std Fanfold 14 7/8 x 11 in',null);
INSERT INTO PaperSize VALUES (40,'German Std Fanfold 8 1/2 x 12 in',null);
INSERT INTO PaperSize VALUES (41,'German Legal Fanfold 8 1/2 x 13 in',null);
INSERT INTO PaperSize VALUES (42,'B4 (ISO) 250 x 353 mm',1);
INSERT INTO PaperSize VALUES (43,'Japanese Postcard 100 x 148 mm',null);
INSERT INTO PaperSize VALUES (44,'9 x 11 in',null);
INSERT INTO PaperSize VALUES (45,'10 x 11 in',1);
INSERT INTO PaperSize VALUES (46,'15 x 11 in',1);
INSERT INTO PaperSize VALUES (47,'Envelope Invite 220 x 220 mm',null);
INSERT INTO PaperSize VALUES (50,'Letter Extra 9  x 12 in',1);
INSERT INTO PaperSize VALUES (51,'Legal Extra 9  x 15 in',1);
INSERT INTO PaperSize VALUES (52,'Tabloid Extra 11.69 x 18 in',1);
INSERT INTO PaperSize VALUES (53,'A4 Extra 9.27 x 12.69 in',1);
INSERT INTO PaperSize VALUES (54,'Letter Transverse 8  x 11 in x 11 in',null);
INSERT INTO PaperSize VALUES (55,'A4 Transverse 210 x 297 mm',null);
INSERT INTO PaperSize VALUES (56,'Letter Extra Transverse 9 x 12 in',1);
INSERT INTO PaperSize VALUES (57,'SuperA/SuperA/A4 227 x 356 mm',1);
INSERT INTO PaperSize VALUES (58,'SuperB/SuperB/A3 305 x 487 mm',2);
INSERT INTO PaperSize VALUES (59,'Letter Plus 8.5 x 12.69 in',null);
INSERT INTO PaperSize VALUES (60,'A4 Plus 210 x 330 mm',1);
INSERT INTO PaperSize VALUES (61,'A5 Transverse 148 x 210 mm',null);
INSERT INTO PaperSize VALUES (62,'B5 (JIS) Transverse 182 x 257 mm',null);
INSERT INTO PaperSize VALUES (63,'A3 Extra 322 x 445 mm',2);
INSERT INTO PaperSize VALUES (64,'A5 Extra 174 x 235 mm',null);
INSERT INTO PaperSize VALUES (65,'B5 (ISO) Extra 201 x 276 mm',null);
INSERT INTO PaperSize VALUES (66,'A2 420 x 594 mm',2);
INSERT INTO PaperSize VALUES (67,'A3 Transverse 297 x 420 mm',1);
INSERT INTO PaperSize VALUES (68,'A3 Extra Transverse 322 x 445 mm',2);
INSERT INTO PaperSize VALUES (69,'Japanese Double Postcard 200 x 148 mm',null);
INSERT INTO PaperSize VALUES (70,'A6 105 x 148 mm',null);
INSERT INTO PaperSize VALUES (71,'Japanese Envelope Kaku #2',null);
INSERT INTO PaperSize VALUES (72,'Japanese Envelope Kaku #3',null);
INSERT INTO PaperSize VALUES (73,'Japanese Envelope Chou #3',null);
INSERT INTO PaperSize VALUES (74,'Japanese Envelope Chou #4',null);
INSERT INTO PaperSize VALUES (75,'Letter Rotated 11 x 8 1/2 11 in',null);
INSERT INTO PaperSize VALUES (76,'A3 Rotated 420 x 297 mm',1);
INSERT INTO PaperSize VALUES (77,'A4 Rotated 297 x 210 mm',null);
INSERT INTO PaperSize VALUES (78,'A5 Rotated 210 x 148 mm',null);
INSERT INTO PaperSize VALUES (79,'B4 (JIS) Rotated 364 x 257 mm',null);
INSERT INTO PaperSize VALUES (80,'B5 (JIS) Rotated 257 x 182 mm',null);
INSERT INTO PaperSize VALUES (81,'Japanese Postcard Rotated 148 x 100 mm',null);
INSERT INTO PaperSize VALUES (82,'Double Japanese Postcard Rotated 148 x 200 mm',null);
INSERT INTO PaperSize VALUES (83,'A6 Rotated 148 x 105 mm',null);
INSERT INTO PaperSize VALUES (84,'Japanese Envelope Kaku #2 Rotated',null);
INSERT INTO PaperSize VALUES (85,'Japanese Envelope Kaku #3 Rotated',null);
INSERT INTO PaperSize VALUES (86,'Japanese Envelope Chou #3 Rotated',null);
INSERT INTO PaperSize VALUES (87,'Japanese Envelope Chou #4 Rotated',null);
INSERT INTO PaperSize VALUES (88,'B6 (JIS) 128 x 182 mm',null);
INSERT INTO PaperSize VALUES (89,'B6 (JIS) Rotated 182 x 128 mm',null);
INSERT INTO PaperSize VALUES (90,'12 x 11 in',null);
INSERT INTO PaperSize VALUES (91,'Japanese Envelope You #4',null);
INSERT INTO PaperSize VALUES (92,'Japanese Envelope You #4 Rotated',null);
INSERT INTO PaperSize VALUES (93,'PRC 16K 146 x 215 mm',null);
INSERT INTO PaperSize VALUES (94,'PRC 32K 97 x 151 mm',null);
INSERT INTO PaperSize VALUES (95,'PRC 32K(Big) 97 x 151 mm',null);
INSERT INTO PaperSize VALUES (96,'PRC Envelope #1 102 x 165 mm',null);
INSERT INTO PaperSize VALUES (97,'PRC Envelope #2 102 x 176 mm',null);
INSERT INTO PaperSize VALUES (98,'PRC Envelope #3 125 x 176 mm',null);
INSERT INTO PaperSize VALUES (99,'PRC Envelope #4 110 x 208 mm',null);
INSERT INTO PaperSize VALUES (100,'PRC Envelope #5 110 x 220 mm',null);
INSERT INTO PaperSize VALUES (101,'PRC Envelope #6 120 x 230 mm',null);
INSERT INTO PaperSize VALUES (102,'PRC Envelope #7 160 x 230 mm',null);
INSERT INTO PaperSize VALUES (103,'PRC Envelope #8 120 x 309 mm',null);
INSERT INTO PaperSize VALUES (104,'PRC Envelope #9 229 x 324 mm',1);
INSERT INTO PaperSize VALUES (105,'PRC Envelope #10 324 x 458 mm',2);
INSERT INTO PaperSize VALUES (106,'PRC 16K Rotated',null);
INSERT INTO PaperSize VALUES (107,'PRC 32K Rotated',null);
INSERT INTO PaperSize VALUES (108,'PRC 32K(Big) Rotated',null);
INSERT INTO PaperSize VALUES (109,'PRC Envelope #1 Rotated 165 x 102 mm',null);
INSERT INTO PaperSize VALUES (110,'PRC Envelope #2 Rotated 176 x 102 mm',null);
INSERT INTO PaperSize VALUES (111,'PRC Envelope #3 Rotated 176 x 125 mm',null);
INSERT INTO PaperSize VALUES (112,'PRC Envelope #4 Rotated 208 x 110 mm',null);
INSERT INTO PaperSize VALUES (113,'PRC Envelope #5 Rotated 220 x 110 mm',null);
INSERT INTO PaperSize VALUES (114,'PRC Envelope #6 Rotated 230 x 120 mm',null);
INSERT INTO PaperSize VALUES (115,'PRC Envelope #7 Rotated 230 x 160 mm',null);
INSERT INTO PaperSize VALUES (116,'PRC Envelope #8 Rotated 309 x 120 mm',null);
INSERT INTO PaperSize VALUES (117,'PRC Envelope #9 Rotated 324 x 229 mm',1);
INSERT INTO PaperSize VALUES (118,'PRC Envelope #10 Rotated 458 x 324 mm',2);
INSERT INTO PaperSize VALUES (271,'A1 594 x 840 mm',2);
INSERT INTO PaperSize VALUES (270,'A0 840 x 1189 mm',2);
INSERT INTO PaperSize VALUES (1003,'B size sheet',1);
INSERT INTO PaperSize VALUES (1004,'A0+ 840 x 3000 mm',3);
INSERT INTO PaperSize VALUES (1005,'E+ size sheet',3);
DELETE FROM DateNumbers;
INSERT INTO DateNumbers VALUES (0,null,null);
INSERT INTO DateNumbers VALUES (1,null,null);
INSERT INTO DateNumbers VALUES (2,null,null);
INSERT INTO DateNumbers VALUES (3,null,null);
INSERT INTO DateNumbers VALUES (4,null,null);
INSERT INTO DateNumbers VALUES (5,null,null);
INSERT INTO DateNumbers VALUES (6,null,null);
INSERT INTO DateNumbers VALUES (7,null,null);
INSERT INTO DateNumbers VALUES (8,null,null);
INSERT INTO DateNumbers VALUES (9,null,null);
INSERT INTO DateNumbers VALUES (10,null,null);
INSERT INTO DateNumbers VALUES (11,null,null);
INSERT INTO DateNumbers VALUES (12,null,null);
INSERT INTO DateNumbers VALUES (13,null,null);
INSERT INTO DateNumbers VALUES (14,null,null);
INSERT INTO DateNumbers VALUES (15,null,null);
INSERT INTO DateNumbers VALUES (16,null,null);
INSERT INTO DateNumbers VALUES (17,null,null);
INSERT INTO DateNumbers VALUES (18,null,null);
INSERT INTO DateNumbers VALUES (19,null,null);
INSERT INTO DateNumbers VALUES (20,null,null);
INSERT INTO DateNumbers VALUES (21,null,null);
INSERT INTO DateNumbers VALUES (22,null,null);
INSERT INTO DateNumbers VALUES (23,null,null);
INSERT INTO DateNumbers VALUES (24,null,null);
INSERT INTO DateNumbers VALUES (25,null,null);
INSERT INTO DateNumbers VALUES (26,null,null);
INSERT INTO DateNumbers VALUES (27,null,null);
INSERT INTO DateNumbers VALUES (28,null,null);
INSERT INTO DateNumbers VALUES (29,null,null);
INSERT INTO DateNumbers VALUES (30,null,null);
INSERT INTO DateNumbers VALUES (31,null,null);
INSERT INTO DateNumbers VALUES (1995,null,null);
INSERT INTO DateNumbers VALUES (1996,null,null);
INSERT INTO DateNumbers VALUES (1997,null,null);
INSERT INTO DateNumbers VALUES (1998,null,null);
INSERT INTO DateNumbers VALUES (1999,null,null);
INSERT INTO DateNumbers VALUES (2000,null,null);
INSERT INTO DateNumbers VALUES (2001,null,null);
INSERT INTO DateNumbers VALUES (2002,null,null);
INSERT INTO DateNumbers VALUES (2003,null,null);
INSERT INTO DateNumbers VALUES (2004,null,null);
INSERT INTO DateNumbers VALUES (2005,null,null);
INSERT INTO DateNumbers VALUES (2006,null,null);
INSERT INTO DateNumbers VALUES (2007,null,null);
INSERT INTO DateNumbers VALUES (2008,null,null);
INSERT INTO DateNumbers VALUES (2009,null,null);
INSERT INTO DateNumbers VALUES (2010,null,null);
INSERT INTO DateNumbers VALUES (2011,null,null);
INSERT INTO DateNumbers VALUES (2012,null,null);
INSERT INTO DateNumbers VALUES (2013,null,null);
INSERT INTO DateNumbers VALUES (2014,null,null);
INSERT INTO DateNumbers VALUES (2015,null,null);
INSERT INTO DateNumbers VALUES (2016,null,null);
INSERT INTO DateNumbers VALUES (2017,null,null);
INSERT INTO DateNumbers VALUES (2018,null,null);
INSERT INTO DateNumbers VALUES (2019,null,null);
INSERT INTO DateNumbers VALUES (2020,null,null);
INSERT INTO DateNumbers VALUES (2021,null,null);
INSERT INTO DateNumbers VALUES (2022,null,null);
INSERT INTO DateNumbers VALUES (2023,null,null);
INSERT INTO DateNumbers VALUES (2024,null,null);
INSERT INTO DateNumbers VALUES (2025,null,null);
INSERT INTO DateNumbers VALUES (2026,null,null);
INSERT INTO DateNumbers VALUES (2027,null,null);
INSERT INTO DateNumbers VALUES (2028,null,null);
INSERT INTO DateNumbers VALUES (2029,null,null);
INSERT INTO DateNumbers VALUES (2030,null,null);
INSERT INTO DateNumbers VALUES (2031,null,null);
INSERT INTO DateNumbers VALUES (2032,null,null);
INSERT INTO DateNumbers VALUES (2033,null,null);
INSERT INTO DateNumbers VALUES (2034,null,null);
INSERT INTO DateNumbers VALUES (2035,null,null);
INSERT INTO DateNumbers VALUES (2036,null,null);
INSERT INTO DateNumbers VALUES (2037,null,null);
INSERT INTO DateNumbers VALUES (2038,null,null);
CREATE TABLE PrinterValues(PrinterID INTEGER NOT NULL, VarName VARCHAR(255), VarValue TEXT,FOREIGN KEY(PrinterID) REFERENCES Printers(ID) ON DELETE CASCADE);
CREATE UNIQUE INDEX IDX_PrinterValues ON PrinterValues (PrinterID, VarName);
CREATE TABLE PrinterSupplies(ID SERIAL PRIMARY KEY,
		PrinterID INTEGER NOT NULL,
		Description VARCHAR(255) NOT NULL,
		Class INTEGER NULL,
		Type INTEGER NULL,
		Unit INTEGER NULL,
		MaxCapacity INTEGER NULL,
		Level INTEGER NULL,
		LevelOID VARCHAR(255) NULL,
		Color VARCHAR(16) NULL,
		FOREIGN KEY(PrinterID) REFERENCES Printers(ID) ON DELETE CASCADE);
CREATE TABLE HDWDATA(ID SERIAL PRIMARY KEY,
		ChangeDate TIMESTAMP NOT NULL,
		SupplyID INTEGER NOT NULL,
		DeltaLevel INTEGER NOT NULL,
		CurrentLevel INTEGER NOT NULL,
		FOREIGN KEY(SupplyID) REFERENCES PrinterSupplies(ID) ON DELETE CASCADE);
