create user sonic121 identified by 121;
grant connect,resource to sonic121;
create table categorys(
categoryID number(10,2),
categoryName Varchar2(50) NOT NULL enable,
PRIMARY KEY(categoryID)
);
create table publishers(
PubCode Char(4),
PubName Char(50) NOT NULL enable,
Phone Char(50),
Address Varchar2(100),
PRIMARY KEY(PubCode),
UNIQUE(PubName)
);
create table titles(
TitleCode Char(6),
TitleName Varchar2(80) NOT NULL enable,
Author Char(8) NOT NULL enable,
CategoryID number,
PubCode Char(4),
Price number,
PubDate Date,
PRIMARY KEY(TitleCode),
FOREIGN KEY (CategoryID) REFERENCES categorys(CategoryID),
FOREIGN KEY (PubCode) REFERENCES publishers(PubCode),
CHECK (Price>0)
);
grant connect,resource to sonic121;
create table categorys(
categoryID number(10,2),
categoryName Varchar2(50) NOT NULL enable,
PRIMARY KEY(categoryID)
);
create table publishers(
PubCode Char(4),
PubName Char(50) NOT NULL enable,
Phone Char(50),
Address Varchar2(100),
PRIMARY KEY(PubCode),
UNIQUE(PubName)
);
create table titles(
TitleCode Char(6),
TitleName Varchar2(80) NOT NULL enable,
Author Char(8) NOT NULL enable,
CategoryID number,
PubCode Char(4),
Price number,
PubDate Date,
PRIMARY KEY(TitleCode),
FOREIGN KEY (CategoryID) REFERENCES categorys(CategoryID),
FOREIGN KEY (PubCode) REFERENCES publishers(PubCode),
CHECK (Price>0)
);









