@@ -166,10 +166,10 @@ This table stores the basic information of books.
166166
167167| Field name | Type | Description |
168168| --------------| ---------------| ------------------------------------------------------------------|
169- | id | bigint(20) | Unique ID of a book |
169+ | id | bigint | Unique ID of a book |
170170| title | varchar(100) | Title of a book |
171171| type | enum | Type of a book (for example, magazine, animation, or teaching aids) |
172- | stock | bigint(20) | Stock |
172+ | stock | bigint | Stock |
173173| price | decimal(15,2) | Price |
174174| published_at | datetime | Date of publish |
175175
@@ -179,19 +179,19 @@ This table stores basic information of authors.
179179
180180| Field name | Type | Description |
181181| ------------| --------------| -------------------------------------------------------|
182- | id | bigint(20) | Unique ID of an author |
182+ | id | bigint | Unique ID of an author |
183183| name | varchar(100) | Name of an author |
184- | gender | tinyint(1) | Biological gender (0: female, 1: male, NULL: unknown) |
185- | birth_year | smallint(6) | Year of birth |
186- | death_year | smallint(6) | Year of death |
184+ | gender | tinyint | Biological gender (0: female, 1: male, NULL: unknown) |
185+ | birth_year | smallint | Year of birth |
186+ | death_year | smallint | Year of death |
187187
188188### ` users ` table
189189
190190This table stores information of Bookshop users.
191191
192192| Field name | Type | Description |
193193| ------------| ---------------| -----------------------|
194- | id | bigint(20) | Unique ID of a user |
194+ | id | bigint | Unique ID of a user |
195195| balance | decimal(15,2) | Balance |
196196| nickname | varchar(100) | Nickname |
197197
@@ -212,19 +212,19 @@ An author may write multiple books, and a book may involve more than one author.
212212
213213| Field name | Type | Description |
214214| ------------| ------------| --------------------------------------------------------------|
215- | book_id | bigint(20) | Unique ID of a book (linked to [ books] ( #books-table ) ) |
216- | author_id | bigint(20) | Unique ID of an author(Link to [ authors] ( #authors-table ) ) |
215+ | book_id | bigint | Unique ID of a book (linked to [ books] ( #books-table ) ) |
216+ | author_id | bigint | Unique ID of an author(Link to [ authors] ( #authors-table ) ) |
217217
218218### ` orders ` table
219219
220220This table stores user purchase information.
221221
222222| Field name | Type | Description |
223223| ------------| ------------| ----------------------------------------------------------------|
224- | id | bigint(20) | Unique ID of an order |
225- | book_id | bigint(20) | Unique ID of a book (linked to [ books] ( #books-table ) ) |
226- | user_id | bigint(20) | User unique identifier (associated with [ users] ( #users-table ) ) |
227- | quantity | tinyint(4) | Purchase quantity |
224+ | id | bigint | Unique ID of an order |
225+ | book_id | bigint | Unique ID of a book (linked to [ books] ( #books-table ) ) |
226+ | user_id | bigint | User unique identifier (associated with [ users] ( #users-table ) ) |
227+ | quantity | tinyint | Purchase quantity |
228228| ordered_at | datetime | Purchase time |
229229
230230## Database initialization script ` dbinit.sql `
@@ -236,29 +236,29 @@ CREATE DATABASE IF NOT EXISTS `bookshop`;
236236
237237DROP TABLE IF EXISTS ` bookshop` .` books` ;
238238CREATE TABLE `bookshop `.` books` (
239- ` id` bigint ( 20 ) AUTO_RANDOM NOT NULL ,
239+ ` id` bigint AUTO_RANDOM NOT NULL ,
240240 ` title` varchar (100 ) NOT NULL ,
241241 ` type` enum(' Magazine' , ' Novel' , ' Life' , ' Arts' , ' Comics' , ' Education & Reference' , ' Humanities & Social Sciences' , ' Science & Technology' , ' Kids' , ' Sports' ) NOT NULL ,
242242 ` published_at` datetime NOT NULL ,
243- ` stock` int ( 11 ) DEFAULT ' 0' ,
243+ ` stock` int DEFAULT ' 0' ,
244244 ` price` decimal (15 ,2 ) DEFAULT ' 0.0' ,
245245 PRIMARY KEY (` id` ) CLUSTERED
246246) DEFAULT CHARSET= utf8mb4 COLLATE= utf8mb4_bin;
247247
248248DROP TABLE IF EXISTS ` bookshop` .` authors` ;
249249CREATE TABLE `bookshop `.` authors` (
250- ` id` bigint ( 20 ) AUTO_RANDOM NOT NULL ,
250+ ` id` bigint AUTO_RANDOM NOT NULL ,
251251 ` name` varchar (100 ) NOT NULL ,
252- ` gender` tinyint ( 1 ) DEFAULT NULL ,
253- ` birth_year` smallint ( 6 ) DEFAULT NULL ,
254- ` death_year` smallint ( 6 ) DEFAULT NULL ,
252+ ` gender` tinyint DEFAULT NULL ,
253+ ` birth_year` smallint DEFAULT NULL ,
254+ ` death_year` smallint DEFAULT NULL ,
255255 PRIMARY KEY (` id` ) CLUSTERED
256256) DEFAULT CHARSET= utf8mb4 COLLATE= utf8mb4_bin;
257257
258258DROP TABLE IF EXISTS ` bookshop` .` book_authors` ;
259259CREATE TABLE `bookshop `.` book_authors` (
260- ` book_id` bigint ( 20 ) NOT NULL ,
261- ` author_id` bigint ( 20 ) NOT NULL ,
260+ ` book_id` bigint NOT NULL ,
261+ ` author_id` bigint NOT NULL ,
262262 PRIMARY KEY (` book_id` ,` author_id` ) CLUSTERED
263263) DEFAULT CHARSET= utf8mb4 COLLATE= utf8mb4_bin;
264264
@@ -283,10 +283,10 @@ CREATE TABLE `bookshop`.`users` (
283283
284284DROP TABLE IF EXISTS ` bookshop` .` orders` ;
285285CREATE TABLE `bookshop `.` orders` (
286- ` id` bigint ( 20 ) AUTO_RANDOM NOT NULL ,
287- ` book_id` bigint ( 20 ) NOT NULL ,
288- ` user_id` bigint ( 20 ) NOT NULL ,
289- ` quality` tinyint ( 4 ) NOT NULL ,
286+ ` id` bigint AUTO_RANDOM NOT NULL ,
287+ ` book_id` bigint NOT NULL ,
288+ ` user_id` bigint NOT NULL ,
289+ ` quality` tinyint NOT NULL ,
290290 ` ordered_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
291291 PRIMARY KEY (` id` ) CLUSTERED,
292292 KEY ` orders_book_id_idx` (` book_id` )
0 commit comments