如何存储一个有很多字段的元素
How to store an element with a lot of fields
我想设计一个数据库系统(我使用 SQLite)并在 table 我保存历史的地方,我存储了员工的一些值(姓名,姓氏,身份证等)一个of the fields是一些工作岗位,目前是3个,以后可能会增加到4个或5个...哪个更聪明?
1) 有一个包含所有字段(其中:wp1、wp2、wp3)的 table,然后为 wp3 添加一列,或者
2) 将所有这些工作位置存储到不同的 table 中,我将有 2 个字段 id
和 wp
并将不同的 wp 存储到多个记录中?
'working position' 是职位吗?在前一家公司的就业记录?
1 是个坏主意。
您可能想要这样的东西:
create table employees (
id int primary key,
name text not null
);
create table working_positions (
id int primary key,
employee_id int not null references employees(id), /* foreign key to employees table */
...other attributes of a working position...
);
我想设计一个数据库系统(我使用 SQLite)并在 table 我保存历史的地方,我存储了员工的一些值(姓名,姓氏,身份证等)一个of the fields是一些工作岗位,目前是3个,以后可能会增加到4个或5个...哪个更聪明?
1) 有一个包含所有字段(其中:wp1、wp2、wp3)的 table,然后为 wp3 添加一列,或者
2) 将所有这些工作位置存储到不同的 table 中,我将有 2 个字段 id
和 wp
并将不同的 wp 存储到多个记录中?
'working position' 是职位吗?在前一家公司的就业记录?
1 是个坏主意。
您可能想要这样的东西:
create table employees (
id int primary key,
name text not null
);
create table working_positions (
id int primary key,
employee_id int not null references employees(id), /* foreign key to employees table */
...other attributes of a working position...
);