Thursday, August 22, 2019

ReactJs

React Js
React is a JavaScript library for building user interfaces. It is maintained by Facebook and a community of individual developers and companies. React can be used as a base in the development of single-page or mobile applications, as it is optimal for fetching rapidly changing data that needs to be recorded.

ReactJS basically is an open-source JavaScript library which is used for building user interfaces specifically for single-page applications. It's used for handling view layer for web and mobile apps. React also allows us to create reusable UI components.

Sunday, August 11, 2019

Ajax

HTML
Ajax is a set of web development techniques using many web technologies on the client-side to create asynchronous web applications. With Ajax, web applications can send and retrieve data from a server asynchronously without interfering with the display and behaviour of the existing page.

AJAX is a developer's dream, because you can:
  • Read data from a web server - after a web page has loaded
  • Update a web page without reloading the page
  • Send data to a web server - in the background
What is AJAX?

AJAX = Asynchronous JavaScript And XML.
AJAX is not a programming language.
AJAX just uses a combination of:
  • A browser built-in XMLHttpRequest object (to request data from a web server)
  • JavaScript and HTML DOM (to display or use the data)
AJAX is a misleading name. AJAX applications might use XML to transport data, but it is equally common to transport data as plain text or JSON text.

AJAX allows web pages to be updated asynchronously by exchanging data with a web server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.

AJAX

Heroku

Image result for heroku
What is Heroku used for?
Heroku is a container-based cloud Platform as a Service (PaaS). Developers use Heroku to deploy, manage, and scale modern apps. Our platform is elegant, flexible, and easy to use, offering developers the simplest path to getting their apps to market.

Why is Heroku free?
Heroku's free cloud services begin with the apps - apps which can be deployed to dynos - our lightweight Linux containers that are at the heart of the Heroku platform. When you sign up with Heroku, you automatically get a pool of free dyno hours to use for your apps. When your app runs, it consumes dyno hours.

 Heroku Buildpack
Buildpacks are composed of a set of scripts that will perform tasks such as retrieve dependencies or output generated assets or compiled code. If you are using a language that is officially supported by the Heroku platform, the build system will automatically detect which Heroku Buildpack is needed for the job.

The Heroku Platform
The Heroku network runs the customer's apps in virtual containers which execute on a reliable runtime environment, Heroku calls these containers Dynos. These Dynos can run code written in Node, Ruby, PHP, Go, Scala, Python, Java, Clojure. Heroku also provides custom buildpacks with which the developer can deploy apps in any other language. Heroku lets the developer scale the app instantly just by either increasing the number of dynos or by changing the type of dyno the app runs in.


How to install Heroku?
Run this from your terminal.
  1. sudo add-apt-repository "deb https://cli-assets.heroku.com/branches/stable/apt ./"
  2. curl -L https://cli-assets:heroku.com/apt/release.key | sudo apt-key add-
  3. sudo apt-get update
  4. sudo apt-get install heroku
Deploy your application to Heroku:
  • git init
  • git add .
  • git commit -m "first commit"
  • git status
  • heroku login(Enter your Heroku credentials)
  • heroku create ukifunwork2byname
  • git push heroku master(if it fails add heroku git remote:heroku git:remote -a yourapp & retry git push heroku master)
  • heroku open

Saturday, August 10, 2019

NODEJS MONGO-DB


We can create a mongo database through mongo coding. In spite of this, we can access MongoDB through Node.js. It is a server-side language used in JavaScript language.


To create a database in MongoDB, start by creating a MongoClient object, then specify a connection URL with the correct IP address and the name of the database you want to create.


Node.js can use this module to manipulate the MongoDB database:
var mongo = require('mongodb');

Creating a Database

To create a database in MongoDB, start by creating a MongoClient object, then specify a connection URL with the correct ip address and the name of the database you want to create


Creating a Collection

To create a collection in MongoDB, use the createCollection() method:


var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";

MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("mydb");
dbo.createCollection("customers", function(err, res) {
if (err) throw err;
console.log("Collection created!");
db.close();
});
});



Insert Into Collection

To insert a record, or document as it is called in MongoDB, into a collection, we use the insertOne() method.
The first parameter of the insertOne() method is an object containing the name(s) and value(s) of each field in the document you want to insert.

var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";

MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("mydb");
var myobj = { name: "Company Inc", address: "Highway 37" };
dbo.collection("customers").insertOne(myobj, function(err, res) {
if (err) throw err;
console.log("1 document inserted");
db.close();
});
});



Find OneTo select data from a collection in MongoDB, we can use the findOne() method.

The findOne() method returns the first occurrence in the selection.

The first parameter of the findOne() method is a query object. In this example, we use an empty query object, which selects all documents in a collection (but returns only the first document).


var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";

MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("mydb");
dbo.collection("customers").findOne({}, function(err, result) {
if (err) throw err;
console.log(result.name);
db.close();
});
});



Sort 

Use the sort() method to sort the result in ascending or descending order.

The sort() method takes one parameter, an object defining the sorting order.
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";

MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("mydb");
var mysort = { name: 1 };
dbo.collection("customers").find().sort(mysort).toArray(function(err, result) {
if (err) throw err;
console.log(result);
db.close();
});
});



Delete Document

To delete a record, or document as it is called in MongoDB, we use the deleteOne() method.

The first parameter of the deleteOne() method is a query object defining which document to delete.

var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";

MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("mydb");
var myquery = { address: 'Mountain 21' };
dbo.collection("customers").deleteOne(myquery, function(err, obj) {
if (err) throw err;
console.log("1 document deleted");
db.close();
});
});



Drop Collection

You can delete a table, or collection as it is called in MongoDB, by using the drop() method.

The drop() method takes a callback function containing the error object and the result parameter which returns true if the collection was dropped successfully, otherwise it returns false.

var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";

MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("mydb");
dbo.collection("customers").drop(function(err, delOK) {
if (err) throw err;
if (delOK) console.log("Collection deleted");
db.close();
});
});



Update Document


You can update a record, or document as it is called in MongoDB, by using the updateOne() method.

The first parameter of the updateOne() method is a query object defining which document to update.


var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://127.0.0.1:27017/";

MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("mydb");
var myquery = { address: "Valley 345" };
var newvalues = { $set: {name: "Mickey", address: "Canyon 123" } };
dbo.collection("customers").updateOne(myquery, newvalues, function(err, res) {
if (err) throw err;
console.log("1 document updated");
db.close();
});
});



Mongoose

Image result for mongoose logo



Mongoose is an Object Data Modeling (ODM) library for MongoDB and Node.js. It manages relationships between data, provides schema validation, and is used to translate between objects in code and the representation of those objects in MongoDB.

MongoDB is a schema-less NoSQL document database. It means you can store JSON documents in it, and the structure of these documents can vary as it is not enforced like SQL databases. This is one of the advantages of using NoSQL as it speeds up application development and reduces the complexity of deployments.


Collections


‘Collections’ in Mongo are equivalent to tables in relational databases. They can hold multiple JSON documents.

Documents.
‘Documents’ are equivalent to records or rows of data in SQL. While a SQL row can reference data in other tables, Mongo documents usually combine that in a document.
Fields
‘Fields’ or attributes are similar to columns in a SQL table.

Schema

While Mongo is schema-less, SQL defines a schema via the table definition. A Mongoose ‘schema’ is a document data structure (or shape of the document) that is enforced via the application layer.

Models

‘Models’ are higher-order constructors that take a schema and create an instance of a document equivalent to records in a relational database.
Getting Started

Mongo Installation

Before we get started, let’s setup Mongo. You can choose from one of the following options :
Download MongoDB version for your Operating System from the MongoDB Website and follow their installation instructions

Create a free sandbox database subscription on mLab
Install Mongo using Docker if you prefer to use docker


How to install  Mongoose by terminal?

npm install mongoose --save 

Now that we have the package, we just have to grab it in our project

var mongoose = require('mongoose');

We also have to connect to a MongoDB database(either local or hosted)

mongoose.connect('mongodb://localhost/myappdatabase');

What is Schema?
Mongoose Schema will create a mongodb collection and defines the shape of the documents within that collection". If we want to create a MongoDB collection in a structured manner similar to SQL tables then we can do that using mongoose Schema. In the schema creation, we will specify the details of fields like field name, its type, default value if need, index concept if need, constraint concept if need.



What is the Model?
Schemas define a structure we will apply that schema part to a model, means "Models are the constructors compiled from our schema definitions". Instances of these models represent documents which can be saved and retrieved from our database. All document creation and retrieval from the database is handled by these models.

Sunday, August 4, 2019

FUTURE TENSE

Future Tense

How do you say about the things that have not happened yet and will happen in the future? You will be interested to know the format of the sentences which talk about the future. 

As the name suggests, this form of tense is used for sentences with a future sense. There are various ways of referring to the future in English, 

Simple Future Tense
  • It is also used to denote facts or events of certainty
  • It is used to give a warning or take a spontaneous decision
  • To express readiness
  • Make an offer or suggestion using ‘shall’
  • To give an invitation or an order to someone
  • It can be used in affirmative, interrogative and negative sentences. Both ‘shall’ and ‘will’ can be used in simple future tense sentences, but modern English uses ‘Will’ rather than ‘shall’.
Examples:  I’ll prepare dinner.

                       Why won’t you tell her the truth?

                       It will rain tomorrow.


Future Continuous/Progressive Tense
The future continuous or future progressive tense is used to denote an event that is ongoing in the future. It is made up of two elements: a simple future of the verb ‘to be’ + the present participle (-ing). 

The future progressive tense is used in the following condition:


  • To extend ourselves in the future
  • To predict future events
  • Ask or inquire about events in the future
  • To refer to events in the future that have a continuous nature or occur regularly
Examples:      I will be gone for an hour.
                      In the afternoon, I’ll still be stuck in meetings.
                      By October, I will be swimming like a pro.
                      He will be coming to the meeting.




Future Perfect Tense
The future perfect tense is a bit complicated as compared to the two types mentioned above. It is used to refer to an action which will have been completed at some time in the future.

The future perfect is composed of two elements: the simple future of the verb “to have” (will have) + the past participle of the main verb. It can be used in the affirmative, negative and affirmative and negative of interrogative sentences.

Examples: By the time you get this letter, I will have left.
                  She will have arrived by lunch.
                   Won’t they have joined us by 7 pm?


Future Perfect Continuous Tense
This tense is used to describe an event that is ongoing and will complete sometime in the future. A time reference is used to indicate the starting time of the event or action or how long it has been continuing. Commonly used words to indicate time reference are ‘since’ and ‘for’.

The future perfect progressive is composed of two elements: the main verb in the present participle(base form of verb + -ing) + Auxilliary verb ‘will have been’

Examples:
  1. They will have been living in Mumbai for 10 years.
  2. You will have been starting your shop since May.
  3. Next year, I will have been working at this company for one year.
  4. I will have been walking for 3 hours. 
  5. Other Ways of Depicting Future Tense
  6. Apart from using the future tense form of the verbs, there are other ways of indicating or talking about events in the future.


Using present continuous tense
I am leaving for Paris tomorrow.
We are staying with friends when we get to Boston.

Using simple present tense
She has her accounts lecture in the morning.
I have an English exam next Friday.

Using the word ‘going’
He’s going to be a skilled clinician.
Is it going to rain this evening?

Mentioning denote obligations
You are to delete the mail right now.
You are to leave this room before 8 am tomorrow.

Referring to the immediate future
He is about to leave

We are just about to leave for the wedding reception

PAST TENSE

Past Tense
We know about the three types of tenses that are used in English Grammar namely Past Tense, Present Tense and Future Tense. Each of these tenses is actually verbs that are used to indicate the occurrence of an event or action at a particular time. Today, let us learn and understand more about the Past Tense and its different types.

Simple Past Tense
The simple past tense is used to indicate or describe something that happened or existed in the past. The situations or conditions to use a simple past tense is to:
  • describe an action, event or condition that occurred in the past or at a specified time
  • refer or describe an action that has been completed and there is no time mentioned.
  • describe an action or occurrence of an event that is done repeatedly and regularly.
  • describe a state of mind in the past or a feeling that was felt in the past.
  • refer to someone who has died
  • describe events that have occurred in quick succession in the past.

Formulating the Simple Past Tense Verb
To formulate the simple past tense verb, we add ‘- ed’. For verbs ending in ‘e’, we add ‘-d’ and. However, there are some simple past tense verbs such as cut, put, set etc which remain the same in the present and past tense. 
Examples are,
  1. He worked at the Cheesecake Factory.
  2.  I often brought my lunch to school.
  3. Learn about Simple Present Tense and Simple Future Tense


Past Continuous Tense
Past continuous tense is used to indicate an ongoing event in the past. Other conditions where past continuous tense is used are:
  1. To show that someone is in the middle of an action.                                                                 Example: I was calling him when he came home.                                                              
  2. Is used to describe an action taking place when another occurred.                                           Example: While they were painting the door, I was painting the windows.                                  
  3. For an action that was taking place in the past when an interrupted action happened.             Example: While he was working on his laptop, he fell asleep
Formulating the Past Continuous Tense
The past continuous tense is formed using the past tense of the verb to be(was/were) and the present participle verbs ending in -‘ing’.  These two tenses can be used together to indicate that an action happened while another was in progress.



Past Perfect Tense
The past perfect tense in a sentence or conversation describes an event that happened in the past before another event in the simple past tense was completed in the past. The situations where a Past Perfect Tense is used are to:
  1. indicate an event that has occurred and been completed in the past.                                                 Example: Meenu had borrowed money from the bank to buy her new car.                                                           
  2. describe an event or action which happened before a definite time in the past.                                 Example: We had cleaned up the terrace before the watchman arrived.                                  
  3. describe an action that happened in the past before another action took place.                                 Example: We had reached their house after the dinner was over.                                              
  4. Past Perfect Tense is also used to describe a state. Example: Their wives had become good friends at the wedding. A very important use of the Past Perfect Tense is that it is used to clarify which event happened earlier when two actions were completed in the past.            Example: I had read those books that you bought for me.

Formulating the Past Perfect Tense
The past perfect tense is formed with the past tense of the auxiliary verb have i.e which is had and the past participle of the main verb.



Past Perfect Continuous Tense
This tense is used to describe actions that were going on in the past up until another action in the past happened. They are often used in the following situations:
  • For an action that has occurred over a period of time having begun in the past.
  • To describe an action which started and finished in the past before another past action.
  • It is also regularly used in the reported speech where the present perfect continuous tense becomes past perfect continuous tense.
  • Unlike the past continuous and past perfect tenses, past perfect continuous tense is not used to indicate state, state of mind or feelings.
 Examples:
  1. I had been studying.
  2. It had been raining hard for several hours and the streets got flooded.
  3. If it had not been raining, we would have gone to the park.
  4. Learn more about Present Perfect Continous Tense and Future Perfect Continous Tense


Formulating the Past Perfect Continuous Tense
This tense is formed with the past perfect tense of the verb ‘to be’, which is ‘had been’ and the present participle of the verb i.e ‘-ing’.

Saturday, August 3, 2019

PRESENT TENSE

Simple Present Tense

The simple present is a verb tense with two main uses. We use the simple present tense when an action is happening right now, or when it happens regularly (or unceasingly, which is why it’s sometimes called present indefinite). Depending on the person, the simple present tense is formed by using the root form or by adding ‑s or ‑es to the end.

How do we make the Simple Present Tense?
subject + auxiliary verb + main verb

There are three important exceptions:

1. For positive sentences, we do not normally use the auxiliary.
2. For the 3rd person singular (he, she, it), we add s to the main verb or es to the auxiliary.
3. For the verb to be, we do not use an auxiliary, even for questions and negatives.

Look at these examples with the main verb like: 



Present Continuous Tense
This tense is used to describe a continued or ongoing action at the present time. It expresses an action which is in progress at the time of speaking and has not yet been completed. The Present Continuous Tense is, therefore, used in the following conditions:
  • As mentioned above, it is used for an action that is occurring at the time of speaking
  • When an action in the future is mentioned without specifying when it will occur
  • When we talk about a planned or arranged event or action that is set to take place at a specified time in the future.
  • It is also used in conditions where the action or event is occurring but not necessarily while we speak
  • It is used in a changing situation
  • With adverbs such as ‘always’ which describe an action that happens frequently.
Formulating the Present Continuous Tense
It is formed from the present tense of the auxiliary verb ‘to be’ and the present participle of the verb ‘-ing’. 
Examples are,
  1. The noise is beginning to give me a headache.
  2. I am complaining to his mother about him.
  3. Why aren’t you doing your homework, Ravi?


Present Perfect Tense
The Present Perfect Tense is used in case of repeated actions, in those actions where the time is not important, and actions that began in the past but are not finished yet and will probably finish in the present as we speak. The Present Perfect Tense can be used in the following scenarios:


  • It is commonly used in actions or events that began in the past and have continued into the present
  • They are used to show an action that has been completed
  • To indicate a time period that has not yet finished
  • This tense is often used with phrases that begin with “This is the first” or “second time” and so on.
  • Is used to describe or express an action that is repeated in the past
  • Used to indicate or describe actions that have been completed in the recent past
Formulating the Present Perfect Tense

To form the present perfect tense, we need to use the simple present tense of the auxiliary verb ‘have’ or ‘has’ based on whether the noun being referred to is plural or singular. The auxiliary verb is then followed by the past participle of the verb. It can also be written as: have/has + past participle. 
Let us see some examples,


  1. We have known each other for a very long time.
  2.  There have been many contenders for this role.
  3. Has there ever been a war during your lifetime?
  4. I have just eaten.
  5. We have had the same car for 8 years.

Present Perfect Continuous Tense

This tense is generally used to describe or indicate an event that is going on at this moment. 

The Present Perfect Continuous Tense is used in the following conditions:


  • It is used to describe an event that began in the past and is continuing into the future
  • An activity or event that began in the past and is now over(just recently completed or over)
  • It is also used when there is no mention of time.

Formulating the Present Perfect Continuous Tense
The present perfect continuous tense is made up of two parts:

The present perfect tense of the verb ‘to be’: ‘have been’ or ‘has been’  and
The present participle of the main verb ‘-ing.

Some examples of present perfect continuous tense are,


  1. My hands are very dirty as I have been painting the walls.
  2. They have been trying to contact her.
  3. I have been working for them for the last seven months.
  4. The party has been going on all night


ER DIAGRAM

ER Diagram

What is the ER Model?

The ER or (Entity Relational Model) is a high-level conceptual data model diagram. Entity-Relation model is based on the notion of real-world entities and the relationship between them.

ER modeling helps you to analyze data requirements systematically to produce a well-designed database. So, it is considered a best practice to complete ER modeling before implementing your database.


History of ER models

ER diagrams are a visual tool which is helpful to represent the ER model. It was proposed by Peter Chen in 1971 to create a uniform convention which can be used for relational database and network. He aimed to use an ER model as a conceptual modeling approach.


What is ER Diagrams?

Entity relationship diagram displays the relationships of entity set stored in a database. In other words, we can say that ER diagrams help you to explain the logical structure of databases. At first look, an ER diagram looks very similar to the flowchart. However, ER Diagram includes many specialized symbols, and its meanings make this model unique.





Facts about ER Diagram Model:
  • ER model allows you to draw Database Design
  • It is an easy to use graphical tool for modeling data
  • Widely used in Database Design
  • It is a GUI representation of the logical structure of a Database
  • It helps you to identifies the entities which exist in a system and the relationships between those entities

Why use ER Diagrams?
Here, are prime reasons for using the ER Diagram

  • Helps you to define terms related to entity relationship modeling
  • Provide a preview of how all your tables should connect, what fields are going to be on each table
  • Helps to describe entities, attributes, relationships
  • ER diagrams are translatable into relational tables which allows you to build databases quickly
  • ER diagrams can be used by database designers as a blueprint for implementing data in specific software applications
  • The database designer gains a better understanding of the information to be contained in the database with the help of ERP diagram
  • ERD is allowed you to communicate with the logical structure of the database to users

Components of the ER Diagram
This model is based on three basic concepts:

  • Entities
  • Attributes
  • Relationships



WHAT IS ENTITY?


A real-world thing either living or non-living that is easily recognizable and nonrecognizable. It is anything in the enterprise that is to be represented in our database. It may be a physical thing or simply a fact about the enterprise or an event that happens in the real world

An entity can be place, person, object, event or a concept, which stores data in the database. The characteristics of entities are must have an attribute, and a unique key. Every entity is made up of some 'attributes' which represent that entity.


Relationship

Relationship is nothing but an association among two or more entities.Entities take part in relationships. We can often identify relationships with verbs or verb phrases.


Attributes

It is a single-valued property of either an entity-type or a relationship-type.
For example, a lecture might have attributes: time, date, duration, place, etc.
An attribute is represented by an Ellipse





Simple attribute  ;--  Simple attributes can't be divided any further. For example, a student's contact number. It is also called an atomic value


Composite attribute:-- It is possible to break down composite attribute. For example, a student's full name may be further divided into first name, second name, and last name.


Derived attribute:-- This type of attribute does not include in the physical database. However, their values are derived from other attributes present in the database. For example, age should not be stored directly. Instead, it should be derived from the DOB of that employee.


Multivalued attribute:-- Multivalued attributes can have more than one values. For example, a student can have more than one mobile number, email address, etc

Weak Entities
A weak entity is a type of entity which doesn't have its key attribute. It can be identified uniquely by considering the primary key of another entity. For that, weak entity sets need to have participation.

Cardinality

Defines the numerical attributes of the relationship between two entities or entity sets.
Different types of cardinal relationships are:
  1. One-to-One Relationships
  2. One-to-Many Relationships
  3. May to One Relationships
  4. Many-to-Many Relationships

1.One-to-one:

One entity from entity set X can be associated with at most one entity of entity set Y and vice versa.

Example: One student can register for numerous courses. However, all those courses have a single line back to that one student.

2.One-to-many:

One entity from entity set X can be associated with multiple entities of entity set Y, but an entity from entity set Y can be associated with at least one entity.

3. Many to One

More than one entity from entity set X can be associated with at most one entity of entity set Y. However, an entity from entity set Y may or may not be associated with more than one entity from entity set X.

4. Many to Many:

One entity from X can be associated with more than one entity from Y and vice versa

ER- Diagram Notations
ER- Diagram is a visual representation of data that describe how data is related to each other.



Express

In this tutorial, we will also have a look at the express framework. This framework is built in such a way that it acts as a minimal an...