MY CODE >> Smart Homes Database
CREATE DATABASE SMART_HOMES_DATABASE;

USE SMART_HOMES_DATABASE;

CREATE TABLE CUSTOMER
    (
    CustID              Int         NOT NULL    AUTO_INCREMENT,
    EmailAddress        Char(50)    NOT NULL,
    LastName            Char(25)    NOT NULL,
    FirstName           Char(12)    NOT NULL,
    
    CONSTRAINT          DEPARTMENT_PK   PRIMARY KEY (CustID)
    );
    
CREATE TABLE ADDRESS
    (
    AddressID           Int         NOT NULL    AUTO_INCREMENT,
    StreetAddress       Char(25)    NOT NULL,
    Phone               Char(12)    NOT NULL,
    City                Char(25)    NULL,
    State               Char(2)     NULL,
    Zip                 Char(7)     NULL,
    CustID              Int         NULL,
    
    CONSTRAINT          ADDRESS_PK      PRIMARY KEY (AddressID),
    CONSTRAINT          ADDR_CUST_FK    FOREIGN KEY (CustID)
                        REFERENCES      CUSTOMER (CustID)
                        ON UPDATE RESTRICT
                        ON DELETE RESTRICT
    );

CREATE TABLE DEVICE
    (
    DeviceID            Int         NOT NULL    AUTO_INCREMENT,
    CustID              Int         NOT NULL,
    
    CONSTRAINT          DEVICE_PK       PRIMARY KEY (DeviceID),
    CONSTRAINT          DEVI_CUST_FK    FOREIGN KEY (CustID)
                        REFERENCES      CUSTOMER (CustID)
                        ON UPDATE RESTRICT
                        ON DELETE RESTRICT
    );

CREATE TABLE DEVICE_LOCATION
    (
    LocationID          Int         NOT NULL    AUTO_INCREMENT,
    Location            Char(25)    NOT NULL,
    DeviceID            Int         NOT NULL,
    
    CONSTRAINT          DEVICE_LOCATION_PK  PRIMARY KEY (LocationID),
    CONSTRAINT          LOCA_DEVI_FK        FOREIGN KEY (DeviceID)
                        REFERENCES          DEVICE (DeviceID)
                        ON UPDATE RESTRICT
                        ON DELETE RESTRICT
    );

CREATE TABLE PROGRAMMABLE_DATA
    (
    ScheduleID          Int         NOT NULL    AUTO_INCREMENT,
    Temperature         Numeric(3)  NOT NULL,
    ScheduledStartTime   Time        NOT NULL,
    ScheduledStopTime    Time        NOT NULL,
    DeviceID            Int         NULL,
    
    CONSTRAINT          PROGRAMMABLE_DATA_PK    PRIMARY KEY (ScheduleID),
    CONSTRAINT          PROG_DEVI_FK            FOREIGN KEY (DeviceID)
                        REFERENCES              DEVICE (DeviceID)
                        ON UPDATE RESTRICT
                        ON DELETE RESTRICT
    );

CREATE TABLE MONITORING_DATA
    (
    MonitoringID        Int         NOT NULL AUTO_INCREMENT,
    DateMonitored       Date        NOT NULL,
    TimeMonitored       Time        NOT NULL,
    Temperature         Numeric(3)  NOT NULL,
    Humidity            Numeric(3)  NOT NULL,
    EnergyUsage         Numeric(3)  NOT NULL,
    DeviceID            Int         NULL,
    
    CONSTRAINT          MONITORING_DATA_PK      PRIMARY KEY (MonitoringID),
    CONSTRAINT          MONI_DEVI_FK            FOREIGN KEY (DeviceID)
                        REFERENCES              DEVICE (DeviceID)
                        ON UPDATE RESTRICT
                        ON DELETE RESTRICT
    );