Personal I need to create a relationship between the attendance table and the category table, but every time I try it it gives the error 1215 can not add foreign key. What am I doing wrong? Both tables are empty.
CREATE TABLE 'atendimentos' (
'id' int(11) NOT NULL AUTO_INCREMENT,
'cliente_id' int(11) NOT NULL,
'categoria_id' int(11) NOT NULL DEFAULT '1',
'contato' varchar(100) DEFAULT NULL,
'created_at' timestamp NULL DEFAULT NULL,
'updated_at' timestamp NULL DEFAULT NULL,
PRIMARY KEY ('id'), ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
and this is a category table:
CREATE TABLE 'categorias' (
'id' int(11) unsigned NOT NULL AUTO_INCREMENT,
'parent_id' int(11) unsigned DEFAULT NULL,
'slug' varchar(100) COLLATE utf8_unicode_ci NOT NULL,
'label' varchar(100) COLLATE utf8_unicode_ci NOT NULL,
'order' int(11) NOT NULL DEFAULT '0',
'icon' varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
'created_at' timestamp NULL DEFAULT NULL,
'updated_at' timestamp NULL DEFAULT NULL,
PRIMARY KEY ('id'),
UNIQUE KEY 'categorias_slug_unique' ('slug'),
KEY 'categorias_parent_id_foreign' ('parent_id')
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;