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:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
|
CREATE DATABASE IF NOT EXISTS `book1`;
USE `book1`;
DROP TABLE IF EXISTS `customers`;
CREATE TABLE `customers`
(
customerid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
NAME CHAR(60) NOT NULL,
address CHAR(80) NOT NULL,
city CHAR(30) NOT NULL,
state CHAR(20),
zip CHAR(10),
country CHAR(20) NOT NULL
);
DROP TABLE IF EXISTS `orders`;
CREATE TABLE `orders`
(
orderid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
customerid INT UNSIGNED NOT NULL,
amount FLOAT(6,2),
DATE DATE NOT NULL,
order_status CHAR(10),
ship_name CHAR(60) NOT NULL,
ship_address CHAR(80) NOT NULL,
ship_city CHAR(30) NOT NULL,
ship_state CHAR(20),
ship_zip CHAR(10),
ship_country CHAR(20) NOT NULL
);
DROP TABLE IF EXISTS `books`;
CREATE TABLE `books`
(
RecordReference CHAR(19),
ProductIDTypeCode1 CHAR(2),
ProductIDTypeIDValue1 CHAR(10),
ProductIDTypeCode2 CHAR(2),
ProductIDTypeIDValue2 CHAR(13) NOT NULL PRIMARY KEY,
ProductIDTypeCode3 CHAR(2),
ProductIDTypeIDValue3 CHAR(13),
Barcode CHAR(2),
ProductFormCode CHAR(3),
TitleOfSeries CHAR(150),
NumberWithinSeries CHAR(3),
TitleOfSet CHAR(150),
TitleTypeCode1 CHAR(2),
TitleText1 CHAR(150),
Subtitle CHAR(150),
ContributorRoleCode1 CHAR(3),
NamesBeforeKey1 CHAR(50),
KeyNames1 CHAR(50),
Affiliation1 CHAR(150),
ContributorRoleCode2 CHAR(3),
NamesBeforeKey2 CHAR(50),
KeyNames2 CHAR(50),
Affiliation2 CHAR(150),
ContributorRoleCode3 CHAR(3),
NamesBeforeKey3 CHAR(50),
KeyNames3 CHAR(50),
Affiliation3 CHAR(150),
ContributorRoleCode4 CHAR(3),
NamesBeforeKey4 CHAR(50),
KeyNames4 CHAR(50),
Affiliation4 CHAR(150),
LanguageRole CHAR(2),
LanguageCode CHAR(3),
NumberOfPages CHAR(4),
BASICMainSubject CHAR(10),
AudienceCode CHAR(2),
TexTypeCode1 CHAR(2),
Tex1 CHAR(150),
TexTypeCode2 CHAR(2),
Tex2 CHAR(150),
TexTypeCode3 CHAR(2),
Tex3 CHAR(150),
NameCodeType CHAR(2),
NameCodeValue CHAR(2),
ImprintName CHAR(80),
PublisherName CHAR(80),
PublishingStatus CHAR(2),
PublicationDate DATE,
CopyrightYear CHAR(4),
CopyrightOwnerIDType CHAR(2),
CopyrightOwnerIDTypeValue CHAR(80),
SalesRightsType CHAR(2),
MeasureTypeCode1 CHAR(2),
Measurement1 FLOAT,
MeasureUnitCode1 CHAR(2),
MeasureTypeCode2 CHAR(2),
Measurement2 FLOAT,
MeasureUnitCode2 CHAR(2),
RightsTerritory CHAR(15),
RelationCode CHAR(2),
RelationProductIDType CHAR(2),
RelationProductIDTypeValue CHAR(13),
SupplierName CHAR(80),
AvailabilityCode CHAR(4),
ProductAvailability INT(4),
ExpectedShipDate DATE,
PackQuantity INT(2),
PriceTypeCode CHAR(2),
DiscountCodeType CHAR(2),
DiscountCodeTypeName CHAR(4),
DiscountCode CHAR(3),
PriceAmount FLOAT(4,2)
);
DROP TABLE IF EXISTS `categories`;
CREATE TABLE `categories`
(
catid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
catname CHAR(60) NOT NULL
);
DROP TABLE IF EXISTS `order_items`;
CREATE TABLE `order_items`
(
orderid INT UNSIGNED NOT NULL,
isbn CHAR(13) NOT NULL,
item_price FLOAT(4,2) NOT NULL,
quantity TINYINT UNSIGNED NOT NULL,
PRIMARY KEY (orderid, isbn)
);
DROP TABLE IF EXISTS `admin`;
CREATE TABLE `admin`
(
username CHAR(16) NOT NULL PRIMARY KEY,
PASSWORD CHAR(40) NOT NULL
);
GRANT SELECT,INSERT,UPDATE,DELETE ON `book1`.* TO `book1`@localhost IDENTIFIED BY 'password';
|