Creating an O2 DB

In O2, the logical database description is called the "Schema", and each schema can have many physical DBs associated with it. Normally there is just one, and that is what you will use. To access the proper system, start O2 using the command "o2 -system cse594 -toolsgraphic &". Then the general procedure is as follows:
  1. Create a schema (via the "Schemas" button’s "Schemas" menu). Call it whatever you like. You won't create a physical "base" until later in the process.
  2. Create the classes. Close the Schema Browser window and notice that your new schema is the current one displayed in the O2Tools window. Use the "Classes" button to open the Class Browser. Create a class. For our purposes, make the class definition "public" (not "private", as is the default) by checking the proper box. Type in the structural (type) definition for the class (e.g. "tuple (x: integer, y: string)") and compile the class (from the "Class" menu of the "Class Editor" window). Close the Class Editor window and then create your next class.
  3. When you have created all your classes, confirm all the classes using the "Classes" menu of the "Class Browser" window.
  4. Close the Class Browser window and use the "Schemas" button to create a new base (a physical place to hold data conforming to your new schema). Close the schema browser. You are now ready to populate your DB. You do this by specifying top-level named objects that will be the roots of persistence in this DB.
  5. Go to the Names button and create a top-level named object. As an example for the name’s type, you could use "set (foo)" if you have a class named "foo". Compile the name.
  6. To put data into this object, select the new named object in the Names Browser and from the Names menu select "Display". This function invokes a graphical data browser that also allows us to update the object in certain ways.
  7. You will see a window with a pencil, an eraser, and three empty boxes. Clicking the right mouse button on one of these empty boxes makes the "new" method available. Create a new object in this set now. The object now exists but it contains no data. Click the right mouse button on the object and use the "edit" method to enter some data into the object in place of the default values. Use the "pencil" button to save your changes to the new object and then again to save the changes to the named top-level object.
  8. Use the "Commit" button to make your changes permanent. Your data is now available for access from the browser, from OQL, and from O2C and other host languages.
  9. Celebrate. You’ve just created an OODB!
  10. NOTES: This version of O2 is a little weak in the CC department. In particular, you may notice it holding onto locks longer than necessary and thus preventing you from doing what you want. Also, I've experienced some odd mouse-button behavior in the past; if the specified button doesn't seem to do anything, try another one, or a combination of 2 or more mouse buttons at once.

    For your enjoyment, this account will remain active until sometime in March 2000.