Invoices InvoicesItems
CREATE TABLE Customers ( ID SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, Name VARCHAR (50) NOT NULL, ... Active ENUM ("Y","N") NOT NULL DEFAULT "Y", InsertUser SMALLINT UNSIGNED NOT NULL DEFAULT 0, InsertDateTime DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ChangeUser SMALLINT UNSIGNED NOT NULL DEFAULT 0, ChangeDateTime DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, INDEX (Name)) COMMENT = "Basic customers data";
CREATE TABLE Invoices ( ID INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, ... Customer SMALLINT UNSIGNED NOT NULL DEFAULT 0, ... InsertUser SMALLINT UNSIGNED NOT NULL DEFAULT 0, InsertDateTime DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ChangeUser SMALLINT UNSIGNED NOT NULL DEFAULT 0, ChangeDateTime DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, FOREIGN KEY (Customer) REFERENCES Customers (ID) ON UPDATE CASCADE) COMMENT = "Master data of issued invoices"; CREATE TABLE InvoicesItems ( ... Invoice INT UNSIGNED NOT NULL, ... FOREIGN KEY (Invoice) REFERENCES Invoices (ID) ON DELETE CASCADE ON UPDATE CASCADE) COMMENT = "Detail data of issued invoice items";
© 2003-24 iNeta d.o.o. | Koroška cesta 31, SI-4000 Kranj | info@ineta.si | Pravno obvestilo
Powered by BravoCMS