Understanding Relational Database with myNet.Dbase

What is Database Relationship?

We are living in the world that all connected with information. Database is where information warehousing. Database Relationship is the relation between databases and tables that define the way how we organize and process data and information. It is so important that a small error from bad design can lead to misinformation, data integrity . And thus your business who depends on that database. On the other hand, if designed properly, it will help your business a lot in term of processing, collecting and sharing data and information.
In real life, your tables now are not stand alone, but they have the relationship with other tables. So that from one table you can relate data from other tables. There are 3 database relationships: One-to-One, One-to-Many, Many-to-Many.

I don't need  Database Relationship now. I design my own way?

It is ok if you design stand alone simple database. But if you don't setup the relationship between Customer table and Invoice table, you will not be able to request information from one to another.
Such as: - What is the Customer ID (Name, Address, Contact..) of this Invoice 1002? - How many _acme_invoices that the Customer XYZ Inc has purchased? What are they?

Without Database Relationship, database is like a junk and disorganized warehouse. Every thing is disconnected. It is hard to find information. When your database grows bigger. It is too late to organize them.

Who make up the Database Relationship?

You are the one who makes up the database relationship based on these factors:
Common sense. Such as the relationship between Customers and Invoices table. It is always true that a Customer buys many things and thus has many invoices. But an Invoice, number 11235 for example, belongs only one customer.
The logistic collecting information of your business. For example the relationship between Projects and Employees table. In this case, it is Many-to-Many. But for other businesses, they require each Project can be assigned to many Employees, and one Employee can be assigned to one Project at a time. So the relationship now is not Many-to-Many, but One-to-Many.
NOTE: Relational Database is only supported by database that is built in this feature.

Can I use myNet.Dbase within my home or office computers, VPN, Intranet, then sharing and collaborating without on the Net?

• Yes, definitely! You can get it running in 5 minutes with the installation.
1) Business may not need website, but
it needs database. You install myNet.Office on one PC in your home, or  in office. See  myNet.Office installation instruction. That is it. DONE in 5 minutes. Now all computers within Home or Office can use myNet.Office by accessing its I.P address. See how below.
2) Check myNet.Office computer's I.P address by:
-
Start -> Run -> Cmd -> DOS screen -> type: >  ipconfig  /all -> Will give the I.P address of computer that installed myNet.Office, such as: 192.168.0.101.  
Run myNet.Dbase computer. From any computer in your home, in office, in VPN, or Intranet that link together by router, you access to myNet.Office by:
- Open any PC's
Web browser -> Type: http://192.168.0.101, the I.P Address of myNet.Office's PC -> Goto its site -> Login as Admin -> Now you can Access, Work and Collaborate myNet.Dbase with others within your Home, Office, Intranet. You don't even need Networking all local computers. You don't need to be on the Net to use myNet.Dbase. Of course, you can always Publish your database online any time.
If your business has locations separated far away, let say one is in Toronto, one is in Downtown or Vancouver. You don't have VPS, Network, or anything that links them. Then Self-Host is the best option to use myNet.Dbase. Use myNet.Page creates an internal company website. No publish on the Net. No body outside can see. Any location, any where on earth, employees can access the company web database securely login through the Internet using static I.P address (get it from your local Internet provider) or Domain name if you have one.

myNet.Dbase is a Client/Server, Relationship, and Web Database.

So what is a Client/Server, Relationship, and Web Database?
Not all databases are relational, and not all relational databases are built on the client/server paradigm. But most of the time you'll want a relational database server, so it's important to clarify the distinction.

myNet.Dbase is a true Client/Server Database.  A Java Technology and heavy duty database server.
  1. Allows multi users access, retrieve, and fast database operation (Insert, Update, Delete..). For example, PC Database is not a Client/Server database. It is good for a single user uses. Ms SQL Server, or MySQL,  is a true client/server multi users database. XP is a single user OS. But Windows 2003 Server is a multi users client/server OS.
  2. Lets you retrieve data very fast by scrolling row, and not loading them all. While non Client/Server database is flat, and retrieves all data every time it loads. You can't scroll them. For example, if your database has 1 million records of data. A none Client/Server database will load them all. But a Client/Server loads only 10 records at a time( or what ever you define how many rows to load ).
  3. Scalability not Flat. 1 millions records or 10 records, the speed and the operation are the same.

myNet.Dbase is a true Relational Database. Not all database applications are relational database.

  1. A relational database management system (RDBMS) is a database management system (DBMS) that is based on the relational model as introduced by E. F. Codd. Relational databases are the most common kind of database in use today.
  2. Relational databases are created using a special computer language, structured query language (SQL). So you have the power of SQL built -in the database.

myNet.Dbase is a Web Database. It is:

  1. Location Independent – Your data is available wherever you have access to the Internet. You don't even need myNet.Dbase on the Net. Because myNet.Dbase is built-in Self-Host. You access it  from I.P address: http://192.168.0.101 (or what ever your I.P address -Check run: Ipconfig /all command from DOS screen). If you have static I.P address, then you can access anywhere. It is simple: Install->Access-> Login -> Sharing and Collaboration. That is it!
  2. Ease of Sharing and Collaboration – With myNet.Dbase, you can share data with as many people as you want, regardless of their physical location. myNet.Dbase is a multi-user system, so several people can work within one account, all at the same time. Collaboration, Collaboration, and Collaboration!
  3. Scalability – A typical desktop database is designed for one person to use. myNet.Dbase is a powerful client/server-based database platform. This way, it can meet your company's needs, regardless of its size. This means your data can grow exponentially without the restrictive limits of a desktop computer's memory, storage, and processing power.
  4. Simple Integration with your Web Sites – Data is not very useful if it cannot be easily accessed online. myNet.Dbase helps you create custom forms, reports, and complete end-to-end applications without having to learn or use a programming language. Your database and the data it holds, and can be easily placed on your own web site.

How is myNet.Dbase dealing with Database Relationship?

We make the technology simplicity out of complexity in our design. We create a tool [Database Relationship Manager] in myNet.Dbase to help you create the database relationship. But first, let understand a bit about the background.

Developing the Basic Schema Relational Database

Once entities and relationships have been identified and defined, the first draft of the entity relationship diagram can be created. This section introduces the ER diagram by demonstrating how to diagram binary relationships. Recursive relationships are also shown.

Figure 1 shows examples of how to diagram one-to-one, one-to-many, and many-to-many relationships.

Figure 1: Example of Binary Relationships
Examples of of one-to-one, one-to-many, and many-to-many relationships

One-To-One

Figure 1A shows an example of a one-to-one diagram. Reading the diagram from left to right represents the relationship every employee is assigned a workstation. Because every employee must have a workstation, the symbol for mandatory existence—in this case the crossbar—is placed next to the WORKSTATION entity. Reading from right to left, the diagram shows that not all workstation are assigned to employees. This condition may reflect that some workstations are kept for spares or for loans. Therefore, we use the symbol for optional existence, the circle, next to EMPLOYEE. The cardinality and existence of a relationship must be derived from the "business rules" of the organization. For example, if all workstations owned by an organization were assigned to employees, then the circle would be replaced by a crossbar to indicate mandatory existence.

The Relational Tables is _acme_employees and _acme_workoffice is One-to-One.  
CREATE TABLE _acme_employees (
EID int not null auto_increment primary key, /* Primary Key  of _acme_employees */
WID int, /* Foreign Key */
NAME varchar(20),
PHOTO varchar(20),
ADDRESS varchar(200),
PHONE varchar(20),
EMAIL varchar(50)
/* ..more fields ..*/
);
DBR Formula:
_acme_employees (1) -> WID -> (1)-> _acme_workoffice
CREATE TABLE _acme_workoffice (
WID int not null auto_increment primary key, /* Primary Key  of _acme_workoffice*/
EID int , /* Foreign Key */
TYPE enum ("Tech support",
"Marketing", "Accounting", "Software Developer", "Manager" )
/* ..more fields ..*/
);
DBR Formula:
_acme_workoffice (1) -> EID -> (1)-> _acme_employees
The Setup: 2 steps:
1)
Put the Primary Key ( EID ) of one table (_acme_employees) to become the Foreign Key of the related table _acme_workoffice, and vice versa.
2) Use [myNet.Dbase] -> [Database Relationship Manager] tool to establish the relationship between them. That is it. DONE in 5 minutes.
NOTE: You can use EID as Primary Key for _acme_workoffice. There is no need to create WID primary key.
 

One-To-Many (the most popular relationship)

Figure 1B shows an example of a one-to-many relationship between DEPARTMENT and PROJECT. In this diagram, DEPARTMENT is considered the parent entity while PROJECT is the child. Reading from left to right, the diagram represents departments may be responsible for many projects. The optionality of the relationship reflects the "business rule" that not all departments in the organization will be responsible for managing projects. Reading from right to left, the diagram tells us that every project must be the responsibility of exactly one department.

The Relational Tables:  
CREATE TABLE _acme_department
(
DID int not null auto_increment primary key, /* Department ID = PM Key */
DEP_NAME enum ("Engineering", "Human Resources", "Marketing", "Accounting", "Software Development")
/* ..more fields ..*/
);
DBR Formula: Department (1) -> DID -> (m)-> _acme_project
Which means: One Department has managed many Projects.
CREATE TABLE _acme_project (
PID int not null auto_increment primary key,
DID int,  /* Foreign Key */
PRJ_CODE varchar(20),
PRJ_COST double,
PRJ_FUNDING double,
PRJ_DESCRIPTION varchar(20),
PROJECT_START_DATE date,
PROJECT_END_DATE date,
SUBJECT PRJ_TYPE enum ("Tech Support", "Marketing", "Accounting", "Software Developer"),
DESCRIPTION text
/* ..more fields ..*/
);
DBR Formula: _acme_project (1) -> DID -> (1)-> Department
Which means: One Projects is managed by One Department only.
The Setup to establish the One-to-Many relationship between _acme_department and _acme_project 2 steps:
1)
Put the Primary Key ( DID ) of main table (_acme_department) to become the Foreign Key of the related table _acme_project.
2) Use [myNet.Dbase] -> [Database Relationship Manager] tool to establish the relationship between them. That is it. DONE in 5 minutes.
 
CREATE TABLE _acme_Customers
(
CustomerID int not null auto_increment primary key, /*Primary Key*/
F_Name varchar (20),
L_Name varchar (20)
/* ..more fields ..*/
);
DBR Formula: _acme_Customer (1) -> _acme_CustomerID -> (m)-> Invoice
CREATE TABLE  Invoice
(
InvoiceID int not null auto_increment primary key, /*Primary Key*/
CustomerID int,  /* Foreign Key */
Cust_Name varchar (50),
Amount double,
/* ..more fields ..*/
);
DBR Formula
: Invoice (1) -> _acme_CustomerID -> (1)-> _acme_Customer
The Setup to establish the One-to-Many relationship between _acme_Customers  and Invoice  2 steps:
1)
Put the Primary Key CustomerID  of main table _acme_Customers  to become the Foreign Key of the related table  Invoice. ( No vice versa)
2) Use myNet.Dbase [Database Relationship Manager] tool to establish the relationship between them. That is it. DONE in 5 minutes.
 

One-to-Many Relationship ( 1 - ∞ )
. NOTE: The Products and Orders is Many-to-Many. Thus Order Details is the associate table used to break up Many-to-Many into 2 of One-to-Many.

This is another example of 1 - to - Many relationship between Customers and Addresses. To setup this 1-to-Many relationship, you put CustID, which is the Primary key of table Customers into the relational table Addresses. Formula: Customers (1) -> CustID -> (m) Addresses

Many-To-Many

Figure 1C shows a many-to-many relationship between EMPLOYEE and PROJECT. An employee may be assigned to many projects; each project must have many employee Note that the association between EMPLOYEE and PROJECT is optional because, at a given time, an employee may not be assigned to a project. However, the relationship between PROJECT and EMPLOYEE is mandatory because a project must have at least two employees assigned. Many-To-Many relationships can be used in the initial drafting of the model but eventually must be transformed into two one-to-many relationships. The transformation is required because many-to-many relationships cannot be represented by the relational model. The process for resolving many-to-many relationships is discussed in the next section.

Resolve Many-To-Many Relationships

Many-to-many relationships cannot be used in the data model because they cannot be represented by the relational model. Because it creates redundancy and duplication. John Smith - the CEO, and John Smith - the Employee, missed up identity, could happen if two tables are Many-to-Many relationship.  Therefore, Many-to-Many relationships must be resolved early in the modeling process. The strategy for resolving Many-to-Many relationship is to replace the relationship with an association entity and then relate the two original entities to the association entity. This strategy is demonstrated below Figure 6.1 (a) shows the many-to-many relationship:

Employees may be assigned to many projects.
Each project must have assigned to it more than one employee.

In addition to the implementation problem, this relationship presents other problems. Suppose we wanted to record information about employee assignments such as who assigned them, the start date of the assignment, and the finish date for the assignment. Given the present relationship, these attributes could not be represented in either EMPLOYEE or PROJECT without repeating information. The first step is to convert the relationship assigned to to a new entity we will call ASSIGNMENT. Then the original entities, EMPLOYEE and PROJECT, are related to this new entity preserving the cardinality and optionality of the original relationships. The solution is shown in Figure 1B.

Figure 2: Resolution of a Many-To-Many Relationship

resolving many-to-many relationships
CREATE TABLE _acme_employees (
EID int not null auto_increment primary key,
NAME varchar(20),
PHOTO varchar(20),
ADDRESS varchar(200),
PHONE varchar(20),
EMAIL varchar(50)
/* ..more fields ..*/
);
DBR Formula:
_acme_employees (1) -> EID -> (m) _acme_assigment
Which means: One Employee is Assigned to -> Many Projects. 
CREATE TABLE _acme_assigment (
PID_EID int not null auto_increment primary key,
EID int, /* Primary key of _acme_employees */
PID int /* Primary of _acme_project */
/* ..more fields ..*/
);
_acme_assigment is the association table (entity) between Employees and Projects.
CREATE TABLE _acme_project (
PID int not null auto_increment primary key,
PRJ_CODE varchar(20),
PRJ_COST double,
PRJ_FUNDING double,
PRJ_DESCRIPTION varchar(20),
PROJECT_START_DATE date,
PROJECT_END_DATE date,
SUBJECT PRJ_TYPE enum ("Tech Support", "Marketing", "Accounting", "Software Developer"),
DESCRIPTION text
/* ..more fields ..*/
);
DBR Formula:
_acme_project (1) -> PID -> (m) _acme_assigment
Which means: One Project is Assigned to -> Many Employees. 
The Setup: 2 steps:
1)
Create the association table _acme_assigment. This table must include EID - the Primary Key of _acme_employees, and PID - the primary key of _acme_project, plus has its own table primary key is: PID_EID.
2) Use [myNet.Dbase] -> [Database Relationship Manager] tool to establish the relationship between _acme_employees with _acme_assigment, and _acme_employees with _acme_assigment. That is it. DONE in 5 minutes.
   

Create the Relational Control View and Calculate The View with myNet.Dbase

myNet.Dbase allows you to create a selected Relational View of fields,  that may interest you and calculate its values.  For example, when viewing the information of _acme_invoices from Customer ABC Inc, instead of viewing 35 pieces of data of _acme_invoices, you can select to view only data Cust_Name, Cust_Address, GST_Amount, PST_Amount, Sub_Total, Cust_Phone only. And they you calculate the Total of Sub_Total,  total of  GST_Amount, total of  PST_Amount of all the _acme_invoices that the Customer ABC Inc has purchased. You can select View of Relation by Embedded View or Popup View.
Embedded View is the
static View displayed inside the page.
Popup View is the
dynamic View displayed from a popup window outside the page.

Let's Get Started Designing Database... Use this as an example for future design.

Let's get started building database. Here are 5 steps that we recommend for users, who have no database administration skills. The requirement to do these steps is: To understand How to CREATE a Table using simple SQL script.,

What tables do you need? List them down.
Of course you know why you need them. You always can expand, add more tables in the future. At the present, you need tables for Employees, Project, Department, Workoffice, Customers, Invoices, Products.

 CREATE TABLE simple syntax first plus CREATE the PRIMARY KEY for each table .
Use an ID number by increment is the easiest way to make a key, because it is unique and automatic every time you add a new record.  Don't worry about what table attributes (or fields, columns) you add them.. later. The write the SQL Syntax English-like expression like this: Create Table <tablename> ( Key_name type );  (see the table). In this step, you begin to write SQL table expression in the definition table below.
Example:
CREATE TABLE _acme_customers (
CustomerID
int not null auto_increment primary key,
/* Add more fields later*/
);

How To Choose a Primary Key
In this case, it is chosen as: int not null auto_increment primary key means int = Integer type, not null = Key should always has value, auto_increment means that every time you add a new record, the number key will automatically increases to plus 1, and it is chosen as a primary Key. Thus it is unique and simple. If you make up an integer and assigned to the key, you can't keep track which number has been used. If you use Name ( even many experienced db designers used to ) as a key. Then  it is possible you miss up the identity of  John Smith - the CEO, and John Smith - the Employee. So you should choose Primary Key as a Number referred to a String.
NOTE:
Database programmers like to choose Name in their database as you often see because the customer Name John Smith is better reference than put CustomerID of John Smith, which is 543325. So that users can easily understand and refer. But if it is designed relational database, then just one click on CustomerID, you can find out much more information about that customer. Not only customer Name, but also that customer's Address, Phone, Company Name...

Define the Relationship between Tables.  And Do Primary Key Assignments.

A table can have many different relationships. For example, table Employees may have 1-to-1 with Workoffice table, and 1-to-Many with Department table...   But there are only 3 relationships: 1-to-1, 1-to-Many, Many-to-Many.
1 - to -1 = Table primary: TP (1) -> (Relational_Key) rk -> (1) TR :Table Relation => 1 instance (record of TP) related by rk given only 1 P instance. And vice versus holds true.
1 -to - Many = TP (1) -> rk -> (m) TR => 1  record of TP related by rk given many TP records. BUT 1  record of  TR related by rk given 1 TP record.
Many -to - Many = TP (m) -> rk -> (m) TR => Many  records of TP related by rk gives many TP records. And many records of  TR related by rk gives many TP records.  In our case:
- Table Employees is having Many-to-Many with table Projects because each Employee work on many different Projects. And one Project can be assigned to many Employees.
- Table Department is having 1-to-Many relationship with Employees because each Department has many Employees. And one Employee is belonging to only 1 Department.
- Table Workoffice is having 1-to-1 relationship with table Employees because each Workoffice has one Employees. And one Employee is having only one Workoffice.
Here are the rules:
1 - to -1: Use the same PK (Primary Key) of TP (Table primary) for TR (Table relation).
For example, if _acme_employees, with PK = EID,  has the relation 1-to-1 with _acme_workoffice then => You should use EID as PK for _acme_workoffice too.
1 - to -Many: Put the PK (Primary Key) of TP (Table primary), used as Foreign Key (FK)  into TR (Table relation). For example, if _acme_customers, with PK = CustomerID,  has the relation 1-to-Many with _acme_invoices then => You should put CustomerID as FK in  _acme_invoices too.
Many - to -Many: Introduce a middle (association) table. Then divide Many-to-Many into two of 1-to-Many and 1-to-Many with the associated table.
Example:
- Students and Teachers are Many-to-Many relation ship. Because a Student can have many Teachers. And a Teacher has many Students.
- Invoice and Product
are Many-to-Many relationship. Because a Invoice has many ordered Products. And a Product can be on many different Invoices.

Translate into code
:
CREATE TABLE Customers (
CustomerID int not null auto_increment primary key,
/* more fields later*/
)
Customers (1) -> InvoiceID -> (m) Products.
CREATE TABLE Invoice (
InvoiceID int not null auto_increment primary key,
CustomerID
int , /*Foreign Key*/
/* more fields later*/
)
Invoice (1) -> InvoiceID -> (m)  Inv_Prod.
CREATE TABLE Inv_Prod (
InvProdID int not null auto_increment primary key,
InvoiceID int, /*Foreign Key*/
ProductID
int, /*Foreign Key*/
/* more fields later*/
)
The associate table.
CREATE TABLE Products (
ProductID int not null auto_increment primary key,
/* more fields later*/
)
Products  (1) -> ProductID   -> (m) Inv_Prod.

After this step, you should have the definition table below like this:
 
Table Primary Relationship and Key Table Relation Analyze
CREATE TABLE _acme_customers (
CustomerID
int not null auto_increment primary key,
/* more fields later*/
);
1-to-Many
_acme_customers 
(1) -> CustomerID  ->
(m) _acme_invoices
CREATE TABLE _acme_invoices (
InvoiceID
int not null auto_increment primary key,
CustomerID int,
/* more fields later*/
);
- One Customer has purchased many Invoices. But One Invoice has only one Customer.
• How? Just use common sense right?
So this is:  One-to-Many Relationship.
- Who is One: _acme_customers
- Who is Many: _acme_invoices
CREATE TABLE _acme_employees (
EID int not null auto_increment primary key,
/* more fields later*/
);
1-to-Many
EID

_acme_employees  (1) -> EID  ->
(m) _acme_assigment
CREATE TABLE _acme_assigment (
PID_EID int not null auto_increment primary key,
EID int, /* PK of _acme_employees */
PID int /* Primary of _acme_project */
/* Expand table add more fields... */
);
To divide Many-to-Many relationship of Employees and Projects, we introduce association table _acme_assigment in order to create two of 1-to-Many relations. _acme_assigment has 2 foreign keys EID and PID includes.  
CREATE TABLE _acme_projects (
PID int not null auto_increment primary key,
/* more fields later*/
);
1-to-Many
PID
_acme_projects 
(1)
->
PID
  ->
(m) _acme_assigment
CREATE TABLE _acme_assigment (
PID_EID int not null auto_increment primary key,
EID int, /* PK of _acme_employees  */
PID int /* Primary of _acme_project */
/* Add more fields... */
);
_acme_projects is relating to _acme_employees with Many-to-Many.
So table _acme_assigment is introduced in order to divide the relationship Many-to-Many into 1-to-Many with _acme_assigment 
CREATE TABLE _acme_department (
DID int not null auto_increment primary key,
DEP_NAME enum ("Engineering", "Human Resources", "Marketing", "Accounting", "Software Development")
/* Expand table add more fields... */
);
1-to-Many
DID

_acme_department 
(1) -> DID  ->
(m) _acme_projects
CREATE TABLE _acme_projects (
PID int not null auto_increment primary key,
DID int, /* PK of _acme_department  */
/* Add more fields... */
);
• One Department has managed many Projects. But one Project belongs to only one Department. Thus it is 1-to-Many.
CREATE TABLE _acme_workoffice  (
EID int not null auto_increment primary key, /* used same key with _acme_employees*/
/* more fields later*/
);
1-to-1
EID
CREATE TABLE _acme_employees (
EID int not null auto_increment primary key,
/* more fields later*/
)
• One work office (computer used, or office, or a cubic) has occupied by only one Employee. And one Employee occupied 1 office.
Continue...
Use myNet.Dbase -> [Database Relationship Manager] to Establish the Relationship between tables.
 
The Database Relationship The Setup using myNet.Dbase -> [Database Relationship Manager]
                1-to-1

_acme_workoffice (1) -> EID -> (1) _acme_employees
1) Open myNet.Dbase -> [Database Relationship Manager] Tool under [Tools] or under [myNet.Dbase] menu , you will see 3 guiding steps:
Step 1: Select Primary Table= _acme_workoffice
Step 2
: Select Primary Key = EID
Step 3: Select Table Relation= _acme_employees. Which has EID key common shared. No foreign Key.
Step 4:
Click icon to establish the relationship.
               1-to-Many

_acme_customers (1) -> CustomerID -> (1) _acme_invoices
1) Open myNet.Dbase -> [Database Relationship Manager] Tool under [Tools] or under [myNet.Dbase] menu , you will see 3 guiding steps:
Step 1: Select Primary Table= _acme_customers
Step 2
: Select its Primary Key = CustomerID
Step 3: Select Table Relation= _acme_invoices Which has CustomerID key common shared used as Foreign Key.
Step 4:
Click icon to establish the relationship.
Step 5: Click icon INSERT/EDIT VIEW FIELDS OF TABLE_RELATION to create the relationship control view. (optional)
Step 6: Click icon CALCULATE VIEW RELATIONSHIP  to calculate the relationship control view. (optional)
2) Create the backward View of 1-to-Many so that one InvoiceID is seen only one CustomerID.
[myNet.Dbase] menu , you will see 3 guiding steps:
Step 1: Select Primary Table= _acme_invoices
Step 2
: Select its Primary Key = CustomerID
Step 3: Select Table Relation= _acme_customers Which has CustomerID key common shared used as Foreign Key.
Step 4:
Click icon to establish the relationship.
Step 5: Click icon INSERT/EDIT VIEW FIELDS OF TABLE_RELATION to create the relationship control view. (optional)
Step 6: Click icon CALCULATE VIEW RELATIONSHIP  to calculate the relationship control view. (optional)
 
        Many-to-Many

Introduce an association table, like _acme_employees, and _acme_projects  introduce an association table like _acme_assigment. Next, create 2 of 1-to-Many relationship.

_acme_employees (1) -> EID -> (1) _acme_assigment

_acme_project
s (1) -> PID -> (1) _acme_assigment
1) Open myNet.Dbase -> [Database Relationship Manager] Tool under [Tools] or under [myNet.Dbase] menu , you will see 3 guiding steps:
Step 1: Select Primary Table= _acme_employees
Step 2
: Select its Primary Key = EID
Step 3: Select Table Relation= _acme_assigment Which has EID key common shared used as Foreign Key.
Step 4:
Click icon to establish the relationship.
Step 5: Click icon INSERT/EDIT VIEW FIELDS OF TABLE_RELATION to create the relationship control view. (optional)
Step 6: Click icon CALCULATE VIEW RELATIONSHIP  to calculate the relationship control view. (optional)
Next,
2) Open myNet.Dbase -> [Database Relationship Manager] Tool under [Tools] or under [myNet.Dbase] menu , you will see 3 guiding steps:
Step 1: Select Primary Table= _acme_project
Step 2
: Select its Primary Key = PID
Step 3: Select Table Relation= _acme_assigment. Which has PID key common shared used as Foreign Key.
Step 4:
Click icon to establish the relationship.
Step 5: Click icon INSERT/EDIT VIEW FIELDS OF TABLE_RELATION to create the relationship control view. (optional)
Step 6: Click icon CALCULATE VIEW RELATIONSHIP  to calculate the relationship control view. (optional)

 Finally, Fill in Fields (or Columns) for the rest of all Tables.
myNet.Dbase
allows you to add more fields (or columns) or delete them. What ever you do, please
DO NOT CHANGE THE PRIMARY KEY AND THE FOREIGN KEY.

 

CREATE TABLE _acme_employees (
EID int not null auto_increment primary key,
NAME   varchar(20),
PHOTO varchar(20),
ADDRESS varchar(200),
PHONE varchar(20),
EMAIL varchar(50)
/* Expand table add more fields... */
);
CREATE TABLE _acme_projects (
PID int not null auto_increment primary key,
DID int, /* for Relation as 1-to-Many with Department*/
PRJ_CODE   varchar(20),
PRJ_COST   double,
PRJ_FUNDING double,
PRJ_DESCRIPTION varchar(20),
PROJECT_START_DATE date,
PROJECT_END_DATE date,
SUBJECT PRJ_TYPE enum ("Tech Support", "Marketing", "Accounting", "Software Developer"),
DESCRIPTION text
/* Expand table add more fields... */
);
CREATE TABLE _acme_assigment (
PID_EID int not null auto_increment primary key,
EID int, /* Primary key of _acme_employees. Used as Foreign Key */
PID int /* Primary of _acme_project. Used as Foreign Key */
/* Expand table add more fields... */
);
CREATE TABLE _acme_department
(
DID int not null auto_increment primary key,
DEP_NAME enum ("Engineering", "Human Resources", "Marketing", "Accounting", "Software Development")
/* Expand table add more fields... */
);
CREATE TABLE _acme_workoffice (
EID int not null auto_increment primary key, /* used same key with _acme_employees*/
TYPE enum ("Tech support",
"Marketing", "Accounting", "Software Developer", "Manager" )
/* Expand table add more fields... */
);


This figure shows 1-to-Many relationship between _acme_Customers and _acme_Invoices. From _acme_Customers table, Click on CustomerID = 54435 will gives you all Invoices that this Customer has purchased. One CustomerID=54435 has two invoices 12, and 55 (may be more in future). The Invoice table has total 30 fields (views), but selected only 13 views. The Control View can always be reset. It also calculate the total of: Sub_total, Gst_amt, Pst_amt. Click again will close the display. _acme_Customers also has multiple relations, such as its unique key =EMAIL has relationship with _feedback table. Click on the Email link, you will see all history of feedbacks that this Customer 54435 posted on your web site.

Create Muti Relationship. Bring your database to the next level with myNet.Dbase

myNet.Dbase not only lets you establish the database relationship, but also allows you to create muti-relationship.  For example,
the table _xyzemp currently has 3 different relationships with 3 tables _acme_assigment, _acme_workoffice, and customer.


This figure shows the employee EID=4 of table _xyzemp currently has 3 relationships: with others in 3 tables _acme_assigment, _acme_workoffice, and customer.

What is the multi Database Relationship?
A table that has many unique keys (EID, CUSTOMERID...) or unique fields (EMAIL, PHONE...) that have relationship with keys or fields with other tables. For example, the table _xyzemp has a primary key
EID that has 2 relationships: one is One-to-Many with _xyz_assigment and one is One-to-One with _xyz_workstation.

Plus, it also has unique field EMAIL that has One-to-Many relationship with Customer table. For a Customer database application, you may have:
- Customer One-to-Many with Invoice table base on CustomerID: Customer (1) -> CustomerID -> (m) Invoice
- Customer One-to-Many with Promotion table. Customer (1) -> CustomerID ->  (m) Promotion. This relation allows to give each Customer can have many different Promotion. And each Promotion is given to a specific Customer when they purchase on the web.

How to recognize a database or a database application is a Relational Database.

After you have ideas about what is a Relational Database, it is not difficult to know my database program is a relational database. At work, you probably run application like Customer-Invoice software, or HR program, or Company database program. Let say you are running Customer Invoice program. When there is a time you see a customer record that has an Invoice ID = 129033. In order to find more information about this InvoiceID, such as: the Date, Amount, Total, Pst, Gst, the Address Delivery, Time Delivery, What Orders on it, which is the Many-to-Many relation of this InvoiceID with table Product. See the above picture and the code design? ...  And you have to go through many steps to piece them together then probably your database application is not built-in Relational Database, or the dbase designer didn't design the software probably. And then you have to spend hours and hours to look for information. This means your work productivities affected. Thus cost your business more. If that database is built in relational database. Then just one click you can gather a whole View of Information of all its relations.

Summary

The Entity-Relationship diagram provides a pictorial representation of the major data objects, the entities, and the relationships between them. Once the basic diagram is completed, the next step is Design Tables that represented by these relationship, and Code Implementation.
We are living the the world governed by data and information. Database is the most important property of your business. Business can't run without them. Garbage in. Garbage out. Therefore, if you are in the position of Management, or dbase Designer, you should take it seriously.

Additional Resources:

We hope this article will give you some information about the background, the design, the code, and how to do with relational database. You can find more information from these links.
- The Relational Database Normalization ( Some background theory of Relational Algebra and Relational Calculus )
- IBM Database Relationship

- Design Your Own Database  from Dr Lorna Scammell, University Database adviser, Newcastle University.
- Database Journal for Developer - Introduction to Database Relationship