-
Notifications
You must be signed in to change notification settings - Fork 1
/
CRUDlexSample.sql
54 lines (45 loc) · 1.74 KB
/
CRUDlexSample.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
-- This file is part of the CRUDlex Silex 2 sample package.
--
-- (c) Philip Lehmann-Böhm <[email protected]>
--
-- For the full copyright and license information, please view the LICENSE
-- file that was distributed with this source code.
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
-- --------------------------------------------------------
CREATE DATABASE IF NOT EXISTS `crud` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `crud`;
-- --------------------------------------------------------
CREATE TABLE IF NOT EXISTS `book` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`deleted_at` datetime DEFAULT NULL,
`version` int(11) NOT NULL,
`title` varchar(255) NOT NULL,
`author` varchar(255) NOT NULL,
`pages` int(11) NOT NULL,
`release` datetime DEFAULT NULL,
`library` int(11) NOT NULL,
`description` text NOT NULL,
`price` float DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `library` (`library`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
CREATE TABLE IF NOT EXISTS `library` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`deleted_at` datetime DEFAULT NULL,
`version` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`type` varchar(255) DEFAULT NULL,
`opening` datetime DEFAULT NULL,
`homepage` varchar(255) DEFAULT NULL,
`isOpenOnSundays` tinyint(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
ALTER TABLE `book`
ADD CONSTRAINT `book_ibfk_1` FOREIGN KEY (`library`) REFERENCES `library` (`id`);