Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old January 28th, 2003, 06:31 PM
Miss K. Miss K. is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Australia
Posts: 20 Miss K. User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 32 sec
Reputation Power: 0
Question Foreign Keys

I am looking for some help regarding my database structure for an internal time recording system I am creating...

I am in the process of converting my ER-Diagram to relations. One of my entities called 'Project' has a number of fields, three of which are:IT_PROJMGR, BUS_PM and BUS_OWNER. I have another entity called 'Employee' with its primary key called EMP_ID. The three fields in the project entity are all foreign keys referencing the EMP_ID field in the employee table. So essentially, there is a many to many relationship between the two, even though there is only one employee that can take on any of these roles.

How can I go about transforming this to a set of relations? One method I thought of was to create a third entity - 'Projemps' and have PROJ_ID and EMP_ID as a composite key, then have a third field defining their position.

But I am not happy with this structure as it doesn't easily convey meaning. Is it possible to have the three fields remain in my project entity (relation) and have three foreign keys referencing the same field from the employee table???

Any help or suggestions you could offer me would be much appreciated.

Reply With Quote
  #2  
Old January 28th, 2003, 11:18 PM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 31 m 56 sec
Reputation Power: 8
Can you diagram what is in your head? I have found that a diagram or an hierarchy chart, in your case, helps to shed light on a solution. A diagram could even help us help you.
__________________
El éxito consiste en una serie de pequeñas victorias día a día

MySQL, MS SQL, MS ACCESS, Oracle Database Manager - http://victorpendleton.net/products/psdviewer.html

Reply With Quote
  #3  
Old January 29th, 2003, 04:30 PM
Miss K. Miss K. is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Australia
Posts: 20 Miss K. User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 32 sec
Reputation Power: 0
I have attached an ER-diagram of the structure I have created to date.

I have left the cardinality off the relationship between project and employee because this is partly what I am unsure about. I am also unsure of whether or not I can only have one relationship here, when I think that perhaps there should be three, since IT MANAGER, BUSINESS PM, and BUS OWNER all reference emp_num in the employee table.

I have the same sort of problem between the user and employee entites. But here I have simply created 2 relationships to show that both supervisor and emp_id reference the emp_id attribute in the employee table.

I'm not sure which method is correct, but I think its the second (ie. the one used between employee and user). However, if it is this one, can these entities then be transformed directly to relations???? I'm not sure whether or not you can have multiple fields in one table as foreign keys referencing the same field in another table.

Help please???
Attached Images
File Type: jpg erdiagram.jpg (71.6 KB, 318 views)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Foreign Keys


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway