O O D B Design And Implementation - Part 1 -

Joe

Thành viên VIP
21/1/13
2,969
1,310
113
Hi

Introduction & History
Everyone who's in touch with IT knows what a Database is.
Everyone who starts to learn coding will sooner or later have to work with a Database.
Everyone who gains more IT experience would start one day to ask himself how a Database works.
Everyone who believes to be an IT developer would get tired of the age-old SQL and will try one day to design and to implement a Database that would suit his using requirements.

Finally, everyone who works day in and day out with an OOPL would ponder one day over the true meaning of OO and why OO Databases weren't so widespread or, at least, as popular as the SQL Databases.

OO or Object Oriented. What's that, this OO? And what is an OODB? If you are a "real" developer you won't raise such a question, but start to analyze the question: how can I design an OODB that covers my specific requirements and how can I implement it in my most favored OO Programming Language? It's a real challenge, isn't it?

JAVA or PYTHON or C# or even the age-old C++ is very "qualified" as the OOPL for such an OODB approach. However, most of the approaches begin with the wrong start: a generic OODB. Why that? Computer languages are like human languages. None of the languages prevails over the others. English, the most spoken language on this planet Earth, cannot render the soul of any other native language. Native Idioms and proverbs reflect their deepest meaning and emotional feeling that even the most adept English scholar has to capitulate. Similar to that JAVA objects are differently "structured" than C# objects, and vice versa.

You may argue that all RDBs are generic because one can access to any RDB (Relational DB) in C or JAVA or whatever OOPL. No, not really. C or JAVA or C# or PYTHON has to ride on the SQL wagon which is more or less standardized (an invention in the 70s by IBM researchers Raymond Boyce and Donald Chamberlin and at that time IBM was a power that every IT man and woman had to bow). Without SQL neither C, nor JAVA can access the data of any RDB.

In our time, when IBM is just another big yahoo, neither C, nor JAVA, nor C# of Bill Gates could dictate the world like IBM did in the 70s with its SQL. NO standardized OO-Query Language (OOQL) = NO generic OODB. So, when we design and implement a specific OODB we could only hope that it would be so excellent that the others accepted it and made it to a "pseudo-standard" like Linux or Android in the OS-Scene. And if it was so, you hit the "jackpot" and became rich and famous.

OODB Design and Implementation Overview
First of all: Keep it simple as the most famous Russian inventor Kalashnikov used to say.

Different to RDB data where the data are ACID (Atomicity, Consistency, Isolation, Durability) before stored OODB data cannot be isolated and this point breaks the RDB rules. OO data are parts of an object. It's the soul, if you so will, of an object. An Object consists of two parts:

- the soul or the functionality (the methods)
- the body or the architectural structure (the class)

Let scrutinize an object with an example. The People in JAVA. To describe "the people" you have to work with two distinctive aspects. The physical (body) and the mental (soul). Both represent in name, age, profession, etc. and then the appearance, hobby, etc. And that requires you to (pattern) design and to implement some methods that render the "mental" and the "physical". Let do it as simple as possible (Kalashnikov)
PHP:
import java.awt.*;
import java.net.URL;
import javax.swing.*;
// Joe Nartca (c)
public class People implements java.io.Serializable {
  private static final long serialVersionUID = 1234L;
  public People(String name, int age, String address,
                String profession, double income, String url) {
    this.age = age;
    this.url = url;
    this.name = name;
    this.income = income;
    this.address = address;
    this.profession = profession;
  }
  private int age;
  private double income;
  private String name, url, address, profession;
  public String toString() {
    return "Name: "+name+", Age: "+age+", Addr.: "+address+", Income: "+income+
           ", Profession: "+profession;
  }
  public void print() {
    System.out.println("Name:\t\t"+name+System.lineSeparator()+
                       "Age:\t\t"+age+System.lineSeparator()+
                       "Addr.:\t\t"+address+System.lineSeparator()+
                       "Income:\t\t"+income+System.lineSeparator()+
                       "Profession:\t"+profession+System.lineSeparator());
  }
  public void picture(JFrame jf) {
    class Picture extends JDialog {
      public Picture(JFrame jf) {
        super(jf, true);  
        setTitle("People:"+name);
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        JButton but;
        try {
          ImageIcon img;
          if (url.indexOf("://") > 0) img = new ImageIcon(new URL(url));
          else img = new ImageIcon(url);
          but = new JButton(img);
          setSize(img.getIconWidth(), img.getIconHeight());
        } catch (Exception e) {
           but = new JButton("No Image");
           pack();
        }
        but.setContentAreaFilled(false);
        but.setBorderPainted(false);
        add(but, BorderLayout.CENTER);
        setLocationRelativeTo(jf);
      }
    }
    (new Picture(jf)).setVisible(true);
  }
}
As you see, "the People class" (the body) does have some similarity with RDB data (name, age, address, etc.) that could be easily "ACIDed". But the appearance (here: picture with the subclass Picture) and the activities (here: toString and print) cannot be parts of RDB data, but they are parts of the OO data.

If an object People, say "Trump", the person Trump is IN the object. In RDB you have to work around to display and to describe the person Trump. In OODB (here in JAVA) the person Trump is serialized and stored as he is. No Atomization, Nothing! Just an access (read) like this:
PHP:
People Trump = (People)oodb.read("people", "Trump");
and you get instantly this "person" Trump.

(Next: OODB Structural Design)
 
Sửa lần cuối:
  • Like
Reactions: Thanhpv

Thanhpv

New Member
30/3/18
28
6
3
Really like to read this way. Feel like it is from a novel writer but actually an IT wiser.
 
  • Like
Reactions: Joe

Thanhpv

New Member
30/3/18
28
6
3
That image again again again...I am actually 'effected'! :D
update: I think you should think about writing a book, something like "Java - How to create"
 
Sửa lần cuối:

Joe

Thành viên VIP
21/1/13
2,969
1,310
113
think about writing a book, something like "Java - How to create"
Thanks a lot for the suggestion...but I've "already swum" in money and don't need more b-) Btw, a book would reveal my anonymity and that hurts #:-s
 

Thanhpv

New Member
30/3/18
28
6
3
Thanks a lot for the suggestion...but I've "already swum" in money and don't need more b-) Btw, a book would reveal my anonymity and that hurts #:-s
Come on! I was not thinking about money. Books out there are mostly about "How to use" not "How to create". This is much more inspirational. BTW, that kind of hurts would be enjoyable :cool:
 

Joe

Thành viên VIP
21/1/13
2,969
1,310
113
that kind of hurts would be enjoyable
It's the question of penchant and roughneckism. Example: POTUS (President Of The US) Trump is a very rich man. Theoretically he doesn't need the title POTUS, nor the meager salary of ~400,000 US$ / year. But he's tried and becomes the 45th POTUS. What he gets is a lot of headaches and bashing. Is that enjoyable?
 

Thanhpv

New Member
30/3/18
28
6
3
It's the question of penchant and roughneckism. Example: POTUS (President Of The US) Trump is a very rich man. Theoretically he doesn't need the title POTUS, nor the meager salary of ~400,000 US$ / year. But he's tried and becomes the 45th POTUS. What he gets is a lot of headaches and bashing. Is that enjoyable?
Right! headaches, nightmares, feeling of kills, praises, hates, insults, risks to be jailed, loves, living shorter... I do not know nor feel all. But I would like to say "YES".

Jurnalist: What is your true hurt?

John: Get shots on fields.
Jane: Get blamed and hated.
Some: Have done nothing.
A hero: Living too safe the whole life, not protecting anyone.
A pesidential nominee: Do not have chances to serve the country at top notch scale.
Jack Sparrow: Sailing without strange tides!

Up to your perspectives of view.
 
Sửa lần cuối: