|
1
|
-- --------------------------------------------------------
|
|
2
|
-- Host: 127.0.0.1
|
|
3
|
-- Server version: 10.4.28-MariaDB - mariadb.org binary distribution
|
|
4
|
-- Server OS: Win64
|
|
5
|
-- HeidiSQL Version: 12.13.0.7147
|
|
6
|
-- --------------------------------------------------------
|
|
7
|
|
|
8
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
|
9
|
/*!40101 SET NAMES utf8 */;
|
|
10
|
/*!50503 SET NAMES utf8mb4 */;
|
|
11
|
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
|
12
|
/*!40103 SET TIME_ZONE='+00:00' */;
|
|
13
|
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
|
14
|
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
|
15
|
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
|
16
|
|
|
17
|
|
|
18
|
-- Dumping database structure for animals_db
|
|
19
|
DROP DATABASE IF EXISTS `animals_db`;
|
|
20
|
CREATE DATABASE IF NOT EXISTS `animals_db` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */;
|
|
21
|
USE `animals_db`;
|
|
22
|
|
|
23
|
-- Dumping structure for table animals_db.animal
|
|
24
|
DROP TABLE IF EXISTS `animal`;
|
|
25
|
CREATE TABLE IF NOT EXISTS `animal` (
|
|
26
|
`animal_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
27
|
`name` varchar(32) NOT NULL,
|
|
28
|
`breed_id` int(10) unsigned NOT NULL,
|
|
29
|
`weight` decimal(4,1) unsigned NOT NULL,
|
|
30
|
`age` int(10) unsigned NOT NULL,
|
|
31
|
`gender` enum('m','f') NOT NULL,
|
|
32
|
PRIMARY KEY (`animal_id`),
|
|
33
|
KEY `fk_animal_breed_id` (`breed_id`),
|
|
34
|
CONSTRAINT `fk_animal_breed_id` FOREIGN KEY (`breed_id`) REFERENCES `breed` (`breed_id`) ON UPDATE CASCADE
|
|
35
|
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
|
36
|
|
|
37
|
-- Dumping data for table animals_db.animal: ~5 rows (approximately)
|
|
38
|
INSERT INTO `animal` (`animal_id`, `name`, `breed_id`, `weight`, `age`, `gender`) VALUES
|
|
39
|
(1, 'Eko', 1, 23.4, 96, 'm'),
|
|
40
|
(2, 'Kitty', 2, 3.3, 50, 'f'),
|
|
41
|
(3, 'Veljko', 3, 16.1, 32, 'm'),
|
|
42
|
(4, 'Dog2', 4, 30.0, 80, 'f'),
|
|
43
|
(5, 'Cat2', 5, 4.7, 21, 'm');
|
|
44
|
|
|
45
|
-- Dumping structure for table animals_db.breed
|
|
46
|
DROP TABLE IF EXISTS `breed`;
|
|
47
|
CREATE TABLE IF NOT EXISTS `breed` (
|
|
48
|
`breed_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
49
|
`species_id` int(10) unsigned NOT NULL,
|
|
50
|
`name` varchar(100) NOT NULL,
|
|
51
|
PRIMARY KEY (`breed_id`),
|
|
52
|
UNIQUE KEY `uq_breed_name` (`name`),
|
|
53
|
KEY `fk_breed_species_id` (`species_id`),
|
|
54
|
CONSTRAINT `fk_breed_species_id` FOREIGN KEY (`species_id`) REFERENCES `species` (`species_id`) ON UPDATE CASCADE
|
|
55
|
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
|
56
|
|
|
57
|
-- Dumping data for table animals_db.breed: ~5 rows (approximately)
|
|
58
|
INSERT INTO `breed` (`breed_id`, `species_id`, `name`) VALUES
|
|
59
|
(1, 1, 'Husky'),
|
|
60
|
(2, 2, 'Russian'),
|
|
61
|
(3, 2, 'Common shorthair'),
|
|
62
|
(4, 1, 'Golden Retriever'),
|
|
63
|
(5, 1, 'Persian');
|
|
64
|
|
|
65
|
-- Dumping structure for table animals_db.species
|
|
66
|
DROP TABLE IF EXISTS `species`;
|
|
67
|
CREATE TABLE IF NOT EXISTS `species` (
|
|
68
|
`species_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
69
|
`name` varchar(100) NOT NULL,
|
|
70
|
PRIMARY KEY (`species_id`),
|
|
71
|
UNIQUE KEY `uq_species_name` (`name`)
|
|
72
|
) ENGINE=InnoDB AUTO_INCREMENT=334 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
|
73
|
|
|
74
|
-- Dumping data for table animals_db.species: ~2 rows (approximately)
|
|
75
|
INSERT INTO `species` (`species_id`, `name`) VALUES
|
|
76
|
(1, 'Canis lupus familiaris'),
|
|
77
|
(2, 'Felis catus');
|
|
78
|
|
|
79
|
-- Dumping structure for table animals_db.vaccination
|
|
80
|
DROP TABLE IF EXISTS `vaccination`;
|
|
81
|
CREATE TABLE IF NOT EXISTS `vaccination` (
|
|
82
|
`vaccination_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
83
|
`animal_id` int(10) unsigned NOT NULL,
|
|
84
|
`vaccinated_at` date NOT NULL,
|
|
85
|
`vaccine` varchar(50) NOT NULL,
|
|
86
|
PRIMARY KEY (`vaccination_id`),
|
|
87
|
KEY `fk_vaccination_animal_id` (`animal_id`),
|
|
88
|
CONSTRAINT `fk_vaccination_animal_id` FOREIGN KEY (`animal_id`) REFERENCES `animal` (`animal_id`) ON UPDATE CASCADE
|
|
89
|
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
|
90
|
|
|
91
|
-- Dumping data for table animals_db.vaccination: ~1 rows (approximately)
|
|
92
|
INSERT INTO `vaccination` (`vaccination_id`, `animal_id`, `vaccinated_at`, `vaccine`) VALUES
|
|
93
|
(1, 1, '2025-11-21', 'Some vaccine..');
|
|
94
|
|
|
95
|
/*!40103 SET TIME_ZONE=IFNULL(@OLD_TIME_ZONE, 'system') */;
|
|
96
|
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
|
97
|
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
|
|
98
|
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
|
99
|
/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */;
|