我正在做一个数据库设计,求职者必须列出他们以前的工作经历.
工作经验是一门课程,它包括:
我想示范这些课程,展示求职者与他们以前的工作经验之间的联系。
我正在考虑为以前的工作经历创建一个表格,并将其引用给求职者,但每个求职者都可以有多个工作经验条目,这可能会变得很混乱。
另一种方法是将用户的所有工作体验作为一个列表存储在求职者表中。
我不知道该怎么做,也不知道哪些建议是可以接受的,哪些建议是不能接受的。任何其他的替代方案都是受欢迎的,事实上是被要求的。谢谢
发布于 2014-09-03 11:10:30
我会用这样的设计。
这将保存所有用户过去的体验
CREATE TABLE `positions` (
`position_id` int(11) NOT NULL AUTO_INCREMENT,
`position_name` varchar(50) DEFAULT NULL,
PRIMARY KEY (`position_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1
这将保存用户的个人数据
CREATE TABLE `users` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`user_firstname` varchar(20) NOT NULL,
`user_lastname` varchar(20) DEFAULT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
--这将为用户提供工作体验-- positions
和users
的“中间”表。
CREATE TABLE `work_experience` (
`seeker_id` int(11) NOT NULL AUTO_INCREMENT,
`seeker_position` int(11) NOT NULL,
`seeker_employer` varchar(20) NOT NULL,
`seeker_user` int(11) NOT NULL,
PRIMARY KEY (`seeker_id`),
KEY `positon_id` (`seeker_position`),
KEY `user_id` (`seeker_user`),
CONSTRAINT `user_id` FOREIGN KEY (`seeker_user`) REFERENCES `users` (`user_id`),
CONSTRAINT `positon_id` FOREIGN KEY (`seeker_position`) REFERENCES `positions` (`position_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
然后,它的作用就像;
SELECT users.* FROM users;
+---------+----------------+---------------+
| user_id | user_firstname | user_lastname |
+---------+----------------+---------------+
| 1 | bob | bob |
+---------+----------------+---------------+
1 row in set
SELECT positions.* FROM positions;
+-------------+-------------------+
| position_id | position_name |
+-------------+-------------------+
| 1 | stackoverflow guy |
+-------------+-------------------+
1 row in set
SELECT work_experience.* FROM work_experience;
+-----------+-----------------+-----------------+-------------+
| seeker_id | seeker_position | seeker_employer | seeker_user |
+-----------+-----------------+-----------------+-------------+
| 1 | 1 | StackExchange | 1 |
+-----------+-----------------+-----------------+-------------+
1 row in set
用户"1“(bob)曾在"StackExchange”担任过“堆叠溢出者”的工作经验。
work_experience.seeker_user
参考资料users.user_id
work_experience.seeker_position
参考资料positions.position_id
发布于 2014-09-03 10:46:53
你最初的想法是处理这种“多对一”情况的常见方法。
使用一个表存储求职者,另一个表存储以前的工作经验,每个PWE都有求职者的外键。(例如"jobseekerId“字段。)
https://stackoverflow.com/questions/25641987
复制相似问题