codice:
CREATE DATABASE testDB;
USING testDB;
CREATE TABLE IF NOT EXISTS `articolidocumenti` (
`idArticoloDocumento` int(50) NOT NULL AUTO_INCREMENT,
`ean` varchar(255) DEFAULT NULL,
`descrizione` text NOT NULL,
`qty` int(5) NOT NULL,
`valore_unitario` decimal(10,2) NOT NULL,
`sconto` decimal(10,2) DEFAULT '0.00',
`iva` decimal(10,2) DEFAULT '0.00',
PRIMARY KEY (`idArticoloDocumento`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `articolidocumenti` (`idArticoloDocumento`, `ean`, `descrizione`, `qty`, `valore_unitario`, `sconto`, `iva`) VALUES
(1, 'ean1', 'articolo1', 1, 120.00, 0.00, 20.00),
(2, 'ean2', 'articolo2', 1, 12.90, 10.00, 20.00),
(3, 'ean3', 'articolo3', 1, 99.00, 0.00, 10.00),
(4, 'ean4', 'articolo4', 1, 358.33, 15.00, 20.00),
(5, 'ean5', 'articolo5', 1, 0.67, 0.00, 5.00);
CREATE TABLE IF NOT EXISTS `clienti` (
`idCliente` int(10) NOT NULL AUTO_INCREMENT,
`nome` text,
`cognome` text,
PRIMARY KEY (`idCliente`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `clienti` (`idCliente`, `nome`, `cognome`) VALUES
(1, 'Mario', 'Rossi');
CREATE TABLE IF NOT EXISTS `docartdoc` (
`idDocArtDoc` int(5) NOT NULL AUTO_INCREMENT,
`idDocumento` int(5) NOT NULL,
`idArticoloDocumento` int(50) NOT NULL,
PRIMARY KEY (`idDocArtDoc`,`idDocumento`,`idArticoloDocumento`),
KEY `idPreventivo` (`idDocumento`),
KEY `idArticoloPreventivo` (`idArticoloDocumento`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `docartdoc` (`idDocArtDoc`, `idDocumento`, `idArticoloDocumento`) VALUES
(1, 1, 1),
(2, 1, 2),
(3, 1, 3),
(4, 2, 4),
(5, 2, 5);
CREATE TABLE IF NOT EXISTS `documenti` (
`idDocumento` int(255) NOT NULL AUTO_INCREMENT,
`numeroPreventivo` int(255) DEFAULT NULL,
`dataDocumento` date NOT NULL,
`tipoDocumento` int(2) DEFAULT NULL,
`idCliente` int(10) DEFAULT NULL,
PRIMARY KEY (`idDocumento`),
KEY `idCliente` (`idCliente`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `documenti` (`idDocumento`, `numeroPreventivo`, `dataDocumento`, `tipoDocumento`, `idCliente`) VALUES
(1, 1, '2011-01-07', 0, 1),
(2, 2, '2011-01-07', 0, 1);
Niente di così gigantesco, versione ridotta all'osso ma sufficiente!