SubSonic Forums
All Your Database Are Belong To Us

Conventions and Many To Many Relationships

Latest post 08-20-2008 2:04 AM by yitzchok. 2 replies.
  • 08-18-2008 6:04 PM

    • gantww
    • Not Ranked
    • Joined on 08-18-2008
    • Posts 4

    Conventions and Many To Many Relationships

    Hello all,

    Sorry to keep hammering the forums with noob questions, but I'm still trying to get my head around all the goodness that is Subsonic. In my database, I have a number of tables that are many-to-many tables. Is there some sort of naming convention that I should be using to make subsonic pick it up automatically?

    Thanks,

    Will

  • 08-19-2008 9:29 AM In reply to

    Re: Conventions and Many To Many Relationships

    A few pointers:

    1. Each and every table must have a primary key in order for SubSonic to pick it up.
    2. Foreign keys should retain the name of their Primary Key name from the source table.
    3. Relationships need to be defined in order for SubSonic to pick up on it.
    4. Tablenames and columnnames should be singular, preferably without underscores
    5. SubSonic works best when each table has a single column primary key.  Compound primary keys in associative entity tables, not so much.  This has been argued to death, but the reality is, single key works, compound keys seem to cause grief.
    6. Do not use reserved words from .NET or TSQL/PLSQL/MySQL in the column or tablenames regardless whether you believe it should work.  It probably wont.
    Software Is Like Cathedrals: First we build 'em, then we pray.
  • 08-20-2008 2:04 AM In reply to

    Re: Conventions and Many To Many Relationships

    There is also a convention for many to many but I don't know if this is required

    You call the mapping table the of the two tables and end it with Map

    Teacher -> TeacherClassMap <- Class

    If I am I because I am I, and You are You because You are You, then I am I, and you are you. But If I am I because You are You, and You are You because I am I, then I am not I and You are not You. -Rabbi of Kotzk

Page 1 of 1 (3 items) | RSS