-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.sql
34 lines (31 loc) · 1.32 KB
/
database.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
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
DROP DATABASE IF EXISTS `message_sender`;
CREATE DATABASE `message_sender`;
USE `message_sender`;
DROP TABLE IF EXISTS `message`;
CREATE TABLE `message` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`sender_id` int(11) DEFAULT NULL,
`receiver_id` int(11) DEFAULT NULL,
`content` longtext COLLATE utf8_bin NOT NULL,
`sending_date` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `sender_id` (`sender_id`),
KEY `receiver_id` (`receiver_id`),
CONSTRAINT `message_user_receiver` FOREIGN KEY (`receiver_id`) REFERENCES `user` (`id`) ON DELETE SET NULL ON UPDATE SET NULL,
CONSTRAINT `message_user_sender` FOREIGN KEY (`sender_id`) REFERENCES `user` (`id`) ON DELETE SET NULL ON UPDATE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=52 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_bin NOT NULL,
`password` varchar(100) COLLATE utf8_bin NOT NULL,
`ip_address` varchar(15) COLLATE utf8_bin NOT NULL,
`mac_address` varchar(17) COLLATE utf8_bin NOT NULL,
`signup_date` datetime NOT NULL,
`login_date` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `mac_address` (`mac_address`)
) ENGINE=InnoDB AUTO_INCREMENT=410 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;