搜题
问题   更新时间2023/4/3 12:59:00

在图书出版发行数据库系统中,有下列关系:
出版社(编号,名称,地址,邮政编码,电话号码,联系人),编号唯一,名称不能为空。
Create table publisher(
Id char(10) primary key,
Desc char(20) not null,
Addr char(30),
Zip char(8),
Phone char(20),
Contact char(20))
图书目录(书号,书名,作者,出版社编号,价格,出版日期),每本书的书号是唯一的,且书名、出版社编号、价格、出版日期均不为空且所有图书价格均不超过200元。
Create table books(
Isdn char(30) primary key,
Title char(20) not null,
Author char(20),
Price number(6,2) not null,
Pub_date datetime not null,
Pub_id char(10),
Check (price>0 and price<200),
Foreign key pub_id references publisher(id))
发行记录(记录号,书号,客户,数量,折扣率,金额),其中记录号为顺序编号,且唯一,书号、数量和金额不为空。
Create table pubRecord(
Sequence char(20) primary key,
Isdn char(30) not null,
Customer char(30),
Discount number(5,2),
Quantity integer not null,
Amount number(8,2) not null,
Foreign key isdn references books(isdn))

请使用SQL语言完成下列工作: (1)建立上述三个表(包含约束); (2)查询所有由“清华大学出版社”在2000年以前出版的所有图书; Select * from books Where pub_date < ‘2000-1-1’ And pub_id =some (select id from publisher where desc=’清华大学出版社’) select isdn, title, author, price, pub_date from book, publisher where pub_date <’2000-1-1’ and book.pub_id=publisher.id (3)查询价格大于100元的未发行过的所有图书,并按出版日期升序排列,当出版日期相同时,按价格降序排列; Select isdn, title, author, price, pub_date From books Where price>100 And not exists( select * from pubRecord where pubRecord.isdn=books.isdn) Order by pub_date, price desc (4)查询所有无折扣的图书信息以及出版社信息。 Select books.*, publisher.* From books, publisher, pubRecord Where books.pub_id = publisher.id And books.isdn=pubRecord.isdn And discount is null Or discount = 0 (5)将所有“电子工业出版社”出版的图书降价10%。 Update books set price=0.9*price Where pub_id in (select id from publisher where desc=’电子工业出版社’)
王老师:19139051760(拨打)