Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2016
    Posts
    2

    Question Suggestion needed - database inheritance issues

    I have two tables as follows... for our healthcare app.


    Code:
    CREATE TABLE public."user_internal" (
      id                               serial NOT NULL PRIMARY KEY,
      ...
      first_name                       varchar(64),
      ...
      /* Keys */
      CONSTRAINT pk_user_internal_account
        PRIMARY KEY (id)
    ) WITH (
        OIDS = FALSE
      );
    public.user_internal stores id and attributes of internal staff, nurses, patients, patient's family members.

    Code:
    CREATE TABLE public."user_external" (
      id                               serial NOT NULL PRIMARY KEY,
      ...
      first_name                       varchar(64),
      company                         varchar(64),
       ...
      /* Keys */
      CONSTRAINT pk_user_external_account
        PRIMARY KEY (id)
    ) WITH (
        OIDS = FALSE
      );
    public.user.external stores id and related attributes of external contractors, external nurses, power of attorney, etc.

    Now, I am asked to add another column for public.user called
    Code:
    emergency_contact
    which takes input as either
    Code:
    public.user.internal
    and
    Code:
    public.user.external
    . What is the best way to approach this? A single table inheritance?
    Last edited by ikel; 07-26-16 at 01:34.

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    I'd create a single users table, then create two views for user_internal and user_external.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Jul 2016
    Posts
    2
    Quote Originally Posted by Pat Phelan View Post
    I'd create a single users table, then create two views for user_internal and user_external.

    -PatP
    Smart. I never thought of that. Thanks for the suggestion.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •