Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Why not simply have two tables? One for S members and one for P members. You can use zero-filled ids. If it's absolutely necessary for the numbers to be unique, i.e. you don't want both S000001 and P000001 to exist, use another table to store the unique ids and reference them in your S and P tables.</p> <p>Something like:</p> <pre><code>-- Table `ids` CREATE TABLE IF NOT EXISTS `ids` ( `master_id` INT ZEROFILL NOT NULL AUTO_INCREMENT , `member_type` ENUM('S','P') NULL , PRIMARY KEY (`master_id`) ) ENGINE = InnoDB; -- Table `s_type` CREATE TABLE IF NOT EXISTS `s_type` ( `s_type_id` INT NOT NULL , `master_id` INT NULL , PRIMARY KEY (`s_type_id`) , INDEX `fk_s_type_1` (`s_type_id` ASC) , CONSTRAINT `fk_s_type_1` FOREIGN KEY (`s_type_id` ) REFERENCES `ids` (`master_id` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- Table `s_type_copy1` CREATE TABLE IF NOT EXISTS `s_type_copy1` ( `p_type_id` INT NOT NULL , `master_id` INT NULL , PRIMARY KEY (`p_type_id`) , INDEX `fk_s_type_copy1_1` (`p_type_id` ASC) , CONSTRAINT `fk_s_type_copy1_1` FOREIGN KEY (`p_type_id` ) REFERENCES `ids` (`master_id` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; </code></pre> <p>If you want to go real simple, just use an auto-incremented id in conjunction with an enumerated CHAR(1) for 'S' or 'P'. You just need to put them together when you need to display. The CHAR(1) column can be used to determine membership type.</p> <p>If you don't plan on adding further membership types you could even go with a TINYINT as a boolean (0 = 'S', 1 = 'P').</p> <pre><code>-- Table `ids` CREATE TABLE IF NOT EXISTS `ids` ( `member_id` INT ZEROFILL NOT NULL AUTO_INCREMENT , `member_type` ENUM('S','P') NULL , PRIMARY KEY (`member_id`) ) ENGINE = InnoDB; </code></pre> <p>...or...</p> <pre><code>-- Table `ids` CREATE TABLE IF NOT EXISTS `ids` ( `member_id` INT ZEROFILL NOT NULL AUTO_INCREMENT , `member_type` TINYINT , PRIMARY KEY (`member_id`) ) ENGINE = InnoDB; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload