« Wherefore art thou, blogroll? | Main| Apple Apple »

Mind Map of Database Design

Category Domino
If you haven't yet seen the mind map Chris created to describe the Notes URL protocol, check it out. I've played with mind maps, but it hadn't occurred to me to use them for training purposes, and in retrospect it makes sense.

One of the uses I've been hoping to expand Decepticon to support is to transform the entire design of a database into a mind map to provide a visual representation of application complexity. Trouble is, that's probably gonna require some serious XSLT. But a few minutes of tinkering with just some core LotusScript produced this. It maps (most of) the design element categories of my mail file. I left out image resources, because there are hundreds in the mail template, and that's apparently just too much data for poor old NotesDOMParser to serialize.

UPDATE: By request, here's the code of the agent that produces the XML which feeds the FreeMind applet:

'Declarations
Dim dbMail As NotesDatabase
Dim nodeDocument As NotesDOMDocumentNode
Dim nodeDbTitle As NotesDOMElementNode

Public Sub AnalyzeElementCategory (Byval p_strCategory As String)
    Dim ncElements As NotesNoteCollection
    Dim docElement As NotesDocument
    Dim nodeCategory As NotesDOMElementNode
    Dim nodeElement As NotesDOMElementNode
    Dim strNoteID As String
    
    Set ncElements = dbMail.CreateNoteCollection(False)    
    Select Case p_strCategory
    Case "Agents"
        Let ncElements.SelectAgents = True
    Case "Folders"
        Let ncElements.SelectFolders = True
    Case "Forms"
        Let ncElements.SelectForms = True
    Case "Framesets"
        Let ncElements.SelectFramesets = True
    Case "Outlines"
        Let ncElements.SelectOutlines = True
    Case "Pages"
        Let ncElements.SelectPages = True
    Case "Script Libraries"
        Let ncElements.SelectScriptLibraries = True
    Case "Shared Fields"
        Let ncElements.SelectSharedFields = True
    Case "Shared Files"
        Let ncElements.SelectMiscFormatElements = True
    Case "Shared Images"
        Let ncElements.SelectImageResources = True
    Case "Subforms"
        Let ncElements.SelectSubforms = True
    Case "Views"
        Let ncElements.SelectViews = True    
    End Select
    
    Call ncElements.BuildCollection()
    If (ncElements.Count > 0) Then
        Set nodeCategory = nodeDocument.CreateElementNode("node")
        Call nodeCategory.SetAttribute("text", p_strCategory & { (} & ncElements.Count & {)})    
        Call nodeCategory.SetAttribute("folded","true")
        Let strNoteID = ncElements.GetFirstNoteId()
        Do While (Len(strNoteID) > 0)
            Set docElement = dbMail.GetDocumentByID(strNoteID)
            Set nodeElement = nodeDocument.CreateElementNode("node")
            Call nodeElement.SetAttribute("text",Replace(docElement.GetItemValue("$TITLE")(0),{'},{'}))
            Call nodeCategory.AppendChild(nodeElement)
            Let strNoteID = ncElements.GetNextNoteId(strNoteID)
        Loop
        Call nodeDbTitle.AppendChild(nodeCategory)
    End If
End Sub

Sub Initialize
    Dim sesCurrent As New NotesSession    
    Dim dompDesign As NotesDOMParser    
    Dim nodeMap As NotesDOMElementNode
    Dim nodeRoot As NotesDOMElementNode
    Dim strmInput As NotesStream
    Dim strmOutput As NotesStream
    On Error Goto errorHandler
    
    Set dbMail = sesCurrent.GetDatabase("","mail\ttripcon.nsf") 'lazy hardcoding...
    Set strmInput = sesCurrent.CreateStream()
    Call strmInput.WriteText("<map />") 'Becomes root node for the output XML
    Set strmOutput = sesCurrent.CreateStream()
    Set dompDesign = sesCurrent.CreateDOMParser(strmInput,strmOutput)
    Call dompDesign.Process()
    Set nodeDocument = dompDesign.Document
    Set nodeRoot = nodeDocument.DocumentElement
    Set nodeDbTitle = nodeDocument.CreateElementNode ("node")
    Call nodeDbTitle.SetAttribute("text",dbMail.Title)
    Call nodeRoot.AppendChild(nodeDbTitle)
    Call AnalyzeElementCategory("Agents")
    Call AnalyzeElementCategory("Folders")
    Call AnalyzeElementCategory("Forms")
    Call AnalyzeElementCategory("Framesets")
    Call AnalyzeElementCategory("Outlines")
    Call AnalyzeElementCategory("Pages")
    Call AnalyzeElementCategory("Script Libraries")
    Call AnalyzeElementCategory("Shared Fields")
    Call AnalyzeElementCategory("Shared Files")
    Call AnalyzeElementCategory("Subforms")
    Call AnalyzeElementCategory("Views")
    Call dompDesign.Serialize()
    
    Print {Content-type: text/plain}
    Let strmOutput.Position = 0
    Print strmOutput.ReadText()
    Exit Sub
errorHandler:
    Print {Error in line } & Erl() & {: } & Error$
    Exit Sub
End Sub

Enjoy...

Comments

Gravatar Image1 - Holy cow...you guys @ Lotus911 are geniuses! That's really cool, Tim! Although I've thought about it, I've never created a mind map for a database design because...well because I'm lazy and didn't want to type it all out. If you are able to do this with code, it could prove to be very valuable.

I find working with mind maps on technology topics helps me get a better understanding of the big picture and visualize connections between elements and concepts that I might not otherwise have seen. Very nice work! I look forward to learning more about Decepticon.

Gravatar Image2 - Sounds like a pretty sweet idea. Using your example link above seems to be throwing a Java error in the applet. ArrayIndexOutOfBounds....

Gravatar Image3 - can you post the script Tim? I would like to expand it a bit

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)

Hire Me

Elsewhere

What the Quote?

"No, you're a twit. Sorta like a tool, only not as useful."

Steven Rodgers

"Put that on your Quote Board and smoke it."

Laura Tripcony

"Gentle, sweetie. Don't eat Daddy's leg. Good girl."

Tim Tripcony

"They're all flying to Hawaii to reenact Pearl Habor Day tomorrow."

Steven Rodgers

"You're a drunken prom queen."

Laura Tripcony

Apparel

Lotus Rocks

I write the code that makes the young girls cry