The Quick Start Guide

When you run "Apricot DB" for the first time, the application screen looks something like this: 

It is an empty Project created for you. You can rename this Project as you want and continue working with it, or create a new Project.

There are two main starting points supported by "Apricot DB":
* Start a new database structure from scratch (read below in this article);
* Use an existing database structure (more details here: The Reverse Engineering Quick Guide).

It is recommended to set two important parameters of the current Project: the database type and the ERD- notation. In the toolbar push the "Edit Project" button: 

In the Project editing form set the Project Name, Project Database and ERD Notation. The Project details can be changed any time later as well.

 Creating a new database structure from scratch

Create a new entity. To do that user the button on the toolbar as shown below.


In the form of edition of the new Entity fill the name and the columns of the Entity.

You can choose the type of the column from the drop down list or, if the required type is not presented in the list, just manually put it into the field.

The constraints and indexes can be added/edited in the second tab of the form: "Indexes and Constraints":

Push the "Save" button on the form to save the changes made.

The newly created Entity will be presented in the working area of the entity/relationship designer:

 The entity can be moved with the mouse.

Use the "Save" button (or Ctrl+S) to save the changes made in the allocation of the entities/constraints.

Let's create another Entity and a Relationship between them:

I've just created a new Entity called "DEPARTMENT". As every Employee has to belong one Department, let's create a Relationship between them. The DEPARTMENT will be a "parent" in this Relationship and the EMPLOYEE will be the "child".
In order to do this, select both DEPARTMENT and EMPLOYEE. Use <Ctrl> button pushed while selecting, to select several entities. Then push the "Create Relationship" button on the toolbar:


Give the new Relationship a reasonable and recognizable name. Ensure, that "parent" and "child" of the relationship are properly set. In our case it is important, that the DEPARTMENT entity stays on the left as a "parent" and the EMPLOYEE to be a "child". If the form presents the entities incorrectly, use the "Swap" button to swap the "parent" and "child" entities.

The Foreign Key of the Relationship: there is a set of drop down lists on the right (the "child") side of the form. If the Foreign Key field(s) exist, you can just choose them from the list. Otherwise, if the Foreign Key field is not presented in the "child" Entity yet, you can put a new field name in it. In my example I manually added "DEPARTMENT_ID" field name as a Foreign Key field on the "child" side. I also checked on the "Not null" flag. This makes the field (column) DEPARTMENT_ID to be created "not null" on the "child" (EMPLOYEE) side. If to check on the "PK" flag, the new field will be added into the Primary Key of the EMPLOYEE entity.

This is a brand new Relationship just created:

The DEPARTMENT_ID field was created automatically, together with the Relationship.

 Now, each EMPLOYEE should have a person he/see has been reporting to. Let's extend the EMPLOYEE entity to support this information. As the "Patron" person is an EMPLOYEE too, we need a Relationship between EMPLOYEE and EMPLOYEE (the auto- relationship).
Select the EMPLOYEE entity and push "Create a new Relationship" button on the toolbar. Here is the information I've put into the form:


The EMPLOYEE is a "parent" and "child" of the Relationship. I've designated the FK field as "REPORTING_TO_ID", not null. This field will be created automatically:


The "auto"-relationship was created (see the picture above).

Each DEPARTMENT should have a manager or managers. If a structure of the DEPARTMENT is complex, there will be more than one manager, with deputies and so on. I will create a new Entity called "MANAGER" and link it with other Entities accordingly. This is the result of this change on my diagram:



Now, after our diagram is ready, let "Apricot DB" generates the CREATE- script:
Select all objects on the diagram with <Ctrl>+A;
Copy the selected into the Clipboard (<Ctrl>+C);
Open the text editor of your choice and paste the content of the Clipboard into it (<Ctrl>+V).

The result might look like this: