{"member": {"columns": [[0, "Member_ID", "INT", 0, null, 1], [1, "Card_Number", "TEXT", 0, null, 0], [2, "Name", "TEXT", 0, null, 0], [3, "Hometown", "TEXT", 0, null, 0], [4, "Level", "INT", 0, null, 0]], "primary_keys": ["Member_ID"], "foreign_keys": [], "unique_constraints": [[[0, 0, "Member_ID"]]], "check_constraints": []}, "branch": {"columns": [[0, "Branch_ID", "INT", 0, null, 1], [1, "Name", "TEXT", 0, null, 0], [2, "Open_year", "TEXT", 0, null, 0], [3, "Address_road", "TEXT", 0, null, 0], [4, "City", "TEXT", 0, null, 0], [5, "membership_amount", "TEXT", 0, null, 0]], "primary_keys": ["Branch_ID"], "foreign_keys": [], "unique_constraints": [[[0, 0, "Branch_ID"]]], "check_constraints": []}, "membership_register_branch": {"columns": [[0, "Member_ID", "INT", 0, null, 1], [1, "Branch_ID", "TEXT", 0, null, 0], [2, "Register_Year", "TEXT", 0, null, 0]], "primary_keys": ["Member_ID"], "foreign_keys": [[0, 0, "branch", "Branch_ID", "Branch_ID", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "member", "Member_ID", "Member_ID", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "Member_ID"]]], "check_constraints": []}, "purchase": {"columns": [[0, "Member_ID", "INT", 0, null, 1], [1, "Branch_ID", "TEXT", 0, null, 2], [2, "Year", "TEXT", 0, null, 3], [3, "Total_pounds", "REAL", 0, null, 0]], "primary_keys": ["Member_ID", "Branch_ID", "Year"], "foreign_keys": [[0, 0, "branch", "Branch_ID", "Branch_ID", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "member", "Member_ID", "Member_ID", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "Member_ID"], [1, 1, "Branch_ID"], [2, 2, "Year"]]], "check_constraints": []}}
CREATE TABLE member (
    Member_ID INT   PRIMARY KEY,
    Card_Number TEXT,
    Name TEXT,
    Hometown TEXT,
    Level INT,
    UNIQUE (Member_ID)
);

CREATE TABLE branch (
    Branch_ID INT   PRIMARY KEY,
    Name TEXT,
    Open_year TEXT,
    Address_road TEXT,
    City TEXT,
    membership_amount TEXT,
    UNIQUE (Branch_ID)
);

CREATE TABLE membership_register_branch (
    Member_ID INT   PRIMARY KEY,
    Branch_ID TEXT,
    Register_Year TEXT,
    UNIQUE (Member_ID),
    FOREIGN KEY (Branch_ID) REFERENCES branch(Branch_ID),
    FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)
);

CREATE TABLE purchase (
    Member_ID INT   PRIMARY KEY,
    Branch_ID TEXT   PRIMARY KEY,
    Year TEXT   PRIMARY KEY,
    Total_pounds REAL,
    PRIMARY KEY (Member_ID, Branch_ID, Year),
    UNIQUE (Member_ID, Branch_ID, Year),
    FOREIGN KEY (Branch_ID) REFERENCES branch(Branch_ID),
    FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)
);