Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
M:N relationship
-
- Posts: 2
- Joined: Wed Oct 22, 2014 2:27 pm
-
- Posts: 503
- Joined: Thu May 24, 2012 2:08 am
- Location: Milan, Italy
- Contact:
-
- Posts: 2
- Joined: Wed Oct 22, 2014 2:27 pm
Re: M:N relationship
Thank you massiws, for answer.
I have new question. My example tables:
When I try to create subform via subform wizzard, wizzard not show tablefields for table student_has_teacher. Why?
It is important for me, that combination student-teacher must be unique.
I have new question. My example tables:
Code: Select all
CREATE TABLE IF NOT EXISTS `student` (
`id_student` varchar(15) NOT NULL,
`name` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id_student`)
) ENGINE=MyISAM;
CREATE TABLE IF NOT EXISTS `teacher` (
`id_teacher` varchar(15) NOT NULL,
`name` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id_teacher`)
) ENGINE=MyISAM
CREATE TABLE IF NOT EXISTS `student_has_teacher` (
`student_id_student` varchar(15) NOT NULL,
`teacher_id_teacher` varchar(15) NOT NULL,
PRIMARY KEY (`student_id_student`,`teacher_id_teacher`),
KEY `fk_student_has_teacher_teacher1_idx` (`teacher_id_teacher`),
KEY `fk_student_has_teacher_student1_idx` (`student_id_student`)
) ENGINE=MyISAM;
It is important for me, that combination student-teacher must be unique.
-
- Posts: 503
- Joined: Thu May 24, 2012 2:08 am
- Location: Milan, Italy
- Contact:
Re: M:N relationship
rasi,
you made some mistakes:
- student
-- student_id -> VARCHAR(25)
-- stu_name -> VARCHAR(45)
- teacher
-- teacher_id -> VARCHAR(25)
-- tea_name -> VARCHAR(45)
- student_has_teacher
-- sht_id -> VARCHAR(25)
-- sht_student_id -> VARCHAR(25)
-- sht_teacher_id -> VARCHAR(25)
Max
you made some mistakes:
- in nuBuilderPro table IDs must be defined VARCHAR(25);
- student_has_teacher table must have an ID field, so you can get unique records;
- student
-- student_id -> VARCHAR(25)
-- stu_name -> VARCHAR(45)
- teacher
-- teacher_id -> VARCHAR(25)
-- tea_name -> VARCHAR(45)
- student_has_teacher
-- sht_id -> VARCHAR(25)
-- sht_student_id -> VARCHAR(25)
-- sht_teacher_id -> VARCHAR(25)
Max