If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > table problems

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-01-11, 17:50
zorrs zorrs is offline
Registered User
 
Join Date: Mar 2011
Posts: 4
Exclamation table problems

I HAVE A TABLE LIKE THIS......
EMPLOYEE
emp_id
emp_name
address
date_of birth
designation
date_of entry
current post hold
current designation
current post location
department name
.....................
the things is that i wanna keep all the posting information history of every employee for later. i am thinking of making three table namely Employee, Posting and Department.
is this wise thing to do. also how do i create relationship.
plz i am very much in need of help
Reply With Quote
  #2 (permalink)  
Old 03-01-11, 17:53
zorrs zorrs is offline
Registered User
 
Join Date: Mar 2011
Posts: 4
Question relationship

i am currently doing a project on employee management and having problem will the tables and relationship....
Employee
emp_id(pk)
name
designation...etc
.........................
Post
post_id(pk)
emp_id(fk)
dep_id(fk)
district
post hold.....etc
......................
Department
dep_id(pk)
dep_name......etc..somthing like this
My problem is that an employee can be posted to different district. so how do i link between employee table and post.
or are there any other solution..
PLZ HELP ME, I AM ONLY A STUDENT AND HAVE SO MUCH TO LEARN
Attached Thumbnails
table problems-export.jpg  
Reply With Quote
  #3 (permalink)  
Old 03-02-11, 12:03
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
First, what the hell kind of naming convention are you using?

Second, depending on your requirements, you can create a history table that stores a history of all the records in your production table. Use a trigger on your production table to populate the history table on inserts, updates, and deletes.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #4 (permalink)  
Old 03-02-11, 12:40
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,246
so separate the employee's role from the details of the employee

you may need to add tables for departments
you need toi decide if you need the history of the employee's addresses.. if so a separate table is required for that
you need to know what period a specific role runs fro (eg a start + end date)
you need to decide if the location is somehtign that should be normalised or is conditional on some other element
eg it could be that the location is a fnction of department
if could be the location (say building) is a separate function / table
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #5 (permalink)  
Old 03-02-11, 14:45
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
You need to add a many-to-many linking table. This is a table that describes an employee assignment to a district, so it has informatoin about that specific assignment such as employee_id, district_id, date_start, date_end, comments, etc. By creating multiple rows in this table, you can assign an employee to multiple districts either at the same time or in sequence (so that one ends before another begins).

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
  #6 (permalink)  
Old 03-04-11, 14:11
zorrs zorrs is offline
Registered User
 
Join Date: Mar 2011
Posts: 4
Question table design

well i don't exactly know how to put it....but here goes......
i wanna do a little project on employee service record book which will records all the employee details and his posting activities(transfered to other area)
My PROBLEMS starts with the POST list for every employee because i wanna keep all the history.
There is also a POST CREATION LIST from which all the post are filled.
Next is the DEPARTMENT details(like its location...etc) which is also needed to be keep.
MAIN CONCERN:
1.HOW do i make the table structure
2. IF SO how do i create a relationship with the EMPLOYEE table and POST table OR should i create relationship with POSTING CREATION LIST table
3.What about the DEPARTMENT table.

I know it's my task to do all this stuff but it cost me a month to setup all these tables and their relationship BUT can anyone help me solve this problem or gives any suggestions.......................THANK YOU
Attached Thumbnails
table problems-erdiagram.jpg   table problems-export.jpg  

Last edited by zorrs; 03-05-11 at 13:14. Reason: put attachment
Reply With Quote
  #7 (permalink)  
Old 03-05-11, 06:09
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by zorrs View Post
...it cost me a month to setup all these tables and their relationship
show us what you've got so far
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #8 (permalink)  
Old 03-05-11, 13:19
zorrs zorrs is offline
Registered User
 
Join Date: Mar 2011
Posts: 4
Arrow ER diagram

Quote:
Originally Posted by r937 View Post
show us what you've got so far
please take a look at my diagram and please tell me where i am wrong.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On