Tables and types
Pick column types that will not fight you in a year.
CREATE TABLE device (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
hostname VARCHAR(64) NOT NULL,
mgmt_ip VARCHAR(45),
last_seen DATETIME,
PRIMARY KEY (id),
UNIQUE KEY uq_hostname (hostname)
);Use INT / BIGINT for counts and ids, VARCHAR for short strings, TEXT for long bodies, and DATETIME or TIMESTAMP for events. Store IPv6-capable addresses in a string wide enough for them, or use VARBINARY if you will query them as bytes.