In mysql database, I have a total of 7 tables. Under normal circumstances an instructor belongs to only one academy but an academy can have many instructors. In the same way many courses can be taught in one academy. I am not keeping record of what instructor taught which course but what course is being taught at x or y academy. Also each academy has a main contact person and unlike the instructors, a contact person can be part of several academies. In the end, I would like to run a query where I can see the linked data to a specific academy of my choice.
Are the tables below structured to do store/display data in away that there is no repeated values of same instructors, courses, etc?
CREATE TABLE IF NOT EXISTS `academies` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(25) NOT NULL,
`mou_id` int(11) default NULL,
`academy_id` int(11) NOT NULL,
`street_address` varchar(50) NOT NULL,
`city` varchar(25) NOT NULL,
`state` varchar(25) NOT NULL,
`country` varchar(25) NOT NULL,
`zipcode` varchar(5) NOT NULL,
`telephone` varchar(15) NOT NULL,
`comments` text,
`last_contacted` date default NULL,
PRIMARY KEY (`id`)
) ;
CREATE TABLE IF NOT EXISTS `academy_courses` (
`id` int(11) NOT NULL auto_increment,
`academy_id` int(11) NOT NULL,
`course_name` varchar(75) NOT NULL,
`course_id` int(11) NOT NULL,
`instructor_id` int(11) NOT NULL,
`start_date` date default NULL,
PRIMARY KEY (`unique_id`),
KEY `course_id` (`academy_id`,`course_id`)
);
CREATE TABLE IF NOT EXISTS `courses` (
`course_id` int(11) NOT NULL auto_increment,
`course_name` varchar(75) NOT NULL,
PRIMARY KEY (`course_id`)
);
INSERT INTO `courses` (`course_id`, `course_name`) VALUES
(1, 'Math'),
(2, 'English'),
(3, 'Science'),
(4, 'HIstory');
CREATE TABLE IF NOT EXISTS `instructors` (
`instructor_id` int(11) NOT NULL auto_increment,
`academy_id` int(11) NOT NULL,
`instructor_name` varchar(50) NOT NULL,
`instructor_phone` varchar(15) default NULL,
`instructor_email` varchar(55) default NULL,
PRIMARY KEY (`instructor_id`),
KEY `academy_id` (`academy_id`)
);
CREATE TABLE IF NOT EXISTS `last_contacted` (
`talkedto_id` int(11) NOT NULL auto_increment,
`academy_id` int(11) NOT NULL,
`talkedto_name` varchar(50) NOT NULL,
PRIMARY KEY (`talkedto_id`),
KEY `academy_id` (`academy_id`)
);
CREATE TABLE IF NOT EXISTS `main_contact` (
`contact_id` int(11) NOT NULL auto_increment,
`academy_id` int(11) NOT NULL,
`contact_name` varchar(50) NOT NULL,
`contact_phone` varchar(15) default NULL,
`contact_email` varchar(55) default NULL,
PRIMARY KEY (`contact_id`),
KEY `academy_id` (`academy_id`)
);
CREATE TABLE IF NOT EXISTS `main_contact_bridge` (
`academy_id` int(11) NOT NULL,
`contact_id` int(11) NOT NULL,
PRIMARY KEY (`contact_id`,`academy_id`),
KEY `academy_id` (`academy_id`)
);
UPDATE : Based on Answer by Emmad Kareem
CREATE TABLE IF NOT EXISTS `person` (
id int(11) NOT NULL auto_increment,
`academy_id` int(11) NOT NULL,
`person_name` varchar(50) NOT NULL,
`person_email` varchar(50) default NULL,
`person_phone` varchar(15) default NULL,
PRIMARY KEY (`id`),
CONSTRAINT `academy_id` FOREIGN KEY (`academy_id`) REFERENCES `academy` (`academy_id`) ON DELETE CASCADE ON UPDATE CASCADE,
);