· 7 years ago · Oct 11, 2018, 07:50 AM
1CREATE DATABASE IF NOT EXISTS `test`;
2
3USE `test`;
4
5
6CREATE TABLE `contragents` (
7 `id` int(11) not null AUTO_INCREMENT,
8 `name_official` varchar(50) not null default '',
9 `pseudonym` varchar(50) not null default '',
10 `city_reg` varchar(50) not null default '',
11 `address_legal` varchar(50) not null default '',
12 PRIMARY KEY `id` (`id`)
13);
14
15INSERT INTO `contragents` (`id`, `name_official`, `pseudonym`, `city_reg`, `address_legal`) VALUES
16 (1,"Kirill",'Kirill the master',"Vladivostok","Palata #6"),
17 (2,"Alexander",'Alexander the greatest',"Vladivostok","Palata #6"),
18 (3,"Iosif Brodsky",'Sharp tongue',"Leningrad","Nevsky district, 10"),
19 (4,"Fedor Shalyapin",'Vociferous',"Kazan","Kazansky district, 55"),
20 (5,"Mike Tyson",'Iron Mike aka Kid Dynatite',"New York","The Park of New York");
21 #(6,"Sophie Ellis-Bextor",'Mademoiselle EB',"London","Piccadilly str., 20"),
22 #(7,"Phil Ivey",'The Tiger Woods of poker',"Las Vegas","Casino Royale");
23
24CREATE TABLE `consignments` (
25 `id` int(11) not null AUTO_INCREMENT,
26 `invoice_id` int(11) not null default '0',
27 `date` date not null default '0000-00-00',
28 `contragent_id` int(11) not null,
29 `vendor_id` int(11) default NULL,
30 PRIMARY KEY `id` (`id`)
31);
32
33# 22 orders
34INSERT INTO `consignments` (`id`, `invoice_id`, `date`, `contragent_id`, `vendor_id`) VALUES
35 (1,1,'2012-01-06',1,100),
36 (2,2,'2012-01-07',1,101),
37 (3,3,'2012-01-01',2,105),
38 (4,4,'2012-01-10',2,105),
39 (5,5,'2012-01-11',2,101),
40 (6,6,'2012-01-11',3,100),
41 (7,7,'2012-01-05',3,108),
42 (8,8,'2012-01-08',4,104),
43 (9,9,'2012-01-04',5,120),
44 (10,10,'2012-01-08',5,125),
45 (11,11,'2012-01-09',5,130);
46 #(12,12,'2012-01-10',5,135),
47 #(13,13,'2012-01-10',5,135),
48 #(14,14,'2012-01-02',6,110),
49 #(15,15,'2012-01-08',6,105),
50 #(16,16,'2012-01-05',6,135),
51 #(17,17,'2012-01-09',6,108),
52 #(18,18,'2012-01-01',7,110),
53 #(19,19,'2012-01-03',7,210),
54 #(20,20,'2012-01-04',7,107),
55 #(21,21,'2012-02-01',7,140),
56 #(22,22,'2012-01-07',7,104);
57
58CREATE TABLE `consignments_goods` (
59 `id` int(11) not null,
60 `invoice_id` INT(11) not null default '0',
61 `name` varchar(50) not null default '',
62 `cnt` int(11) default NULL,
63 `price_nds` DOUBLE(15,2) default NULL,
64 `nds_rate` int(11) default NULL,
65 PRIMARY KEY `id` (`id`)
66);
67
68INSERT INTO `consignments_goods` (`id`, `invoice_id`, `name`, `cnt`, `price_nds`, `nds_rate`) VALUES
69 (1,1,'White T-shirt, size 36',2,22.00,18),
70 (2,1,'Blue jeens, size 40',3,85.30,17),
71 (3,1,'Red scarf',1,5.20,19),
72 (4,2,'Rolex Premium Watch',1,1200,16),
73 (5,2,'Apple i-Pod 3, 64Gb',1,640,18),
74 (6,3,'Suzuki Escudo Bumper',1,150,18),
75 (7,3,'Suzuki Escudo Left Front Door',1,210,18),
76 (8,3,'Sport streering wheel',1,1150,17),
77 (9,4,'White T-shirt, size 38',3,33.00,18),
78 (10,4,'Blue jeens, size 40',2,50.30,17),
79 (11,4,'Wool Jacket',1,150.95,16),
80 (12,5,'Toothpaste Dental Plus Extra Care',1,6.97,19),
81 (13,5,'Toothbrush Dental Plus Extra Care',1,3.97,19),
82 (14,6,'Schenider ball pen',10,5.96,14),
83 (15,6,'Paper sheets. 200 sheets pack',4,40.40,15),
84 (16,7,'Umbrella',1,10.15,18),
85 (17,7,'Rainsuit',1,23.95,17),
86 (18,8,'Aspirin',5,5.98,14),
87 (19,9,'Boxing gloves',2,120.50,18),
88 (20,9,'Boxing shorts',3,165.00,18),
89 (21,9,'Relaxation chair',1,650.00,16),
90 (22,10,'Black T-shirt, size 42',5,55.00,18),
91 (23,10,'Toilet paper, 50m',3,15.45,16),
92 (24,10,'Toothpaste Dental Plus Extra Care',2,12.47,19),
93 (25,11,'Decorative lamp',2,58.20,18),
94 (26,11,'Leather Sofa',1,750.00,18),
95 (27,11,'Nissan GTR',1,85000,14),
96 (28,11,'Rolex Premium Watch',1,1200,16);