Profile Picture

Database Table Shapes and Mapping

Posted By Montford Chelliah 14 Years Ago
Author
Message
Montford Chelliah
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 12, Visits: 1

Hi,

 

I have a tree control and that contains two databases with tables as tree nodes. I have a requirement to drag couple of tables from these databases (from tree) and drop on them as Nevron shape on Nevron canvas. What is the recommended shape you suggest? (I need to display table columns and data type and PK/FK relation text)

 

After drag and drop of these tables, I need to visually map the fields between tables using Nevron connectors, what type of connector shape can I use?

 

After mapping the fields visually, I need to identify the mapping relationship (which field is mapped with which field between table shapes) by .NET code in the diagram.  How can I do this?

 

Please suggest me the recommended shapes and methodology. I have tried couple of shapes (NErmShape and NTableShape) I could not find out the mapping relationship.

 

Thanks in advance.

 

 

Regards

Montford Anslum



Pavel Vladov
Posted 14 Years Ago
View Quick Profile
Forum Member

Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)

Group: Forum Members
Last Active: 7 Years Ago
Posts: 33, Visits: 2

Hi Montford,

If you use the database schema importer it will automatically create diagram shapes (of type NErmShape) for the tables and connect them based on their relationships. For an example of how to use the database schema importer take a look at this online example.

Questions or comments, please let me know.


Best Regards,
Pavel Vladov



Montford Chelliah
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 12, Visits: 1

Hi Pavel,

Thanks for the reply. I saw that sample on you web site but I don't want to generate the ER diagram dynamically rather user go and manually do the drag and drop the tables on the Nevron canvas and maps the fields individually.

For example,

Database A has Patient table (fields such as Id, Firstname, Lastname, Address1, Address2) and Database B also has PatientDemographic table (fields such as PatientId, Firstname, Surname, AddressOne, AddressTwo) with different field names. I need to transfer the records from Patient (Database A) table to PatientDemographic (Database B) table. So using Nevron, user needs to visually drag Patient table from Database A and PatientDemographic from Database B, then map field by field using Nevron connectors (say Patient.Id is mapped with PatientDemographic.PatientId, Patient.Firstname is mapped with PatientDemographic.Firstname, Patient.Lastname is mapped with PatientDemographic.Surname ct.). After finished the mapping, user will click save button, I need to programatically go through the Nevron shapes and find out which field is mapped which field then save the results into database.

So this is my requirement. Please give a right direction.

 

Regards

Montford Anslum

 



Pavel Vladov
Posted 14 Years Ago
View Quick Profile
Forum Member

Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)

Group: Forum Members
Last Active: 7 Years Ago
Posts: 33, Visits: 2
Hi Montford,

I understood your requirement. What you have to do is to manually create custom ERM shape for each table, when the user drags it into the drawing view. You can easily do this by using code similar to:

NErmShape shape = new NErmShape(0, 0, 10, 10);
shape.CreateFromTable(dataTable);


Where dataTable is the table that the user has dragged into the drawing view. Next you can provide the user with the ability to connect the tables using Erm connectors.

Best Regards,
Pavel Vladov

Montford Chelliah
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 12, Visits: 1

Hi Pavel,

Could you please provide the sample code of NErmshape object. I could not found any sample application in your product samples (with the Nevron product installation). I have tried the way you suggest, I have following problems.

(1) How do I enable the Erm connector on drawing space? I have found only single connector to connect multiple shapes (like NDWFR.TooltipConnectToPort)

view.Controller.Tools.SingleEnableTool(NDWFR.TooltipConnectToPort)

(2) How do I resize the NErmshape object after populate the table object. It does not resize according to the text.

Dim shape As New NErmShape(0, 0, 10, 10)

' Populate the data table......

shape.SizeToContent()

(3) How do I include the data type column next to field column in NErmShape

Thanks

Regards

Montford Anslum

 



Pavel Vladov
Posted 14 Years Ago
View Quick Profile
Forum Member

Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)

Group: Forum Members
Last Active: 7 Years Ago
Posts: 33, Visits: 2
Hi Montford,
regarding your questions:

1. The code to activate the erm connector tool is:

NCreateConnectorTool tool = (view.Controller.Tools.GetToolByName(NDWFR.ToolCreateConnector) as NCreateConnectorTool);
if (tool == null)
return;

tool.ConnectorType = ConnectorType.ErmConnector;
view.Controller.Tools.SingleEnableTool(NDWFR.ToolCreateConnector);


Unfortunatelly, I've discovered that there's a bug when activating this tool, but I've fixed it, and it will work fine in the upcoming service pack (it is going to be released today or tomorrow) of our component.

2. In order to work properly, the SizeToContent() method of the erm shape should be called after the shape is added to the drawing document.

3. The erm shapes does not support adding such information. If you need to show more details than just the name of the column and its relation type (i.e. PK = private key or FK = foreign key), I suggest you take a look at the table shape and the UML shape examples.

Best Regards,
Pavel

Montford Chelliah
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 12, Visits: 1

Hi Pavel,

Thanks for the idea, I have tried with NTableShape object and the sample is attached herewith. Using NTableShape object I am facing a problem to identify the mappings ports and plugs. Please review my sample and identify the fault.

Thanks

Regards

Montford Anslum



Attachments
TestNevron.zip (120 views, 48.00 KB)
Pavel Vladov
Posted 14 Years Ago
View Quick Profile
Forum Member

Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)

Group: Forum Members
Last Active: 7 Years Ago
Posts: 33, Visits: 2
Hi Montford,

I've examined your code and I've attached the working solution. Some important thigs I would like to bring to your attention are:

1. When you are setting the content of table shapes use the BeginUpdate and EndUpdate method of the table shape. This will greatly improve the performance. Take a look at this topic for more information.

2. To find out the relations all you have to do is to loop through the 1D shapes of the document's active layer. For example:

    NNodeList links = document.ActiveLayer.Children(NFilters.Shape1D);
    int linkCount = links.Count;
    for (int i = 0; i < linkCount; i++)
    {
        NBezierCurveShape link = links[i] as NBezierCurveShape;
        if (link != null)
        {
            // Display a meassage for the current relation
            DisplayMessage(link);
        }
    }

3. Please, take advantage of the Name property of the NShape class and set the table names to this property, so that you can easily retrieve it later. This eliminates the need to use dictionaries in your data object adapter class.

If you have any other questions, I'll be glad to help.

Best Regards,
Pavel

Attachments
TestForm.cs (179 views, 11.00 KB)
Montford Chelliah
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 12, Visits: 1

Hi Pavel,

Thanks so much for the help and direction. I am going to add more functionality on that code. If I face any problem I will send you the details on the this thread.

Thanks

Regards

Montford Anslum



Montford Chelliah
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 12, Visits: 1

Hi Pavel,

I am using Microsoft Smart Client Software Factory. I have different work spaces. One workspace I am loading by tree with tables nodes (one user control) and the other workspace I am loading Nevron drawing view (another user control) dynamically.

I have a requirement to validate the mapping between NTableShape shapes when using connectors. I am using NDrawingView's NodeSelecting event for validating the items are selected. Unfortunately this event is not raising when I select any of shapes in NDrawingView object.

Same validation I have done without using the Microsoft Smart Client Software Factory (put everything on a single Win Form object) then the NodeSelecting event is raising successfully.

Please give me your thoughts.

Thanks

Regards

Montford Anslum

 

 





Similar Topics


Reading This Topic