mysql 中的外键问题?
Foreign key issue in mysql?
假设 EmployeeId 在 mysql 数据库中的一个 table 中充当 主键 。如何使 EmployeeId 在另一个 table?
中充当 外键
我认为这是一个需要自己回答的简单问题。
假设您有 'employee' table
将 employeeID 作为您存储、更新和删除 'employee' table 数据的主键。但是如果您想向任何员工提供薪水并且想将该薪水信息存储在数据库中,在这种情况下您需要 'salary' table ,其中 employeeID 将用作外键
'employee' table
employeeID | employee_name| employee_birthdate| address
1 | John due | 1990-01-01 | Dhaka
2 | Rahim | 1990-02-06 | Feni,Bangladesh
'salary' table
salaryID | employeeID(from 'employee' table | salary | date time
1 | 2 | 00 | 2017-04-01
2 | 2 | 00 | 2017-05-01
希望您能理解。如果你觉得还是很困,尽管问我
假设 EmployeeId 在 mysql 数据库中的一个 table 中充当 主键 。如何使 EmployeeId 在另一个 table?
中充当 外键我认为这是一个需要自己回答的简单问题。 假设您有 'employee' table 将 employeeID 作为您存储、更新和删除 'employee' table 数据的主键。但是如果您想向任何员工提供薪水并且想将该薪水信息存储在数据库中,在这种情况下您需要 'salary' table ,其中 employeeID 将用作外键
'employee' table
employeeID | employee_name| employee_birthdate| address
1 | John due | 1990-01-01 | Dhaka
2 | Rahim | 1990-02-06 | Feni,Bangladesh
'salary' table
salaryID | employeeID(from 'employee' table | salary | date time
1 | 2 | 00 | 2017-04-01
2 | 2 | 00 | 2017-05-01
希望您能理解。如果你觉得还是很困,尽管问我