Msj Databasev7 1

  • View
    214

  • Download
    0

Embed Size (px)

Text of Msj Databasev7 1

  • 8/3/2019 Msj Databasev7 1

    1/54

    MicroStation/J Tutorial Workbook 13-1

    13 Creating Database LinkagesThis tutorial serves as an introduction to attaching database linkages to elements inMicroStation/J.

    PreviewWithin this tutorial are exercises to help you learn about:

    Establishing a database linkage between an element and arow in the database.

    Defining the Active Entity graphically.

    Establishing database linkages to fenced elements.

    Todo thistutorialyoumusthavepreviouslyperformedtheproceduresinSettingUpfortheDatabaseInterfaceinChapter4intheAdministratorsGuidefor setting up the database for MicroStation/J, setting upMicroStation/J for the database, and connecting to the database fromwithin MicroStation/J.

    Prepare for the first exercises

    1. Open the design file cd9.dgn, which is located in MicroStation/JsWorkspace/projects/tutorials/intro/dgn directory.

    This file is installed when you select the database utilities wheninstalling MicroStation/J on your system.

    2. Turn off all views except 1 and 2.

    3. From the Window menu, choose Tile.

    4. Use the Fit Viewview control to fit views 1 and 2.

    5. In View 2, use theWindow Areaview control to magnify the displayof the lower left parcel of land.

    314_dbif.fra Page 1 Thursday, May 20, 1999 9:05 AM

  • 8/3/2019 Msj Databasev7 1

    2/54

    13

    13-2 MicroStation/J Tutorial Workbook

    Creating Database LinkagesEstablishing a database linkage

    6. From the File menu, choose Save Settings (or press ).

    Views 1 and 2 set up for the first exercises.

    With the views set up, the next step is to connect to the database. Thisprocedure will vary depending on your setup. Typically, it can be doneusing a string that was defined in the setting up procedures.

    Connect to the database

    1. From the Settings menus Database sub-menu, choose Connect.

    The Connect to Database dialog box opens.

    2. From the Database Server option menu, choose the database serverthat you wish to use, such as ODBC.

    3. In the Connect String field:

    key in the string that you defined in the setting up procedures.

    OR

    key in *, to select the data source.

    4. Click OK.

    Connect to Database dialog box.

    Establishing a database linkage

    The design file (cd9.dgn) contains a sectional map of a suburban area.The centroid of each parcel is marked by a cyan (light blue) dot. Each dot

    314_dbif.fra Page 2 Thursday, May 20, 1999 9:05 AM

  • 8/3/2019 Msj Databasev7 1

    3/54

    Creating Database LinkagesEstablishing a database linkage

    MicroStation/J Tutorial Workbook 13-3

    isactuallyapoint(zerolengthlineelement),whichhasaheavylineweight

    for easy visibility. Parcel outlines are indicated by grey lines. This designfilecontainsdatabaselinks.Forexample,eachcentroiddothasadatabaseattribute, which can be reviewed.

    Review the database attribute for parcel number 10

    1. From the Tools menu choose Database.

    The Database tool box opens.

    2. In the Database tool box, select the Review Database Attributes ofElementtool.

    3. In View 2, identify the cyan centroid dot for parcel number 10.

    The dot highlights.

    4. Accept.

    The SQL Window opens, displaying the database attribute.

    5. Use the scroll bar, and/or the Next button to review all the databaseattributes attached to the element.

    SQL Window displaying the database attributes attached to Parcel 10.

    Establishing linkages to an SQL database is as simple as querying thedatabase. MicroStation/J uses a seedrow called theActiveEntityto

    insert values into a special table namedAE. This seed row can be copiedfrom an existing row in the database or you can create it directly. TheActive Entity can be edited from within MicroStation/J before it is linkedto an element.

    314_dbif.fra Page 3 Thursday, May 20, 1999 9:05 AM

  • 8/3/2019 Msj Databasev7 1

    4/54

    13

    13-4 MicroStation/J Tutorial Workbook

    Creating Database LinkagesEstablishing a database linkage

    Before continuing, the Linkage Mode should be checked and, if

    necessary, set to New.

    Check the Linkage Mode setting

    1. In the Database tool box, select the Show Linkage Modetool.

    The linkage mode displays in the status bar.

    If the linkage mode displayed is not New then it must be changed.

    If necessary, change the linkage mode to New

    1. From the Settings menu, choose Database > Dialog.

    The Database settings box opens.

    2. From the Linkage Mode option menu, choose New.

    3. Close the Database settings box.

    Defining the Active Entity

    One way to define the Active Entity is with the ACTIVE ENTITY (AE=)key-in, which includes an SQL INSERT statement.

    Define the Active Entity as a seed row for theparceltable withan attribute value forowner

    1. In the Key-in Window, key in:

    AE= insert into parcel (owner) values ('John Smith')

    (Press to complete the operation.)

    This does not insert a row in parcel, rather it inserts a row in the ActiveEntity table with the structure of parcel and an owner value of JohnSmith.

    314_dbif.fra Page 4 Thursday, May 20, 1999 9:05 AM

  • 8/3/2019 Msj Databasev7 1

    5/54

    Creating Database LinkagesDefining the Active Entity

    MicroStation/J Tutorial Workbook 13-5

    Confirm the creation of the Active Entity

    1. In the Database tool box, select the Show Active Entitytool.

    The SQL Window shows the seed row forparcel. All values in theAE table are empty except those specified in the AE= key-in.

    This valuecan be linked to any parcel in the parcel table. For this exercise,we will link it to the lower left parcel (number 10), displayed in View 2.

    Establish a linkage from parcel number 10 to theparcel table

    1. In the Database tool box, select the Attach Active Entitytool.

    2. In View 2, identify the cyan centroid dot for parcel number 10.

    The centroid dot for the parcel highlights.

    3. Accept the parcel.

    The linkage is established.

    When you attach a linkage to an element, two values are saved with theelement. One is an entity number that uniquely identifies the table in thedatabase. The other value ismslink that relates the element to a specificrow in the table.

    Review the linkages between the parcel table and the parcel

    1. In the Database tool box, select the Review Database Attributes ofElementtool.

    2. In View 2, identify the centroid dot for parcel number 10.

    3. Accept the parcel.

    TheSQLWindowdisplaysthesamelinkageasseenpreviously.Clickthe Next button to retrieve successive linkages.

    The linkage you just established is the last one. Notice themslinkkey value was replaced with a unique number for MicroStation/Js

    314_dbif.fra Page 5 Thursday, May 20, 1999 9:05 AM

  • 8/3/2019 Msj Databasev7 1

    6/54

    13

    13-6 MicroStation/J Tutorial Workbook

    Creating Database LinkagesEstablishing a database linkage

    use. MicroStation/J uses themslinkkey to access information in the

    database.

    SQL Window displaying the just attached database linkage

    WhentheAttach ActiveEntitytoolisusedinNewlinkagemode,asabove,the Active Entity is copied into the primary database table (parcelin thisexample), thereby creating a unique linkage to that row. The ACTIVEENTITY (AE=) key-in works only in New linkage mode; it does notrequire an existing seed row in the table.

    Defining the Active Entity graphically

    YoucanusetheDefineActiveEntityGraphicallytooltosettheActiveEntitydefinition to match an existing database row. The Active Entity assumesall database attributes of the element to which the row is linked. In thefollowingexample you will firstplacea textelement. Youwill then locatean Active Entity graphically and attach a linkage to the new text element.

    Prepare for the exercise

    1. In View 2, use the View controls to select a blank area in the designplane.

    2. In the Main tool box, select the Place Texttool

    3. Place some text in View 2.

    4. If necessary, use the View controls to magnify the text so that it isvisible.

    5. In View 1, use theWindow Areaview control to magnify part of the

    subdivision, to display several parcels.This will make it easier to identify centroid points of several parcels.

    314_dbif.fra Page 6 Thursday, May 20, 1999 9:05 AM

  • 8/3/2019 Msj Databasev7 1

    7/54

    Creating Database LinkagesEstablishing database linkages to fenced elements

    MicroStation/J Tutorial Workbook 13-7

    Set the Active Entity graphically

    1. In the Database tool box, select theDefine Active Entity Graphicallytool.

    2. In View 1, identify any parcel on its centroid.

    3. Accept the parcel.

    If Confirm Rows is off in the Database settings box, the first rowlinked to the element is set as the Active Entity.

    If Confirm Rows is on, the first row is displayed in the SQL Window.If there is more than one linked row, you can click the Next buttonto reject rows. To accept a row as the Active Entity, click the Acceptbutton. To return to step 2, click the Stop button.

    4. Use theShow Active Entitytool to display the new Active Entity in the

    SQL Window.

    Link the Active Entity to the text element

    1. In the Database tool box, select the Attach Active Entitytool.

    2. In View 2, identify the text element.

    The text highlights.

    3. Accept the text element.

    If Linkage Mode is set to Duplicate in the Database settings box, thetext element is linked to the same row as the parcel centroid. IfLinkage Mode is set to New, a new row is created in the table and thelinkage is to that row.

    4. UsetheReviewDa