Paste this into a new question or an answer at dba.stackexchange.com:
<!-- --> > select @@version; > > <pre> > | @@version | > | :-------- | > | 8.0.13 | > </pre> <!-- --> > CREATE TABLE IF NOT EXISTS USER_PROFILE ( > id BIGINT NOT NULL AUTO_INCREMENT, > user_id BIGINT NOT NULL, > name VARCHAR(100) NOT NULL, > username VARCHAR(100) NOT NULL, > mobile BIGINT NOT NULL, > description VARCHAR(100), > created_date DATETIME, > modified_date DATETIME, > PRIMARY KEY (id), > UNIQUE (user_id) > ); > > <pre> > ✓ > </pre> <!-- --> > CREATE TABLE IF NOT EXISTS USER_DESCRIPTION_HISTORY ( > id BIGINT NOT NULL AUTO_INCREMENT, > user_id BIGINT NOT NULL, > description VARCHAR(100), > dt_datetime DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, > PRIMARY KEY(id), > CONSTRAINT FOREIGN KEY (user_id) REFERENCES USER_PROFILE (user_id) > ); > > <pre> > ✓ > </pre> <!-- --> > show create table USER_DESCRIPTION_HISTORY ; > > <pre> > Table | Create Table > :----------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > USER_DESCRIPTION_HISTORY | CREATE TABLE `USER_DESCRIPTION_HISTORY` (&lt;br&gt; `id` bigint(20) NOT NULL AUTO_INCREMENT,&lt;br&gt; `user_id` bigint(20) NOT NULL,&lt;br&gt; `description` varchar(100) DEFAULT NULL,&lt;br&gt; `dt_datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,&lt;br&gt; PRIMARY KEY (`id`),&lt;br&gt; KEY `user_id` (`user_id`),&lt;br&gt; CONSTRAINT `USER_DESCRIPTION_HISTORY_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `USER_PROFILE` (`user_id`)&lt;br&gt;) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci > </pre> *db<>fiddle [here](https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=f4fc01532f2c27e57cb32a5d77683b08)*
back to fiddle