peterlemonjello wrote:
IMHO, this isn't NHibernate's job. Whatever tool you're using to export the schema should provide this option.
I am using the SchemaExport tool (NHibernate.Tool.hbm2ddl.SchemaExport)
peterlemonjello wrote:
If you're child foreign keys are on the primary key column of the parent table then they're already clustered by default.
Actually, in sql server 2005 the primary key is always clustered by default. I am looking at a generated schema, and the clustered index of the child table is the child's primary key, NOT the child's foreign key. This means the children are physically arranged on the disk by the time/order they are created, NOT by their parent.
The result is, when you have a parent and you need to read the children, the children are physically scattered about the disk, and NOT physically grouped together by their parent.
peterlemonjello wrote:
If you want to do the opposite and cluster the fk columns of the child table then you have a problem. What happens if the child table has more than 1 fk defined?
you mean, what if a child row has numerous many-to-one associations? good question! because you can only have one clustered index in a table. I suppose I would like to explicitly specify a specific foreign key index to cluster, and the default behavior should be clustering on the PK.