Preface
I've got a db design job about meeting room booking system last week.There're many suitable tools which can be used to handle this kind of job such as power designer,ERwin,HeidiSQL,dbschema,etc.Today,I'm gonna demonstrate the last one —— dbschema.This is the official website:https://www.dbschema.com
Introduce
dbschema is a rather simply used tool even you're a novice in designing db system.The dbschema which is downloaded on official website only free for 15 days,then you have to pay for license for later useage but there's no limit in function at all.It provide two modes in designing layout of your system.One is offline mode and the other one is connecting to db servers.You can easily synchronize tables of database with your designed tables as soon as possible by refreshing them from time to time.It also supports almost all popular rdbms such as oracle,db2,MySQL,postgreSQL.There're many key features which you can found in the homepage of official website.I'm not going to describe each one of them.
Procedure
The meeting room booking system(I'll call it "mrbs" .) I contains four tables:employee,department,conference_room,room_reservation.The detail of tables shows below.
employee table
1 id 自增id int(11) 2 user_id 工號 int(11) 3 user_name 用戶名稱 varchar(20) 4 user_phone 用戶手機號 bigint 5 user_email 用戶郵箱 varchar(50) 6 user_dept_id 用戶所在部門id int(11) 7 user_status 在職、離職等 tinyint(4) 8 create_time 用戶創建時間 datetime 9 update_time 用戶信息修改時間 datetime
department table
1 id 自增id int(11) 2 dept_id 部門id int(11) 3 dept_name 部門名稱 varchar(30) 4 parent_id 父級id tinyint(4) 5 tlevel 層級id tinyint(4) 6 create_time 部門創建時間 datetime 7 update_time 部門信息修改時間 datetime
conference_room table
1 id 自增id int(11) 2 room_id 會議室id int(11) 3 room_building_id 樓號 int(11) 4 room_num 房間號 int(11) 5 room_max_num 最大容納人數 int(11) 6 room_status 會議室狀態 tinyint(4) 7 create_time 會議室創建時間 datetime 8 update_time 會議室信息修改時間 datetime
room_reservation table
1 會議室預定表(room_reservation) 2 id 自增id int(11) 3 book_id 預定工單id int(11) 4 book_room_id 預定會議室id int(11) 5 book_start_time 預定開始時間 datetime 6 book_stop_time 預定結束時間 datetime 7 book_user_id 預定人id int(11) 8 book_usage 預定用途 varchar(200) 9 book_status 預定工單狀態 tinyint(4) 10 create_time 預定工單創建時間 datetime 11 update_time 預定工單修改時間 datetime
Configure the database connection.


Use mouse to create target tables in dbschema.
Check the primary key & unique key(even other keys but I'm not creating them ye).
Check the foreign key.
After you click ok button,the table will be created in "mrbs" database.
Check the tables in "mrbys".
1 root@localhost:mysql3306.sock [mrbs]>show tables; 2 +------------------+ 3 | Tables_in_mrbs | 4 +------------------+ 5 | conference_room | 6 | department | 7 | employee | 8 | room_reservation | 9 +------------------+ 10 4 rows in set (0.01 sec) 11 12 root@localhost:mysql3306.sock [mrbs]>show create table employee\G 13 *************************** 1. row *************************** 14 Table: employee 15 Create Table: CREATE TABLE `employee` ( 16 `id` int(10) unsigned NOT NULL AUTO_INCREMENT, 17 `user_id` int(10) unsigned NOT NULL COMMENT '工號', 18 `user_name` varchar(20) NOT NULL COMMENT '用戶名稱', 19 `user_phone` bigint(20) unsigned NOT NULL COMMENT '用戶手機號', 20 `user_email` varchar(50) DEFAULT NULL COMMENT '用戶郵箱', 21 `user_dept_id` int(10) unsigned NOT NULL COMMENT '用戶所在部門id', 22 `user_status` tinyint(3) unsigned NOT NULL COMMENT '是否在職', 23 `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '用戶創建時間', 24 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '用戶信息修改時間', 25 PRIMARY KEY (`id`), 26 UNIQUE KEY `uk_user_id` (`user_id`) 27 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用戶表' 28 1 row in set (0.00 sec) 29 30 root@localhost:mysql3306.sock [mrbs]>show create table department\G 31 *************************** 1. row *************************** 32 Table: department 33 Create Table: CREATE TABLE `department` ( 34 `id` int(10) unsigned NOT NULL AUTO_INCREMENT, 35 `dept_id` int(10) unsigned NOT NULL COMMENT '部門id', 36 `dept_name` varchar(30) NOT NULL COMMENT '部門名稱', 37 `parent_id` tinyint(3) unsigned NOT NULL, 38 `tlevel` tinyint(3) unsigned NOT NULL COMMENT '層級', 39 `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '部門創建時間', 40 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '部門信息修改時間', 41 PRIMARY KEY (`id`), 42 UNIQUE KEY `uk_dept_id` (`dept_id`) 43 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='部門表' 44 1 row in set (0.00 sec) 45 46 root@localhost:mysql3306.sock [mrbs]>show create table conference_room\G 47 *************************** 1. row *************************** 48 Table: conference_room 49 Create Table: CREATE TABLE `conference_room` ( 50 `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id', 51 `room_id` int(10) unsigned NOT NULL COMMENT '會議室id', 52 `room_building_id` int(10) unsigned NOT NULL COMMENT '樓號', 53 `room_num` int(10) unsigned NOT NULL COMMENT '房間號', 54 `room_max_num` int(10) unsigned NOT NULL COMMENT '最大容納人數', 55 `room_status` tinyint(3) unsigned NOT NULL COMMENT '會議室狀態', 56 `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '會議室創建時間', 57 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '會議室信息修改時間', 58 PRIMARY KEY (`id`), 59 UNIQUE KEY `uk_room_id` (`room_id`) 60 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='會議室表' 61 1 row in set (0.00 sec) 62 63 root@localhost:mysql3306.sock [mrbs]>show create table room_reservation\G 64 *************************** 1. row *************************** 65 Table: room_reservation 66 Create Table: CREATE TABLE `room_reservation` ( 67 `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id', 68 `book_id` int(10) unsigned NOT NULL COMMENT '預定工單id', 69 `book_room_id` int(10) unsigned NOT NULL COMMENT '預定會議室id', 70 `book_start_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '預定開始時間', 71 `book_stop_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '預定結束時間', 72 `book_user_id` int(10) unsigned NOT NULL COMMENT '預定人id', 73 `book_usage` varchar(200) NOT NULL COMMENT '預定用途', 74 `book_status` tinyint(3) unsigned NOT NULL COMMENT '預定工單狀態', 75 `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '預定工單創建時間', 76 `update_time` date DEFAULT NULL COMMENT '預定工單修改時間', 77 PRIMARY KEY (`id`), 78 UNIQUE KEY `uk_book_id` (`book_id`) 79 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='會議室預定表' 80 1 row in set (0.00 sec)