CREATE TABLE Country (
    ID TINYINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, -- Primary key, auto increment, integer ranging from 0 to 255

    CountryName VARCHAR(100), -- Variable-length string with max 100 characters

    Continent VARCHAR(50), -- Variable-length string with max 50 characters
    CHECK (Continent IN ( -- Must be one of the listed continents
        'Africa',
        'Asia',
        'Europe',
        'North America',
        'South America',
        'Oceania',
        'Antarctica'
    )),

    PopulationMillions DECIMAL(5,1) -- Decimal number with 5 digits total and 1 decimal place
    CHECK (PopulationMillions BETWEEN 0.1 AND 9999.9), -- Must be between 0.1 and 9999.9

    IndependenceDate DATE -- Date of independence
    CHECK (IndependenceDate >= '1800-01-01') -- Must be on or after Jan 1, 1800
);

-- Insert sample data into Country table
INSERT INTO Country (CountryName, Continent, PopulationMillions, IndependenceDate)
VALUES
  ('Canada', 'North America', NULL, '1867-07-01'), -- NULL population allowed
  ('Brazil', 'South America', 214.3, '1822-09-07'),
  ('Germany', 'Europe', 83.2, '1871-01-18');

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: