Body: <p>First i would like to say that Craft CMS really impresses me and im really interested in learning more about it </p>
  
  <p>However in a recent project i am having a bit of problems, i have looked at the sample cocktail recipes plugin and it all makes sense however my project is a bit more complicated than that, it adds about 10 new tables and i need to be able to use more than one locale</p>
  
  <p>I will describe a small portion of what im trying to achieve and maybe someone could point out where to look for some code examples within craft core files </p>
  
  <p>For the sake of this example i will have 4</p>
  
  <p>disease (diseaseSort)
  disease_translation (diseaseId, locale, diseaseTranslation, diseaseTranslationDescription)
  treatment (diseaseId, treatmentSort)
  treatment_translation (treatmentId, locale, treatment, treatmentDescription)</p>
  
  <p>The idea is we would have a list of diseases (in more languages)</p>
  
  <p>and each of those would also have multiple treatments that are available, and also they would be in all the different languages</p>
  
  <p>what i would like to find out is how can i have a form where i add the disease and it also update the relevant translation table.</p>
  
  <p>I have looked at the source code but at the moment its still bit hard to understand the data flow.</p>
  
  <p>To Clarify why i am thinking of separating the plugins data structure from crafts structure and not using elementsModel i will outline a more detailed plugin description</p>
  
  <p>The plugin will have Diseases with locales 
  Each Disease will have a Grid </p>
  
  <p>A Grid would have a table based layout where there would be treatments as columns ranging from 2-5 treatments for each grid </p>
  
  <p>And 5-15 questions about the effects of a disease as rows.</p>
  
  <p>the cells of the grid would be answers to a specific question for a specific treatment 
  a simple example would be :</p>
  
  <p><img src="https://i.sstatic.net/0xhMs.png" alt="Grid example"></p>
  
  <p>even with this very simple example i have 9 elements and if i have 5 locales it amounts to 45 entries in the database however most grids will have far more data</p>
  
  <p>Am i wrong into thinking that it will slow things down considerably ? </p>
  
  <p>A suggestion that would help me and probably other people as well would be extending the cocktail recipes plugin a bit so it would have:</p>
  
  <p>Cocktail Ingridients</p>
  
  <p>Cocktail Recipies (A group of ingridients)</p>
  
  <p>Locales integrated with both the ingridients and recipies</p>
  
  <p>This would provide an example for both the locale integration and more advanced relations between tables </p>
  
  <p>Thanks in advance </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-22T10:30:18.560Z
Comments.Text: Is there a reason why you want to make a plugin, and not just use different channels with entry relations, getting locale support "for free"? :)
Comments.UserDisplayName: André Elvan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-22T10:32:31.370Z
Comments.Text: The project has far more than just this structure, the idea is that each disease would have a some sort of a grid, a disease would have a few treatments and there would be also questions that would have answers for each treatment. SO a patient could potentially see what would be the consequences for choosing any specific treatment. there would be also a few other features including an interactive application. i think this goes a bit further than the default system would allow even if i used matrix
Comments.UserDisplayName: Gints Ligotnis
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-22T10:38:48.067Z
Comments.Text: Bassically what i want to know how to build complex structures while still being able to use craft functionality without doing some workarounds that would jeopardise the project some time in the future
Comments.UserDisplayName: Gints Ligotnis
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-22T11:11:29.637Z
Comments.Text: Ok. I don't think I can provide a single answer to this, the question is pretty broad. But maybe you should have a look at Element Types, I believe they give you functionality like localization, along with a bunch of other standard Craft functionality, "for free". Check out the videos at Straight Up Craft: http://straightupcraft.com/element-types
Comments.UserDisplayName: André Elvan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-22T13:17:06.743Z
Comments.Text: Thanks i have been looking at the videos and it all looks great, i have a question though.
Comments.UserDisplayName: Gints Ligotnis
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-22T13:25:19.963Z
Comments.Text: My application would potentially host lots of diseases and each would have 2-4 treatments. and also 5-15 questions so the total for this data alone would be quite a lot ( disease_count *( treatment_count + question_count + (treatment_count * question_count AS answers) ) * locales ) my concern is that each data here would add an entry in the elemets table and also in the table to store locale translations.
Comments.UserDisplayName: Gints Ligotnis
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-22T13:29:44.627Z
Comments.Text: In the end i think the queries would be kind of massive to process all this data as on top of what i mentioned registered members will give input any of the treatments . with such complex structure for me it made sense to separate the CMS from the plugin in terms of database tables so the joined tables would be limited as much as possible as there are already many relations, please advise if this wouldn't be a problem.
Comments.UserDisplayName: Gints Ligotnis
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-10-09T18:34:39.197Z
Comments.Text: Hi Gints, welcome to Craft Stack Exchange... Glad you're enjoying Craft! It looks like your question is very broad, and you've been asking several follow-up questions. The format of Stack Exchange promotes asking a **specific** question in order to get a **specific** answer. Since this question now covers a variety of subtopics, please break this up into more "bite-size" pieces, and ask separate questions for each challenge that you're facing. You can ask as many separate questions as you need to! This particular question will be closed as being "too broad".
Comments.UserDisplayName: Lindsey D
Tags: <plugin-development><localization><relations>
Title: Plugin with multiple locales and relations
ThreadText: # Plugin with multiple locales and relations
  
  (Asked by: username_0 on 2014-09-22)
  
  First i would like to say that Craft CMS really impresses me and im really interested in learning more about it
  
  However in a recent project i am having a bit of problems, i have looked at the sample cocktail recipes plugin and it all makes sense however my project is a bit more complicated than that, it adds about 10 new tables and i need to be able to use more than one locale
  
  I will describe a small portion of what im trying to achieve and maybe someone could point out where to look for some code examples within craft core files
  
  For the sake of this example i will have 4
  
  disease (diseaseSort)
  disease\_translation (diseaseId, locale, diseaseTranslation, diseaseTranslationDescription)
  treatment (diseaseId, treatmentSort)
  treatment\_translation (treatmentId, locale, treatment, treatmentDescription)
  
  The idea is we would have a list of diseases (in more languages)
  
  and each of those would also have multiple treatments that are available, and also they would be in all the different languages
  
  what i would like to find out is how can i have a form where i add the disease and it also update the relevant translation table.
  
  I have looked at the source code but at the moment its still bit hard to understand the data flow.
  
  To Clarify why i am thinking of separating the plugins data structure from crafts structure and not using elementsModel i will outline a more detailed plugin description
  
  The plugin will have Diseases with locales
  Each Disease will have a Grid
  
  A Grid would have a table based layout where there would be treatments as columns ranging from 2-5 treatments for each grid
  
  And 5-15 questions about the effects of a disease as rows.
  
  the cells of the grid would be answers to a specific question for a specific treatment
  a simple example would be :
  
  ![Grid example](https://i.sstatic.net/0xhMs.png)
  
  even with this very simple example i have 9 elements and if i have 5 locales it amounts to 45 entries in the database however most grids will have far more data
  
  Am i wrong into thinking that it will slow things down considerably ?
  
  A suggestion that would help me and probably other people as well would be extending the cocktail recipes plugin a bit so it would have:
  
  Cocktail Ingridients
  
  Cocktail Recipies (A group of ingridients)
  
  Locales integrated with both the ingridients and recipies
  
  This would provide an example for both the locale integration and more advanced relations between tables
  
  Thanks in advance
  
  **Tags:** plugin-development, localization, relations
  
  > **Comments:**
  > **username_1**: Is there a reason why you want to make a plugin, and not just use different channels with entry relations, getting locale support "for free"? :)  
  > **username_0**: The project has far more than just this structure, the idea is that each disease would have a some sort of a grid, a disease would have a few treatments and there would be also questions that would have answers for each treatment. SO a patient could potentially see what would be the consequences for choosing any specific treatment. there would be also a few other features including an interactive application. i think this goes a bit further than the default system would allow even if i used matrix  
  > **username_0**: Bassically what i want to know how to build complex structures while still being able to use craft functionality without doing some workarounds that would jeopardise the project some time in the future  
  > **username_1**: Ok. I don't think I can provide a single answer to this, the question is pretty broad. But maybe you should have a look at Element Types, I believe they give you functionality like localization, along with a bunch of other standard Craft functionality, "for free". Check out the videos at Straight Up Craft: http://straightupcraft.com/element-types  
  > **username_0**: Thanks i have been looking at the videos and it all looks great, i have a question though.  
  > **username_0**: My application would potentially host lots of diseases and each would have 2-4 treatments. and also 5-15 questions so the total for this data alone would be quite a lot ( disease_count *( treatment_count + question_count + (treatment_count * question_count AS answers) ) * locales ) my concern is that each data here would add an entry in the elemets table and also in the table to store locale translations.  
  > **username_0**: In the end i think the queries would be kind of massive to process all this data as on top of what i mentioned registered members will give input any of the treatments . with such complex structure for me it made sense to separate the CMS from the plugin in terms of database tables so the joined tables would be limited as much as possible as there are already many relations, please advise if this wouldn't be a problem.  
  > **username_2**: Hi username_0, welcome to Craft Stack Exchange... Glad you're enjoying Craft! It looks like your question is very broad, and you've been asking several follow-up questions. The format of Stack Exchange promotes asking a **specific** question in order to get a **specific** answer. Since this question now covers a variety of subtopics, please break this up into more "bite-size" pieces, and ask separate questions for each challenge that you're facing. You can ask as many separate questions as you need to! This particular question will be closed as being "too broad".  
  
  ---
  
  ## 0 answers
  
  