If you are familiar with Oracle HR schema (it’s one the Oracle Database Sample Schema) you may find this “adaptation” useful.

I’ve written a script that generates a very similar sample schema but for MySQL and MariaDB. I’ve tried to keep the table structure and the actual data very similar with what you can find in Oracle.

Database Diagram (this file was generated using MySQL Workbench):

hr_mysql

 

The SQL script can be found here

To clone the GitHub project:

8 thoughts on “HR Schema for MySQL and Maria DB

  1. With my thanks to the author for this effort , Here it is the missing part of the Job_Hostory

    INSERT INTO job_history
    VALUES (
    102,
    STR_TO_DATE(’13-Jan-1993′, ‘%d-%M-%Y’),
    STR_TO_DATE(’24-Jul-1998′, ‘%d-%M-%Y’),
    ‘IT_PROG’,
    60
    );

    INSERT INTO job_history
    VALUES (
    101,
    STR_TO_DATE(’21-Sep-1989′, ‘%d-%M-%Y’),
    STR_TO_DATE(’27-Oct-1993′, ‘%d-%M-%Y’),
    ‘AC_ACCOUNT’,
    110
    );

    INSERT INTO job_history
    VALUES (
    101,
    STR_TO_DATE(’28-Oct-1993′, ‘%d-%M-%Y’),
    STR_TO_DATE(’15-Mar-1997′, ‘%d-%M-%Y’),
    ‘AC_MGR’,
    110
    );

    INSERT INTO job_history
    VALUES (
    201,
    STR_TO_DATE(’27-Feb-1996′, ‘%d-%M-%Y’),
    STR_TO_DATE(’19-Dec-1999′, ‘%d-%M-%Y’),
    ‘MK_REP’,
    20
    );

    INSERT INTO job_history
    VALUES (
    114,
    STR_TO_DATE(’24-Mar-1998′, ‘%d-%M-%Y’),
    STR_TO_DATE(’31-Dec-1999′, ‘%d-%M-%Y’),
    ‘ST_CLERK’,
    50
    );

    INSERT INTO job_history
    VALUES (
    122,
    STR_TO_DATE(’01-Jan-1999′, ‘%d-%M-%Y’),
    STR_TO_DATE(’31-Dec-1999′, ‘%d-%M-%Y’),
    ‘ST_CLERK’,
    50
    );

    INSERT INTO job_history
    VALUES (
    200,
    STR_TO_DATE(’17-Sep-1987′, ‘%d-%M-%Y’),
    STR_TO_DATE(’17-Jun-1993′, ‘%d-%M-%Y’),
    ‘AD_ASST’,
    90
    );

    INSERT INTO job_history
    VALUES (
    176,
    STR_TO_DATE(’24-Mar-1998′, ‘%d-%M-%Y’),
    STR_TO_DATE(’31-Dec-1998′, ‘%d-%M-%Y’),
    ‘SA_REP’,
    80
    );

    INSERT INTO job_history
    VALUES (
    176,
    STR_TO_DATE(’01-Jan-1999′, ‘%d-%M-%Y’),
    STR_TO_DATE(’31-Dec-1999′, ‘%d-%M-%Y’),
    ‘SA_MAN’,
    80
    );

    INSERT INTO job_history
    VALUES (
    200,
    STR_TO_DATE(’01-Jul-1994′, ‘%d-%M-%Y’),
    STR_TO_DATE(’31-Dec-1998′, ‘%d-%M-%Y’),
    ‘AC_ACCOUNT’,
    90
    );

    Reply
  2. Hi, the script below gives me an error syntax, it seems that does not recognizes STR_YO_DATE, can someone help me?

    Reply
    • Dear Sebastian
      Above script has some typing errors you may follow replace above script with following:
      INSERT INTO job_history
      VALUES (
      102,
      STR_TO_DATE(’13-Jan-1993′, ‘%d-%M-%Y’),
      STR_TO_DATE(’24-Jul-1998′, ‘%d-%M-%Y’),
      ‘IT_PROG’,
      60
      );

      INSERT INTO job_history
      VALUES (
      101,
      STR_TO_DATE(’21-Sep-1989′, ‘%d-%M-%Y’),
      STR_TO_DATE(’27-Oct-1993′, ‘%d-%M-%Y’),
      ‘AC_ACCOUNT’,
      110
      );

      INSERT INTO job_history
      VALUES (
      101,
      STR_TO_DATE(’28-Oct-1993′,’%d-%M-%Y’),
      STR_TO_DATE(’15-Mar-1997′,’%d-%M-%Y’),
      ‘AC_MGR’,
      110
      );

      INSERT INTO job_history
      VALUES (
      201,
      STR_TO_DATE(’27-Feb-1996′,’%d-%M-%Y’),
      STR_TO_DATE(’19-Dec-1999′,’%d-%M-%Y’),
      ‘MK_REP’,
      20
      );

      INSERT INTO job_history
      VALUES (
      114,
      STR_TO_DATE(’24-Mar-1998′,’%d-%M-%Y’),
      STR_TO_DATE(’31-Dec-1999′,’%d-%M-%Y’),
      ‘ST_CLERK’,
      50
      );

      INSERT INTO job_history
      VALUES (
      122,
      STR_TO_DATE(’01-Jan-1999′,’%d-%M-%Y’),
      STR_TO_DATE(’31-Dec-1999′,’%d-%M-%Y’),
      ‘ST_CLERK’,
      50
      );

      INSERT INTO job_history
      VALUES (
      200,
      STR_TO_DATE(’17-Sep-1987′,’%d-%M-%Y’),
      STR_TO_DATE(’17-Jun-1993′,’%d-%M-%Y’),
      ‘AD_ASST’,
      90
      );

      INSERT INTO job_history
      VALUES (
      176,
      STR_TO_DATE(’24-Mar-1998′,’%d-%M-%Y’),
      STR_TO_DATE(’31-Dec-1998′,’%d-%M-%Y’),
      ‘SA_REP’,
      80
      );

      INSERT INTO job_history
      VALUES (
      176,
      STR_TO_DATE(’01-Jan-1999′,’%d-%M-%Y’),
      STR_TO_DATE(’31-Dec-1999′,’%d-%M-%Y’),
      ‘SA_MAN’,
      80
      );

      INSERT INTO job_history
      VALUES (
      200,
      STR_TO_DATE(’01-Jul-1994′,’%d-%M-%Y’),
      STR_TO_DATE(’31-Dec-1998′,’%d-%M-%Y’),
      ‘AC_ACCOUNT’,
      90
      );

      This will work for sure.

      Reply
  3. The job_history inserting statement got syntax errors because of some of the quotes are not of the right font. Try replacing the doggy ones with (‘).

    Reply
  4. Pingback: Esquema HR de Oracle para Mysql | Blog de Michael Yugcha

Leave a reply

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url=""> 

required

Are we human, or are we dancer *