 -- House View
 -- Because houses are used so much, make a view separate from the organizations
 -- table.
-CREATE VIEW org_houses AS (
-    SELECT org_id, org_name FROM organizations WHERE type = 'house'
+CREATE VIEW group_houses AS (
+    SELECT group_id, group_name FROM organizations WHERE type = 'house'
 );
 
 -- House Members View
 -- Because house membership is used so much, make a view separate from the
 -- positions table.
-CREATE VIEW org_house_membership AS (
-    SELECT user_id, org_id, pos_id
-    FROM org_houses NATURAL JOIN positions NATURAL JOIN position_holders
+CREATE VIEW group_house_membership AS (
+    SELECT user_id, group_id, pos_id
+    FROM group_houses NATURAL JOIN positions NATURAL JOIN position_holders
     WHERE UPPER(pos_name) = UPPER('Full Member') 
         OR UPPER(pos_name) = UPPER('Social Member')
-);
-
--- Groups Table
--- Groups of members. Used for mailing lists, etc.
--- Groups are very similar to organizations, but more for internal groupings
--- of users.
-CREATE TABLE groups (
-    group_id                INT          NOT NULL AUTO_INCREMENT,
-    group_name              VARCHAR(32)  NOT NULL,
-    group_desc              VARCHAR(255) DEFAULT NULL,
-    anyone_can_send         BOOLEAN      DEFAULT FALSE, -- This flag controls
-                                                        -- whether or not 
-                                                        -- anyone can send
-                                                        -- emails to the group
-    newsgroups              BOOLEAN      DEFAULT FALSE, -- Controls if this is
-                                                        -- an email group
-    visible                 BOOLEAN      DEFAULT FALSE, -- Controls if anyone
-                                                        -- anyone can see this
-                                                        -- group
-    admin_control_members   BOOLEAN      DEFAULT TRUE,  -- Toggles whether or
-                                                        -- not admins control
-                                                        -- Group membership
-    PRIMARY KEY (group_id),
-    UNIQUE (group_name)
 );
 
 -- Group Members Table

    FOREIGN KEY (group_id) REFERENCES groups(group_id)
);

-- Group Member Positions Table
CREATE TABLE group_member_positions (
    pos_id      INT NOT NULL,
    group_id    INT NOT NULL,
    send        BOOLEAN DEFAULT FALSE, -- Toggles whether or not this position

    UNIQUE (username)
);

-- Groups Table
-- Groups of members. Used for mailing lists, etc.
-- Groups are used for any internal/external groupings of users.
-- Used for organizations on campus
-- Examples: Blacker Hovse, IHC, CRC, ug-list, ug-2020
CREATE TABLE groups (
    group_id                INT          NOT NULL AUTO_INCREMENT,
    group_name              VARCHAR(32)  NOT NULL,
    group_desc              VARCHAR(255) DEFAULT NULL,
    type                    VARCHAR(32)  DEFAULT NULL,
    anyone_can_send         BOOLEAN      DEFAULT FALSE, -- This flag controls
                                                        -- whether or not 
                                                        -- anyone can send
                                                        -- emails to the group
    newsgroups              BOOLEAN      DEFAULT FALSE, -- Controls if this is
                                                        -- an email group
    visible                 BOOLEAN      DEFAULT FALSE, -- Controls if anyone
                                                        -- anyone can see this
                                                        -- group
    admin_control_members   BOOLEAN      DEFAULT TRUE,  -- Toggles whether or
                                                        -- not admins control
                                                        -- Group membership
    PRIMARY KEY (group_id),
    UNIQUE (group_name)
);

-- Positions Table
CREATE TABLE positions (
    group_id INT         NOT NULL,
    pos_id   INT         NOT NULL AUTO_INCREMENT,
    pos_name VARCHAR(32) NOT NULL,
    PRIMARY KEY (pos_id),
    FOREIGN KEY (group_id) REFERENCES groups(group_id)
);

-- Position to Member Table
