Site icon Utopia TV Casting

Putting constraint on an attribute gender so that it only accepts ‘F’ or ‘M’ characters

I am doing an assignment which is implementing a database that has book, author, publisher and people tables in it.

CREATE TABLE IF NOT EXISTS Author (
    author_id INT,
    author_name VARCHAR(255),
    books_written VARCHAR(255),
    gender CHAR(1),
    birthday DATE,
    country VARCHAR(100),
    PRIMARY KEY(author_name)
);

I have to put constraint on the gender attribute of my Author table so that the only characters in a component for this attribute can be ‘F’ or ‘M’. I only thought of CHAR(1) and i know that it is not the solution. How can i do it?

Exit mobile version