CREATE TABLE `neumann_addresses` (
	`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
	`street` varchar(64) COLLATE utf8_czech_ci NOT NULL,
	`no` int(11) NOT NULL,
	`city` varchar(64) COLLATE utf8_czech_ci NOT NULL,
	`zip` varchar(5) COLLATE utf8_czech_ci NOT NULL,
	PRIMARY KEY `id` (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=8 ;

INSERT INTO `neumann_addresses` (`id`, `street`, `no`, `city`, `zip`) VALUES
(1, 'Univerzitní', 8, 'Plzeň', '30614'),
(2, 'Klatovská', 16, 'Plzeň', '32123'),
(3, 'Tylova', 40, 'Plzeň', '33341'),
(4, 'Žlutická', 1, 'Plzeň', '32300'),
(5, 'Žitná', 5, 'Praha', '12345'),
(6, 'Ječná', 8, 'Praha', '12345');


CREATE TABLE `neumann_users` (
	`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
	`login` varchar(16) COLLATE utf8_czech_ci NOT NULL,
	`name` varchar(64) COLLATE utf8_czech_ci NOT NULL,
	`lastname` varchar(64) COLLATE utf8_czech_ci NOT NULL,
	`password` varchar(42) COLLATE utf8_czech_ci NOT NULL,
	`address` bigint(20) unsigned DEFAULT NULL,
	PRIMARY KEY `id` (`id`),
	UNIQUE KEY `login` (`login`),
	KEY `address` (`address`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=5 ;

INSERT INTO `neumann_users` (`id`, `login`, `name`, `lastname`, `password`, `address`) VALUES
(1, 'neumann', 'Jan', 'Tichava', 'b0dafc71a2937302a937bb8f07931ecc90c63e70', 1),
(2, 'rohlik', 'Ondřej', 'Rohlík', 'b888ce3be0ba09c26564b7d78348c6eaa3fd7f68', 1),
(3, 'brada', 'Přemysl', 'Brada', 'ba8130f90dcccb44cabdbd80d4d65c62be04d7d4', 2),
(4, 'jnovak', 'Josef', 'Novák', 'a06b48b84727fdd45a1b23aec656ca0da305d3e5', NULL);

ALTER TABLE `neumann_users` ADD CONSTRAINT `neumann_users_address_fk` FOREIGN KEY (`address`) REFERENCES `neumann_addresses` (`id`);
