1

Example:

Student

studentId
name

Staff

staffId
name

Account

accountId
foreignKeyId(studentId or staffId)
username
password
usertype
Joseph Quinsey
  • 9,185
  • 10
  • 53
  • 75

2 Answers2

1

IMHO strange design choice. You better go all the way around:

Account
-------
accountid
username
password
usertype
...

Student
-------
studentid
accountid
name
...

Staff
-----
staffid
accountid
name
...
peterm
  • 88,818
  • 14
  • 143
  • 153
-1

Both tables should be InnoDB. InnoDB details - http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html

The following Stack Overflow answer could help.

Multiple-column foreign key in MySQL?

Community
  • 1
  • 1
donlaur
  • 1,261
  • 1
  • 12
  • 21