CREATE TABLE IF NOT EXISTS `movie` (
`m_ID` varchar(9) NOT NULL
`ReleaseDate` date
`Title` varchar(255) NOT NULL
PRIMARY KEY (`m_ID`),
KEY `m_ID` (`ReleaseDate`,`Title`,)
)
CREATE TABLE IF NOT EXISTS `m_director` (
`dirID` int(11) unsigned NOT NULL AUTO_INCREMENT,
`dirName` varchar(40) NOT NULL,
PRIMARY KEY (`dirID`),
UNIQUE KEY `dirName` (`dirName`)
)
CREATE TABLE IF NOT EXISTS `m_directs` (
`m_ID` char(9) NOT NULL
`dirID` int(11) unsigned NOT NULL,
UNIQUE KEY `m_ID_2` (`m_ID`,`dirID`),
KEY `m_ID` (`m_ID`),
KEY `dirID` (`dirID`)
)
Also note that m_ID is set as a foreign key to movie table and dirID is set as a foreign key to m_director.
I do not understand how this would get mapped to an object like this one via mapping xmls.
public class Movie
{
public string MovieTitle{get;set;}
public IList<string> Directors;
public DateTime ReleaseDate;
}
I can see it would be fairly easy with a list tag if there was not an intermediary table between movie and m_director(eg m_directs), but for a schema like I have, I do not understand how this is done.
AFAIK
public IList<string> Directors;cant be a manytomany because string has no object identity so it cant be linked from different Movies. Therefor you cant map it with NHibernate as manytomany. best way would be tothen it would be also possible to give directors more information like Birthdate and so on.
Edited: corrected typos and indentation of xml mapping (hence not shown) and added fluent mapping