Hello, i need help facing of relationships thrugh models, in particular need to understand how best to manage to be able to take advantage of these.
I have this table:
CREATE TABLE `album` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`title` VARCHAR(50) NULL DEFAULT NULL,
`created_at` DATE NULL DEFAULT NULL,
`updated_at` DATETIME NULL DEFAULT NULL,
PRIMARY KEY (`id`)
)
CREATE TABLE `images` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NOT NULL,
`tags` VARCHAR(50) NOT NULL,
`created_at` DATE NULL DEFAULT NULL,
`updated_at` DATETIME NULL DEFAULT NULL,
PRIMARY KEY (`id`)
)
CREATE TABLE `user` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`email` VARCHAR(50) NOT NULL DEFAULT '0',
`password` VARCHAR(128) NOT NULL DEFAULT '0',
`role` ENUM('guest','user','admin') NOT NULL DEFAULT 'user',
`created_at` DATETIME NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` DATETIME NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
UNIQUE INDEX `email` (`email`)
)
CREATE TABLE `album_link` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`album_id` INT(10) NOT NULL,
`image_id` INT(10) NOT NULL,
`user_id` INT(10) NOT NULL,
`created_at` DATE NULL DEFAULT NULL,
`updated_at` DATETIME NULL DEFAULT NULL,
PRIMARY KEY (`id`)
)
How i can manage relation betwin these tables, using models?
Thank you in advance.