简体   繁体   English

创建有关主键和外键的数据库表

[英]Creating database tables regarding Primary and Foreign Keys

I'm doing an activity online where I need to create an example database for an Airline. 我正在进行在线活动,需要为航空公司创建示例数据库。 It details the general information needed to be put into each table but I need help linking certain tables. 它详细说明了需要放入每个表中的一般信息,但是我需要链接某些表的帮助。

I've drawn up tables in Word to help me grasp the connections between tables but I'm unsure if I'm doing it correctly. 我已经在Word中草拟了表格,以帮助我掌握表格之间的联系,但是我不确定自己是否做得正确。

I have a table called 'Staff' that looks like this: 我有一个名为“ Staff”的表,如下所示: 在此处输入图片说明

I was asked to create another table that provides each staff members previous work experience such as the company they worked for and join and end dates, etc. The 'Work Experience' table: 我被要求创建另一个表,该表为每个员工提供以前的工作经验,例如他们工作的公司以及加入和结束日期等。“工作经验”表: 在此处输入图片说明

My question is, what would be the primary key for the Work Experience table? 我的问题是,“工作经验”表的主键是什么? Seeing as Staff_ID references back to the Staff table could it be both a Primary Key and a Foreign Key? 看到Staff_ID引用了Staff表,它既可以是主键又可以是外键?

只需创建一个通用的work_experience_id或we_id(无论您希望使用哪种方式),以便每次您想要给员工打电话之前的工作经验时,只需选择通用ID主键即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用外键创建Oracle表,该外键引用实例化视图上的主键 - Creating Oracle tables with foreign keys that reference primary keys on materialized views SQL:使用主键和外键引用创建表( - SQL: creating tables with primary keys and foreign key refering ( 导出数据库中的所有对象(表,主键/外键等)。 - Exporting all objects in database (tables,primary / foreign keys, etc..) 创建 SQL 数据库。 有多个主键和外键 - Creating SQL database. with multiple primary and foreign keys 主键和外键数据库设计 - Primary and foreign keys database design 创建一个有 2 个主键和两个外键的表,引用 2 个具有相同约束名称的不同表 - Creating a table with 2 primary keys and two foreign keys referring to 2 different tables with same constraint name 如何从特定数据库中的所有表中检索不属于主键和外键的所有列 - How to retrieve all the columns from all of the tables in a particular database which are not part of primary keys and foreign keys 添加主/外键并引用其他表 - Adding primary/foreign keys and referencing other tables 在SQL Developer中使用主键和外键创建表 - creating table in sql developer with primary and foreign keys 使用主键和外键将值添加到数据库中 - Adding values into database with the use of primary and foreign keys
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM