为了理解什么是第二范式,我正在阅读一些文章,还有一些我不理解的东西.
在文章这里
的客户表它说,它不是在2NF,因为there are several attributes which don’t completely rely on the entire Customer table primary key.这里的主键,我认为这意味着{客户ID,雇员}

如果我们选择{customerId,employeeId}作为候选键,那么Customername,customerCity,PostalCode确实仅部分取决于候选键,因此不在2NF中.但是,如果我们认为候选键是customerId,那么Customer表中的所有列都完全依赖于customerId吗?(因为employeeId依赖于customerId).
此外,由于CustomerId可以是候选键,因此候选键不能包含另一个候选键作为候选键.{CustomerId,EmployeeId}可以作为候选键.
因此,如果我们单独将customerId作为候选键,那么这个表是不是以2NF格式表示的?
但是在文章中它说2NF形式的表应该有一个目的,这里这个客户表有两个目的.
To indicate which customers are called upon by each employee
To identify customers and their locations.
然后我觉得这张桌子不在2NF.
那么这张表中的候选键是什么?
我的第二个问题是在这篇文章中

这些表格在3NF.在TABLE_BOOK表中,候选键是bookId吗?我们不能选择{bookId,genereId}作为候选键对吗?如果选择这样,它就不会在2NF中,因为价格不依赖于genreId.
有人可以帮助我更好地理解规范化背后的理论
我正在尝试编写一个方法来查找给定节点的父节点.这是我的方法.
我创建了一个BinaryNode最初引用root 的对象r.
public BinaryNode r=root;
public BinaryNode parent(BinaryNode p){
BinaryNode findParent=p;
if (isRoot(findParent) || r==null){
return null;
}
else{
if(r.left==findParent || r.right==findParent)
return r;
else{
if (r.element<findParent.element)
return parent(r.right);
else
return parent(r.left);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这段代码不能正常工作.我认为这是因为r是一个空对象.因为当我这样做
if (isRoot(findParent) || r==null){
System.out.println(r==null);
return null;}
Run Code Online (Sandbox Code Playgroud)
r==null评估为true.如何发生,因为我已插入节点
public static void main (String args[]){
BinaryTree t=new BinaryTree();
t.insert(5);
t.insert(t.root,4);
t.insert(t.root,6);
t.insert(t.root,60);
t.insert(t.root,25);
t.insert(t.root,10);
Run Code Online (Sandbox Code Playgroud)
并且root不为null.
有人可以指出为什么会发生这种情况,以及我为了找到父节点而尝试做的事情在逻辑上是否正确.
在只有一个Node情况的链表中,我尝试使用reoveFromHead()删除它; 我在toString()方法中得到一个nullpointer.
public void removeFromHead(){
if(head==null)
return;
else{
head=head.next;
}
}
public String toString() {
String result = " ";
ListNode a=head;
while (a.next!=null){
result +=" "+a.item;
a=a.next;
}
result+=" "+a.item;
return result;
}
Run Code Online (Sandbox Code Playgroud)
有谁可以指出错误在哪里?
我有一个曲面图,在上面绘制了一些点。现在我想给每一点贴上标签。我使用了以下代码。
name={'point1','point2','point3','point4','point5'}
co=[0 0 0];
scatter3(X,Y,Z,[],co,'filled');
c=cellstr(name);
dx = 0.1; dy = 0.1;
dz=0.1;
text(X+dx, Y+dy,Z+dz, c);
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能使这些标签变得清晰?
仍然在更改后 'Color', 'black', 'FontSize', 14)
标签显示为
在R中如果我想找到具有Gamma(10,0.5)的伽马分布的概率为0.05的分位数
我用了
> qgamma(0.05,shape=10,scale=0.5)
[1] 2.712703
Run Code Online (Sandbox Code Playgroud)
但这不是我想要的价值.我使用时获得的期望值,
qgamma(0.05,10,0.5)
[1] 10.85081
Run Code Online (Sandbox Code Playgroud)
那么qgamma(0.05,10,0.5)和的区别是什么qgamma(0.05,shape=10,scale=0.5)?
为什么我得到两个完全不同的结果?
我刚刚开始学习R,并且编写了这段代码以学习函数和循环。
squared<-function(x){
m<-c()
for(i in 1:x){
y<-i*i
c(m,y)
}
return (m)
}
squared(5)
NULL
Run Code Online (Sandbox Code Playgroud)
为什么这会返回NULL。我想将i*i值附加到末尾m并返回一个向量。有人可以指出这段代码有什么问题吗?
java ×2
r ×2
binary-tree ×1
database ×1
for-loop ×1
function ×1
linked-list ×1
matlab ×1
parent ×1
scatter-plot ×1
surface ×1