女士訪問

關於主鍵的一切

關於主鍵的一切

在我們生命中的某個時刻,我們所有人都遇到過這個術語叫做主鍵。那麼主鍵有什麼用呢?讓我們舉一個例子來更好地理解它。假設我有一家公司,我自己的公司,我想存儲在我的組織中工作的每個人的記錄。然後,當我有一些字段,如DOB、加入日期、年齡、工資和就業ID時,肯定有可能兩個不同的人的任何兩個記錄幾乎所有內容都是相似的。我的意思是說,兩個人同一天加入公司,得到了相同的薪水,而且碰巧生日在同一天,甚至可能年齡也一樣。現在,使情況更糟的是,可能有百分之一的情況,甚至兩個人的名字變成一樣的。(我在高中的時候就有五個叫Ayush的學生)。所以,對人力資源部門來說,跟蹤他們就變成了一個困惑的問題,這可能會導致嚴重的誤解。因此,在這種情況下,我們必須定義一個特定的字段,我們稱之為主鍵,它對每個員工都是唯一的。 Each employee, here, in our example, can be assigned a unique employment id, which can serve as the primary key. It should be kept in mind that computers, as a device, originated as a military devices whose sole work was to coordinate with the military requirements. So, typically, the databases were created, creating a unique identification number, which would be similar to the unique military id assigned to each machine during the WW2 era. You can also think of it as the aadhar card number. There is a requirement to assign a field as a primary key. You cannot simply assign any field randomly to be the primary key. The main criterion is it should not contain similar data for 2 different entries. And then, no particular cell should be left vacant. If these two conditions are satisfied, then you are all ready to set that field as a primary key.

Baidu
map