SET FOREIGN_KEY_CHECKS=0; SET UNIQUE_CHECKS=0; SET NAMES LATIN2;

-- MySQL dump 10.11
--
-- Host: localhost    Database: hd
-- ------------------------------------------------------
-- Server version	5.0.45-standard

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES latin2 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `faktury`
--

DROP TABLE IF EXISTS `faktury`;
CREATE TABLE `faktury` (
  `id` int(11) default NULL,
  `data` date default NULL,
  `rodzaj` enum('FZ','FS') default NULL,
  `odbiorca` varchar(100) default NULL,
  `dostawca` varchar(100) default NULL,
  UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin2;

--
-- Dumping data for table `faktury`
--

LOCK TABLES `faktury` WRITE;
/*!40000 ALTER TABLE `faktury` DISABLE KEYS */;
INSERT INTO `faktury` VALUES (1,'2016-07-01','FS','Firma X','Firma Y'),(2,'2016-07-11','FS','Firma X','Firma Y'),(3,'2016-08-22','FS','Firma X','Firma Z'),(4,'2016-09-15','FS','Firma X','Firma Z');
/*!40000 ALTER TABLE `faktury` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `faktury_poz`
--

DROP TABLE IF EXISTS `faktury_poz`;
CREATE TABLE `faktury_poz` (
  `id` int(11) NOT NULL,
  `faktury_id` int(11) NOT NULL,
  `stawki_vat_id` int(11) NOT NULL,
  `nazwa` varchar(150) default NULL,
  `cena` decimal(10,2) default NULL,
  `ilosc` int(11) default NULL,
  PRIMARY KEY  (`id`),
  KEY `faktury_id` (`faktury_id`),
  KEY `stawki_vat_id` (`stawki_vat_id`),
  CONSTRAINT `faktury_poz_ibfk_1` FOREIGN KEY (`faktury_id`) REFERENCES `faktury` (`id`) ON DELETE CASCADE,
  CONSTRAINT `faktury_poz_ibfk_2` FOREIGN KEY (`stawki_vat_id`) REFERENCES `stawki_vat` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin2;

--
-- Dumping data for table `faktury_poz`
--

LOCK TABLES `faktury_poz` WRITE;
/*!40000 ALTER TABLE `faktury_poz` DISABLE KEYS */;
INSERT INTO `faktury_poz` VALUES (1,1,3,'Komputer','99.99',1),(2,1,3,'Myszka','29.99',1),(3,1,2,'Klawiatura','15.99',1),(4,2,4,'Komputer','9999.99',3),(5,2,4,'Drukarka','2139.99',4),(6,2,4,'Skaner','219.00',1),(7,3,4,'Myszka','19.00',1),(8,3,4,'Monitor','959.00',1),(9,3,2,'Klawiatura','59.00',1);
/*!40000 ALTER TABLE `faktury_poz` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `numery_seryjne`
--

DROP TABLE IF EXISTS `numery_seryjne`;
CREATE TABLE `numery_seryjne` (
  `id` int(11) NOT NULL auto_increment,
  `faktury_poz_id` int(11) NOT NULL,
  `nr_ser` varchar(32) default NULL,
  PRIMARY KEY  (`id`),
  KEY `faktury_poz_k` (`faktury_poz_id`),
  CONSTRAINT `faktury_poz_k` FOREIGN KEY (`faktury_poz_id`) REFERENCES `faktury_poz` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin2;

--
-- Dumping data for table `numery_seryjne`
--

LOCK TABLES `numery_seryjne` WRITE;
/*!40000 ALTER TABLE `numery_seryjne` DISABLE KEYS */;
INSERT INTO `numery_seryjne` VALUES (1,4,'SNK001'),(2,4,'SNK002'),(3,4,'SNK003'),(4,5,'SND001'),(5,5,'SND002'),(6,5,'SND003'),(7,5,'SND004');
/*!40000 ALTER TABLE `numery_seryjne` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `stawki_vat`
--

DROP TABLE IF EXISTS `stawki_vat`;
CREATE TABLE `stawki_vat` (
  `id` int(11) NOT NULL auto_increment,
  `stawka` int(11) NOT NULL,
  `opis` tinytext,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin2;

--
-- Dumping data for table `stawki_vat`
--

LOCK TABLES `stawki_vat` WRITE;
/*!40000 ALTER TABLE `stawki_vat` DISABLE KEYS */;
INSERT INTO `stawki_vat` VALUES (1,0,'zwolniony z vat'),(2,0,'stawka 0'),(3,8,'stawka 8'),(4,23,'stawka 23');
/*!40000 ALTER TABLE `stawki_vat` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2016-10-24 14:44:20
