postgresql - SQL Database Design - Flag or New Table? -


some of users in database practitioners.

this represented either:

  • an is_practitioner flag in user table
  • a separate practitioner table user_id column

it isn't clear me approach better.

advantages of flag:

  • fewer tables
  • only 1 id per user (hence no possibility of confusion, , no confusion in id use in other tables)
  • flexibility (i don't have decide whether fields practitioner-only or not)
  • possible speed advantage finding user-level information practitioner (e.g. e-mail address)

advantages of new table:

  • no nulls in user table
  • clearer information pertains practitioners only
  • speed advantage finding practitioners

in case specifically, at moment, practitioner-related information one-to-many (such locations can work in, or shifts can work, etc). not @ surprised if turns need store simple attributes practitioners (i.e., one-to-one).

questions

  1. are there other considerations?
  2. is either approach superior?

you might want consider fact that, practitioner today, else tomorrow. (and, don't mean, not being practitioner). say, consultant, author or whatever variants in subject domain, , might want keep track of latest status in users table. might make sense have proftype field, (type of professional practice) or equivalent. way, have advantages of having flag, keep string field , leave blank string, or fill other prof.type codes requirements grow.

you mention, having new table, has advantage finding practitioners. no, better off clause on users table that.

your last paragraph(one-to-many), however, may tilt whole choice in favour of separate table. might want consider, number of records, growth, criticality of complicated queries etc.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -