这个表是否需要primarykey [英] Does this table need primarykey

查看:63
本文介绍了这个表是否需要primarykey的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Emp_Code

OnDate

参加

NotAttended

Total_Hours

Total_Minutes

Total_Seconds

Shift_Start_Time

Shift_End_Time



Emp_Code是外键



这名员工是否需要外键?

表每天都会更新。

如果需要主键而不是什么,如果它不需要比什么原因。


:大喊大叫删除

Emp_Code
OnDate
Attended
NotAttended
Total_Hours
Total_Minutes
Total_Seconds
Shift_Start_Time
Shift_End_Time

Emp_Code is the foreign key

Does this employee need foreign key??
the table would be updated daily.
If it needs primary key than what would be and if it doesnt need than why.

: Shouting removed

推荐答案

主键是字段(单个或多个),其中值的组合在表中是唯一的,即在这些主键字段中没有2个记录应具有相同的值组合。

哪些字段中的值组合不能重复,请问自己这个问题,你应该能够得到答案。

P.S.不要使用all-capital,它会引起flak而不是注意。
Primary key are fields (single or multple) where their combination of values are unique in the table, i.e. no 2 records should have the same combination of values in these primary key fields.
Which fields where the combination of values in your table cannot be repeated, ask yourself this question, and you should be able to get the answer.
P.S. Do not use all-capital, it will draw flak instead of attention.


1)你应该添加一个名为ID的新字段作为主键,例如integer类型和自动增量。



2)外键应该保留,因为是来自其他表的数据的链接(员工数据);
1)You should add as primary key a new filed named "ID" for example, of type integer and with autoincrement.

2)foreign key should remain because is the link with data that come from other table (employee data);


For如果每个员工在表中每天只添加一条新记录,那么您可以将Emp_Code&OnDate设置为复合键以过滤掉重复记录。



Emp_Code将如你所说,充当外键。
For each employee if only one new record is added on each day in your table, then you can set Emp_Code & OnDate as Composite key to filter out duplicate records.

Emp_Code will act as Foreign Key as you said.


这篇关于这个表是否需要primarykey的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆