MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old January 23rd, 2005, 11:37 PM
popeye137 popeye137 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Queen City of the South--> Cebu Philippines
Posts: 11 popeye137 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 1 m 22 sec
Reputation Power: 0
Foreign Key

hi guys,

i need some help. i have 3 tables m_dept_hdr, m_dept_dtl and m_employee.

m_dept_hdr:
dept_id /* primary key */
dept_name

m_dept_dtl:
dept_id /* primary key */
empid /* primary key, this is for employee id */

m_employee:
empid /* primary key */
empname

i want the m_dept_hdr.dept_id and m_employee.empid to be the foreign key in m_dept_dtl... does anybody help me on how to code this...

i tried

alter table m_dept_dtl
add constraint fk_dept_id foreign key (dept_id)
references m_dept_hdr(dept_id)
on delete restrict on update restrict

alter table m_dept_dtl
add constraint fk_empid foreign key(empid)
references m_employee (empid)
on delete restrict on update restrict

but the second alter table in setting the empid to be the foreign key does not work...

please help me...

thanks...



Reply With Quote
  #2  
Old January 23rd, 2005, 11:53 PM
popeye137 popeye137 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Queen City of the South--> Cebu Philippines
Posts: 11 popeye137 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 1 m 22 sec
Reputation Power: 0
hi guys,

i solve the problem...


i was not able to set the dept_id and empid to be index...


thanks anyway...



Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Foreign Key


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 6 hosted by Hostway