1

Example:

Student

studentId
name

Staff

staffId
name

Account

accountId
foreignKeyId(studentId or staffId)
username
password
usertype
Joseph Quinsey
  • 9,553
  • 10
  • 54
  • 77

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
  • 91,357
  • 15
  • 148
  • 157
-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,269
  • 1
  • 12
  • 21