SPJ

1. ∏sno(δjno='j1'(spj))
2. ∏sno(δpno='p1'(δjno='j1'(spj)))
3. ∏sno(δjno='j1'(spj)∞δcolor='红'(p))
4. ∏jno(δcity!='天津'(s)∞spj∞δcolor!='红'(p))
5. ∏jno,pno(spj)÷∏pno(δsno='s1'(spj))

 

(1)
create table S
(
  SNO VARCHAR(20) PRIMARY KEY,
  SNAME NVARCHAR(50) NOT NULL,
  STATUS INT DEFAULT(0),
  SCITY NVARCHAR(20)
)
CREATE TABLE P
(
  PNO VARCHAR(20) PRIMARY KEY,
  PNAME NVARCHAR(50) NOT NULL,
  COLOR NVARCHAR(10),
  WEIGHT NUMERIC(9,2)
)
CREATE TABLE J
(
  JNO VARCHAR(20) PRIMARY KEY,
  JNAME NVARCHAR(50) NOT NULL,
  JCITY NVARCHAR(100)
)

CREATE TABLE SPJ
(
  SNO VARCHAR(20),
  PNO VARCHAR(20),
  JNO VARCHAR(20),
  QTY NEMERIC(9,2)
)

(2)
----------------------
SELECT PNAME, COLOR, WEIGHT FROM P

(3)
--------------------
SELECT SNO FROM SPJ AS T
WHERE JNO='J2'
  AND EXISTS(SELECT 1 FROM P WHERE COLOR='红色' AND PNO=T.JNO)

(4)
-----------------
UPDATE J SET JCITY='天津' WHERE JNO='J2'

(5)
-----------------
DELETE FROM P WHERE PNO = 'P4'

posted @ 2013-11-01 13:33  博园少主  阅读(869)  评论(0编辑  收藏  举报