diff --git "a/NBA\344\275\234\344\270\232/\346\242\201\345\220\257\351\221\253/SQLQuery2.sql" "b/NBA\344\275\234\344\270\232/\346\242\201\345\220\257\351\221\253/SQLQuery2.sql" new file mode 100644 index 0000000000000000000000000000000000000000..0881fd40e552ce75e95a37470b08e7abc365df01 --- /dev/null +++ "b/NBA\344\275\234\344\270\232/\346\242\201\345\220\257\351\221\253/SQLQuery2.sql" @@ -0,0 +1,152 @@ + +create database NBA +go +use NBA +go +create table Team +( + TID int primary key identity, + --队名 + Tname varchar(50), + --分区 + region varchar(50), + --创建年份 + CreateTime varchar(20), + --口号 + intro text, + +) +go + +insert into Team values +('亚特兰大 老鹰','东部联盟东南赛区参赛球队','1946','不尝试,就永远不会成功'), +('夏洛特 黄蜂','东部联盟东南赛区参赛球队','2004','从历史的心中出发,迈向更加悸动的未来'), +('洛杉矶湖人队','美国加利福尼亚州洛杉矶','1947','1、2、3、Manba!曼巴精神永存') +go + +create table Player + ( + PID int primary key identity, + --球队 + TID int references Team(TID) not null, + --名字 + PName varchar(20) not null, + --性别 + PSex varchar(2) default('男') check(PSex in('男','女')) not null, + --位置 + PPosition varchar(20), + --身高 + Phigh varchar(20), + --体重 + Pweight varchar(20), + --生日 + Pbirthday date, + --参赛年数 + Pexperience int not null, + --家乡 + Pnationality varchar(20) not null + ) + + insert into Player values (1,'马克加·索尔','男','中锋','2.11m','115.7公斤','1985-01-29 ',12,'西班牙'), + (1,'勒布朗·詹姆斯','男','前锋','2.06m','113.4公斤','1984-12-30',17,'美国'), + (1,'亚历克斯·卡鲁索','男','后卫','1.93m','84.4公斤',' 1994-02-28', 3,'美国') + + + insert into Player values (2,'拉梅洛·鲍尔','男','后卫','1.98m','81.6公斤','2001-08-22',0,'美国'), + (2,'俾斯麦·比永博','男','中锋','2.03m','115.7公斤','1992-08-28',9,'刚果民主共和国'), + (2,'迈尔斯·布里奇斯','男','前锋','1.98m','102.1公斤','1998-03-21',2,'美国') + + insert into Player values (3,'博格丹·博格达诺维奇','男','后卫','1.98m','99.8公斤','1992-08-18',3,'塞尔维亚'), + (3,'克林特·卡佩拉','男','中锋','2.08m','108.9公斤','1994-05-18',6 ,'瑞士'), + (3,'约翰·科林斯','男','前锋-中锋','2.06m','106.6公斤 ','1997-09-23',3,'美国') + +create table ContestInfo +( + TeamId int foreign key references Team(TID), + --本赛季场次 + GamePlayed int not null, + --进攻篮板 + Attack int not null, + --防守篮板 + Defend int not null, + --得分 + Score int not null, + --失误 + Fault int not null, + --犯规 + Foul int not null +) + +insert into ContestInfo(TeamId,GamePlayed,Attack,Defend,Score,Fault,Foul) +values +(1,51,10.8,34.7,113.4,13.7,19.9), +(2,19,10.5,33.6,110.7,15.4,18.1), +(3,51,9.7,35.5,110.0,15.6,19.0) + +create table Gameinformation +( +PID int primary key references Player(PID),--对应球员信息表的ID +GameOpponent varchar(20) not null,--比赛对手球队 +Score int not null,--该球员比赛得分 +BackBoard int not null,--篮板次数 +Assist int not null,--助攻次数 +Steal int not null,--抢断次数 +Block int not null,--盖帽次数 +Hit int not null,--命中次数 +Sell int not null,--出手次数 +Offensive int null,--进攻次数 +Guard int not null,--防守次数 +Fault int not null,--失误次数 +Foul int not null,--犯规次数 +) +insert into Gameinformation values +(1,'猛龙',13,9,5,0,4,6,9,3,6,5,3), +(2,'老鹰',10,1,4,0,0,3,6,0,1,1,0), +(3,'猛龙',13,5,4,2,0,4,7,0,5,4,3), +(4,'快船',13,5,2,3,0,4,12,0,5,1,4), +(5,'凯尔特人',6,3,2,0,2,2,2,1,2,0,3), +(6,'凯尔特人',10,5,2,0,0,3,9,0,5,4,1), +(7,'灰熊',24,6,3,2,0,9,20,3,3,2,3), +(8,'鹈鹕',12,12,1,0,3,5,7,5,7,1,3), +(9,'太阳',9,4,3,0,0,4,6,0,4,0,1) + + +create table NBAOne +( + --夺冠年份 + year datetime unique , + TID int foreign key references Team(TID) +) +insert into NBAOne values('1958',1), + + ('1978',2) , + + ('1949',3), + + ('1950',3), + + ('1952',3), + + ('1953',3), + + ('1954',3), + + ('1972',3), + + ('1980',3), + + ('1982',3), + + ('1985',3), + + ('1987',3), + + ('1988',3), + + ('2000',3), + + ('2001',3), + + ('2002',3), + + ('2009',3)