我目前正在做作业,遇到了问题。
我得到一个错误:
信息8135,第16级,状态0,第41行
表级约束或索引未指定表“会话”的列列表。
我已经经历了一百万遍了,但是我找不到问题出在哪里。我相信我在两个表级语句中都指定了列,所以我很茫然。
代码如下:
CREATE TABLE Class
(
-- Column specifications and constraints--
ClassID NCHAR(6) NOT NULL,
ClassDescription NVARCHAR(50) NOT NULL,
--Table constraints--
CONSTRAINT pk_Class_ClassID
PRIMARY KEY (ClassID) --ClassID is the primary key in the Class table, done as a table constraint
)
CREATE TABLE Riders
(
-- Column specifications and constraints--
RiderID INT NOT NULL IDENTITY(10, 1) --RiderID auto-fills in the value, starting at 10, incrementing by 1
CONSTRAINT pk_Riders_RiderID PRIMARY KEY, --RiderID is the primary key in the Riders table
[Name] NVARCHAR(50) NOT NULL
CONSTRAINT chk_Riders_Name CHECK (LEN([Name]) > 4), --Name must be longer than 4 letters
ClassID NCHAR(6) NULL,
--Table constraints--
CONSTRAINT fk_Riders_Class
FOREIGN KEY (ClassID) REFERENCES Class (ClassID)
)
CREATE TABLE [Sessions]
(
-- Column specifications and constraints--
RiderID INT NOT NULL,
BikeID NCHAR(6) NOT NULL,
SessionDate DATETIME NOT NULL
CONSTRAINT chk_Sessions_SessionDate CHECK (SessionDate > '1 Sep 2017'), --SessionDate must be AFTER September 1, 2017
Laps INT NULL,
-- Table constraints--
CONSTRAINT pk_Sessions_RiderID_BikeID_SessionDate
PRIMARY KEY (RiderID, BikeID, SessionDate), --RiderID, BikeID, SessionDate is the composite primary key for the Sessions table
INDEX CI_Sessions_RiderID_BikeID ON [Sessions] (RiderID, BikeID) --Index RiderID and BikeID
)
CREATE TABLE Bikes
(
-- Column specifications and constraints--
BikeID NCHAR(6) NOT NULL
CONSTRAINT chk_Bikes_BikeID CHECK (BikeID LIKE '[0-9][0-9][0-9][HYS]-[AP]') --BikeID in format ###X-A # = 0 - 9, X = H(Honda), Y(Yamaha), S(Suzuki), A = A(AM), P(PM)
CONSTRAINT pk_Bikes_BikeID PRIMARY KEY, --BikeID is the primary key in the Bikes table
StableDate DATE NOT NULL
CONSTRAINT def_Bikes_StableDate DEFAULT GETDATE()
)
ALTER TABLE [Sessions]
ADD CONSTRAINT chk_Sessions_Laps CHECK (Laps >= 10)
ALTER TABLE [Sessions]
ADD CONSTRAINT fk_Sessions_Riders
FOREIGN KEY (RiderID) REFERENCES Riders (RiderID)
ALTER TABLE [Sessions]
ADD CONSTRAINT fk_Sessions_Bikes
FOREIGN KEY (BikeID) REFERENCES Bikes (BikeID)
感谢您的帮助!
答案 0 :(得分:1)
只需从索引定义中删除apply
并写为:
df['a_'] = df.a.apply(lambda r: x[r-1])
df['b_'] = df.b.apply(lambda r: x[r-1])
df
# returns:
time a b a_ b_
0 0.000 6 5 0.5 -1
1 0.008 6 9 0.5 4
2 0.016 1 9 -6.0 4
3 0.024 2 7 -4.0 1
4 0.032 1 5 -6.0 -1
您可以检查使用以下脚本创建的索引:
function drawMealsChartOld(){
$('#btnC').css('background-color','#ffff00');
google.script.run
.withSuccessHandler(function(mObj){
var dt=mObj.dA;
var hA=dt[0];
dt.splice(0,1);
var dA=dt.slice();
var data = new google.visualization.DataTable();
for(var i=0;i<hA.length;i++){
if(i===0){
data.addColumn('string',hA[i]);
}else{
data.addColumn('number',hA[i]);
}
}
data.addRows(dA);
var options={
title:'Meals Grams (Starts: ' + mObj.start + ' - Ends: ' + mObj.end + ')',
fontSize: 14,
fontName: 'Roman',
width:640,
height:350,
pointSize:3,
hAxis:{slantedText:true,slantedTextAngle:90,textStyle:{color:'#333300',fontName:'Verdana',fontSize:8,bold:true}},
legend:{position:'top'},
chartArea:{left:75,top:75,width:'75%',height:'50%'},
series:{0: {targetAxisIndex: 0}, 1:{targetAxisIndex: 0}},
vAxes:[{title:'GRAMS',titleTextStyle:{color:'#0000CC',fontName:'Verdana',fontSize:12,bold:true,italic:false},textStyle:{color:'#0000CC',fontName:'Verdana',fontSize:10,bold:true,italic:false}}]
};
var chart=new google.visualization.LineChart(document.getElementById('mcht'));
//Not interested in emailing this chart I just want to be able to see how the average is doing.
//google.visualization.events.addListener(chart,'click',function(){emailVitalsDialog()});
//google.visualization.events.addListener(chart,'ready',function(){
//gImgObj['base64Data']=chart.getImageURI().split(',')[1];
//gImgObj.ready=true;
//});
chart.draw(data,options);
$('#btnC').css('background-color','#ffffff');
})
.getMealsData();
}