Mid-Term Wakandadb: Information System Thematic

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 16

MID-TERM

REPORT
WakandaDB

Information System Thematic


LIST

CONTENTS

I. OVERVIEW ...................................................................................................................................... 2
What is an Object-Oriented Database? ............................................................................................. 2
Fundamental Features of Object-Oriented Databases ..................................................................... 3
Object-Oriented Database Advantages .............................................................................................. 4
II. OVERVIEW WAKANDA ................................................................................................................ 4
III. DESCRIBE DETAIL WAKANDA – DEMO ............................................................................... 5
1. Basic............................................................................................................................................... 5
1.1. DataClass and Entity .............................................................................................................. 5
1.2. Creating your data model ....................................................................................................... 5
2. Client-side ...................................................................................................................................... 8
2.1. Get started .............................................................................................................................. 8
2.2. Retrieve entities...................................................................................................................... 9
2.3. Handle entities...................................................................................................................... 10
3. Server-side ................................................................................................................................... 11
Creating new entities ..................................................................................................................... 12
Finding entities ............................................................................................................................... 14
IV. REFERENCES ............................................................................................................................ 14

MEMBER LIST
TRAN ANH DUNG – 15130038
DINH CHI THIEN – 15130173
NGUYEN KHAC TAM – 15130164

LECTURER
B.S. PHAN DINH LONG

1
I. OVERVIEW

For many years, businesses in various sectors have been using relational database systems
to effectively represent their data and information. A typical relational database stores
data in a collection of tables with rows and columns. As interest in the utilization of better
database systems increased, many organizations have started to use a wide range of new
applications in various fields including engineering design, telecommunications, and
geographic systems. Moreover, organizations have been dealing with huge amounts of
complex data and that’s why it’s extremely important to invest in applications that can
handle this kind of data. It is difficult to represent complex data in an ordinary relational
database because of the database’s restricted attributes. Object databases emerged to
solve this problem and other problems associated with the relational database model and
other database models. Object databases are known for their high performance and the
ability to handle complex data effectively.

WHAT IS AN OBJECT-ORIENTED DATABASE?

An object database is a database management system in which information is represented


in the form of objects as used in object-oriented programming. Object databases are
different from relational databases which are table-oriented. Object database combine
database capabilities with object-oriented programming language capabilities.
Object oriented databases (OODB) represent data in the form of objects and classes. In
object-oriented terminology, an object is a real-world entity and a class is a collection of
objects. Object-oriented databases follow the fundamental principles of object-oriented
programming (OOP). The combination of relational model features (concurrency,
transaction and recovery) with object-oriented principles results in an object-oriented
database model.
The object-oriented database model (OODBM) is an alternative implementation to that
of a relational model. An object-oriented database is similar in principle to an object-
oriented programming language. An object-oriented database management system is a
hybrid application that uses a combination of object-oriented and relational database
principles to process data. That said, we can use the following formula to outline the
OODBM:
Object-Oriented Programming + Relational Database Features = Object-Oriented
Database Model.

2
FUNDAMENTAL FEATURES OF OBJECT-ORIENTED DATABASES

Objects and Classes


The object-oriented approach considers all entities as objects. An object has properties
(state) and methods (behavior). Each object is identified using a unique object identifier.
For example, let us consider a real-world entity called ‘Student’. A student has states or
properties such as a name, USN, date of birth, address, etc. Similarly, the student has
behaviors or methods including attending classes, writing exams, paying fees, etc.
A class is a collection of similar objects. In the above example, a collection of first year
commerce students forms a class. In a class, the objects interact with each other using
messages.
Encapsulation
Encapsulation is an important object-oriented feature. This hides the implementation
details from the end-users and displays only the needed descriptions.
For example, imagine that you are buying a soap from a commercial store. You know its
ingredients such as color and fragrance by looking on the box, but you aren’t shown the
actual method used to manufacture the soap.
Inheritance
Inheritance is considered important in object-oriented design as it enables re-usability. It
is defined as the method of creating new classes from existing classes. The new classes
not only inherit the properties of their parent class, but they also have their own unique
properties.
For example, when a child is born to parents, the child resembles either its mother of
father, but is also has its own unique traits and personality.
Association
Association refers to links between the various entities of an application. In an object-
oriented database, association is denoted as references between various objects. For
example, individuals from a ‘Person’ class can also be associated with the ‘Committee’
class.
Complex Objects
The concept of complex objects is derived from applying constructors to simple objects.
Simple objects are mainly items such as integers, byte strings and characters. Complex
objects are items such as maps, sets, lists, tuples or collections of many primitive objects.
Persistence

3
The object-oriented database allows for the creation of persistent objects. A persistent
object is one that lives in computer memory even after completing its execution. This is
different from the lifespan of normal objects which expire after execution, are destroyed
immediately and freed from memory. Object persistence solves the database challenges
of concurrency and recovery.

OBJECT-ORIENTED DATABASE ADVANTAGES

There are many advantages to using object-oriented databases for creating applications
and managing data. Some are as follows:
- They permit data, software components, information, computing environments
and products to be shared easily.
- They allow the integration of databases, operating systems, spreadsheets,
languages, AI systems, word processors and other objects or applications.
- They enable the referential sharing of products and applications, which is
accomplished through inheritance and object identity.
-

II. OVERVIEW WAKANDA

Wakanda is an open-source web framework for developing web and mobile applications
in JavaScript. It includes a database server (WakandaDB), a JavaScript framework
(WAF), and Wakanda Studio, an integrated development environment.
Wakanda is supported on Linux, Microsoft Windows and Mac OS, and is cloud-ready on
the back-end. Wakanda Server supports CommonJS modules, Web Workers, Web
Storage, XMLHttpRequest, HTML5 File API, Blobs, Timers. It implements the Firebug
Crossfire Debugger protocol, as well as the WebKit remote debugging protocol. With
Wakanda, developers can take control when necessary and write their own code or use
open source and existing components and tools. What is unique about Wakanda is that it
brings all the various tools together one needs for prototyping, building, and deploying
into a single environment. Then Web and mobile applications can be built quickly into
applications that deliver fast response times.
As a unified and open platform, Wakanda is modular and progressive so that developers
have the most choices possible. Based on JavaScript and other open source code,
Wakanda is supported by a large developer community. It is compatible with all
technologies and can be integrated with frameworks and databases of all types. Wakanda
is available in either cloud or on-premises deployments. Thanks to reduced development
times, Wakanda can be a money saver, due in part to reusable modules, standardized

4
processes, and easy integration between the back end prototyping and development
phases of application development.
Because Wakanda is a single platform, technology is unified and standardized for easy
maintenance and simplified deployment. Developers can use stock Wakanda components
or modify them extensively.

III. DESCRIBE DETAIL WAKANDA – DEMO

1. Basic
1.1. DataClass and Entity
A Data-Class is a description of a business entity or concept needed in your application.
This is the equivalent to Table for other database system.
An Entity is an instance of a Data-Class. This is the equivalent to a Row for a Table.

1.2. Creating your data model

1.2.1. Relations
In the Employee Data-Class, company is a relation attribute of type Company
representing that every employee in the app works for a specific company. The attribute
employees in the Company Data-Class is a collection of Employee entities.

1.2.2. Attributes
An attribute is an object that stores information or represents a value in the datastore class.
Attributes are be default scalar but you can choose to make an attribute calculated if you
need its value to be calculated using code.
5
i. Scalar attributes types

Data
Description Value Range
Type
Blod A “binary large object” containing binary data.

bool A Boolean value: either true or false.

byte A sequence of 8 bits

If the Data only property is selected for this


attribute type, the data value will include only the
data “MM/DD/YYY” format (e.g, “21/03/2019”).
Otherwise, the date value including the time,
stored in UTC.
duration A duration between two dates.

image A reference to an image file or an actual image.

A whole number, greater than or equal to a -2.147.483.648 to


long
standard number. 2.147.483.647
A whole number, greater than or equal to a -9.233.372.036.854.775.808
long64 standard number. to 9.233.372.036.854.775.807

A numeric value, corresponding either to a Real, ±1.7e±308 (real), -32.768 to


number and Integer or Long Integer. 32.767 (integer), -2^31 to
(2^31)-1 (long)
string A sequence of characters.
Universally Unique Identifier: a 16-bytes (128
uuid bits) number containing 32 hexadecimal
characters.

word A 16-bit signed integer. -32.767 to 32.768

ii. Calculated attributes

A calculated attribute is a named property with a data type that masks a calculation.

 It requires at least the OnGet method to be defined


 The value of the attribute is not stored

6
 If the attribute is not accessed the OnGet method will not be called
 Inside calculated attribute methods(OnGet, OnSet..) this represents the current
entity
 If you don't define the OnQuery method and use the attribute in a query on
large data, expect latency

1.2.3. Methods

Datastore class methods allow you to execute code that can be applied to a DataClass,
an entity collection, or an individual entity.

 Inside a collection method this represents the collection who's method


was called
 Inside an entity method this represents the current entity who's method was
called

1.2.4. Events
In addition to dataclass methods that are executed when called, Wakanda provides a
series of events on both entities and attributes that can trigger specific code to execute.
Not to be confused with the Get, Set, Sort, and Query methods of a calculated attributed,
events are available on all attributes and datastore classes.

i. DataClass Events

Class events operate on whole entities and are triggered by particular conditions. The
following are datastore class level events:

Event Description

Executes when a new entity comes into being after all auto
Init
sequence values are assigned.

Load Executes just after an entity is accessed from the datastore but
before it is delivered to the calling routine.
Executes when an entity is saved but before the Save event and can
Validate
fail the validation if needed.
Save Executes before an entity is saved and can stop the save if needed.

Remove Executes before an entity is deleted and can stop the deletion if
needed.
7
Excutes when entities are accessed and returns an entity collection
Restrict
thet represents all entities in the dataclass.

ii. Attribute Events


Event Description
Executes when a new entity comes into being but after the entity’s
Init
Init event.
Excutes the first time the attribute is accessed after the entity is
Load
loaded. If the attribute is not accessed, this event is not executed.
Executes after an attribute’s value is set. In server-side code, this
excutes when the value is set. When an attribute is set in client-
Set side code, this event executes when the entity is saved or the
method serverRefresh is called, but only for each attribute that was
modified.

Executes just before the entity’s Validate event executes and can
Validate
fail the validation if needed.

Executes just before the entity’s Save event excutes and can stop
Save
the save if needed.
Executes just before the entity’s Remove event and can stop the
Remove
deletion if needed.

2. Client-side

You can perform multiple operations from the client side :

 Create/Read/Update/Delete entities (CRUD operations)


 Call entity/dataclass/collection methods
 Authenticate users and get user information

2.1. Get started

Instantiating the client


First, add Wakanda Client to your web page:

8
Define-web.js:
<script src="/path/to/wakanda-client.min.js"></script>
Then, simply instantiate it. You can pass in your backend's hostname and your
datastore's name as optional arguments.
instantiate.js
var wakanda = new WakandaClient.WakandaClient();
instantiate-domain.js
var wakanda = new WakandaClient.WakandaClient({host:
“http://localhost:8881”});
instantiate-catalog.js
var wakanda = new WakandaClient.WakandaClient({catalog:
“crm”});

ES6/TypeScript
You can also import the Wakanda Client using ES6 import.
Instantiate-es6.js:
import {WakandaCLient} from ‘wakanda-client’;
let wakanda = new WakandaClient();

Getting the datastore object


Since the dataclasses list is generated dynamically during runtime, you need to call
the getCatalog method with an optional list of dataclasses you want to use. If you don't
specify any dataclasses you'll get all dataclasses the current user has access to.

2.2. Retrieve entities

Query
The query method is available on all dataclass instances and takes an optional object as
parameter to describe the query (order, expanding, filter, etc).
query.js:
ds.Company.query({
filter: 'staffCount > :1',
params: [500],
orderBy: 'name'
})
.then(function (companyCollection) {
var firstCompany = companyCollection.entities[0];
});

9
Find
To get an entity by its id, use the find method.
find.js
ds.Company.find(6)
.then(function (company) {

// company is an entity, with its properties and framework


// methods (see next parts for their documentation)

})
.catch(function() {
// company not found
});

2.3. Handle entities

Update

update.js:

ds.Employee.find(4).then(function (employee) {
employee.firstName = 'Jack';
employee.save().then(function () {
//Our entity is updated
});
});

Create
Creating entities is straight forward, use the create() method to create a
representation of your entity on the client side, then call save() to submit the request
to the server.
create.js
var comp1 = ds.Company.create();
comp1.name = ‘Nice Corp 1’;
comp1.save();
var comp2 = ds.Company.create({name: ‘Nice Corp 2’});
comp2.save();

10
Delete
delete.js:
ds.Company.find(5).then(function (company) {
company.delete().then(function() {
// company is deleted
});
});

3. Server-side

The Data Abstration Layer gives you the ability to handle data the same way regardless
of where it comes from (built-in DB, MySQL, ODBC..).

In this section, we will work on the following data model :

The datastore API


On the server-side, ds represents your application's datastore that contains all your
dataclasses.

11
CREATING NEW ENTITIES

 The example 001 shows how to create a new Company, a new Employee and attach the
Employee to the created Company.
 The example 002 shows how to import data from a JSON file to the database.

001-creating-entities.js

var comp = new ds.Company();


comp.name = 'NLPige';
comp.save();

var emp = new ds.Employee();


emp.firstName = 'Dinh';
emp.lastName = 'Chi Thien';
emp.dob = new Date("22/02/1997");
/**
* /PROJECT/ will automatically be understood by Wakanda Server
as the path of the project
*/
emp.photo = loadImage('/PROJECT/images/nlpige.jpg');
emp.company = comp;
emp.save();

002-creating-entities.js

var strHeroes =
File('/PROJECT/heroes/list.json').toString('utf-8');
var heroes = JSON.parse(strHeroes);
var photosFolder = Folder('/PROJECT/heroes/images/');
//Get the company with ID = 1
var heroAssociation = ds.Company(1);

heroes.forEach(function(hero){
var h = new ds.Employee();
h.firstName = hero.fName;
h.lastName = hero.lName;
h.dob = new Date(hero.dob);
h.photo = loadImage(File(photosFolder, hero.photo));
h.company = heroAssociation;
h.save();
});

12
list.json

[
{
"fName" : "Atomic",
"lName" : "Samurai",
"dob" : "01/01/1979",
"photo" : "atomic_samurai.png"
},
{
"fName" : "Superalloy",
"lName" : "Darkshine",
"dob" : "01/01/1989",
"photo" : "superalloy.png"
},
{
"fName" : "Child",
"lName" : "Emperor",
"dob" : "01/01/2006",
"photo" : "child_emperor.png"
},
{
"fName" : "Metal",
"lName" : "Bat",
"dob" : "01/01/1999",
"photo" : "metal_bat.png"
},
{
"fName" : "Flashy",
"lName" : "Flash",
"dob" : "01/01/1991",
"photo" : "flashy.png"
}
]

13
FINDING ENTITIES
003-query-find.js
/**
* saitama is an entity of type Employee
*/
var saitama = ds.Employee.find('firstName == :1', 'saita*');

/**
* heroes is a collection of Employee entities
*/
var heroes = ds.Employee.query('(firstName == :1 OR dob > :2)
AND company.name == :3', '*r*', new Date("01/01/1995"), 'Hero
Association');

var result = {
saitama : saitama,
heroes : heroes
};

result;

IV. REFERENCES

https://study.com/academy/lesson/what-is-an-object-oriented-database.html

https://www.predictiveanalyticstoday.com/top-object-databases/

https://wakanda.github.io/doc/#/guide?section=main

https://www.predictiveanalyticstoday.com/top-object-databases/

14
15

You might also like