Hello
we have a Ruby on Rails app that we want to “reverse engineer” into TDM. Rails uses a convention where FK relationships have a suffix of _id. For example, in a case where an exam result has the student’s ID in it you will see that the “exam_result” table will have a column called “student_id”. In the Ruby on Rails world, you can then expect to see a “student” table with a PK called “ID”. All tables in our database have an integer ID column as a PK.
All of the relationships between the entities are described in the Rails Models so there is nothing in the database in terms of formal FK constraints.
My question is this – is there a way to have TDM automagically create relationships based on the aforementioned convention?
Thanks in advance,
Michael
Hi,
can you send me a sample model, please? I believe it should be easy to modify the infer relationship macro (menu Macros | All | Infer Relationship) but I would like to do tests on real example.
Regards,
Vaclav
Vaclav
thanks for the response – here’s a sample model as specified in rails for the “medicine” model:
create_table “medicine”, :force => true do |t|
t.string “sku”, :limit => 50
t.string “lic_number”, :limit => 50
t.string “name”, :limit => 50
t.datetime “lic_startdate”
t.datetime “lic_enddate”
t.integer “medicine_manufacturer_id”, :limit => 8
t.boolean “active”, :default => true
t.datetime “created_at”
t.datetime “updated_at”
end
And here’s the model for “medicine_manufacturer”
create_table “medicine_manufacturer”, :force => true do |t|
t.string “lic_number”, :limit => 50
t.string “name”, :limit => 50
t.string “addr1”, :limit => 50
t.string “addr2”, :limit => 50
t.string “town”, :limit => 50
t.string “postcode”, :limit => 50
end
In both cases you may be wondering “where’s the ID?!?” – Rails creates an id column in each table by convention so the medicine_manufacturer_id can be assumed to refer to the ID column of the medicine_manufacturer model.
I hope this is the info you were looking for – if not, I can try again.
Thanks
Michael
Message was edited by: Father Ted
Hi,
thank you. I’ll reply next week.
Have a nice weekend,
Vaclav
Hi,
my co-worker Petr created a script (attached) that infers relationships in the structure you described. Please import the custom package and then open your model and click Macros | Infer Relatinships (Ruby).
How to import custom packages:
http://blogs.inside.quest.com/modeling/2010/10/21/how-to-import-custom-packages/
I will upload it to our library after receiving your feedback.
Regards,
Vaclav & Petr
InferRelationshipsRuby.zip (2.72 KB)
Brilliant, brilliant, brilliant. Great support service. Your script worked perfectly and quickly.
Many thanks
Michael
Hi Michael,
Thank you for the confirmation. I added the file to our Library.
http://modeling.inside.quest.com/kbcategory.jspa?categoryID=34
Regards,
Vaclav