Tuesday, July 16, 2019

CHAPTER 2: Microsoft SQL Sever

CHAPTER 2. UNIONS/TABLE VARIABLES/SELECT all rows and columns from table

UNIONS

As we have seen before, a Join adds column from different table sources. But what if you want to combine rows from different sources? In this case you can use a UNION. Suppose you're planning a party and want to invite not only employees but also customers. Then you could run this query to do it:

SELECT FirstName+' '+LastName as ContactName, Address, City FROM Employees
UNION
SELECT ContactName, Address, City FROM Customers

It will return names, addresses and cities from the employees and customers in one single table. Note that duplicate rows (if there should be any) are automatically eliminated (if you don't want this, use a UNION ALL instead). The column number, column names, oder and data type must match across all the select statements that are part of the union- this is why the first SELECT combines FirstName and LastName from Employee into ContactName.



TABLE VARIABLES

It can be useful, if you need to deal with temporary data (especially in a stored procedure), to use table variables;
The difference between a "real" table and a table variable is that it just exist in memory for temporary processing.

Example:
  DECLARE @Region TABLE
  (
  RegionID int,
  RegionDescription NChar (50)
  )

creates a table memory. In this case the @ prefix is mandatory because it is a variable. You can perform all DML , operations mentioned above to insert, delete and select rows
, e.g

  INSERT INTO @Region values (3,Northern)
  INSERT INTO @Region values (4,Southern)

But normally, you would populate it based on real table like

  INSERT INTO \@Region
  SELECT * FROM dbo.Region WHERE RegionID=2;

which would read the filtered values from the real table dbo.Region and inserting it into the memory table @region- where it can be used for further processing. For example, you could use it in a join like:

  SELECT * FROM Territories t
  JOIN @Region r on t.RegionID = r.RegionID

NOTE : Microsoft only recommends the use of the table variables if the number of rows of data in the table variable are less than 100. If you will be working  with larger amounts of data, use a temporary table or temp. table, instead.

SELECT ALL ROWS AND COLUMNS FROM A TABLE


Syntax:

 SELECT * FROM table_name


Using the asterisk operator serves a shortcut for selecting all the columns in the table. All rows will also be selected because this SELECT statement does not have a WHERE clause, to specify any filtering criteria. This would also work the same way if you added an alias to the table, for instance in this case:

  SELECT * FROM Employees AS e

or if you wanted to select all from a specific table you can use the alias +".*":

  SELECT e .*, d.DepartmentName
  FROM Employees AS e
  INNER JOIN Department AS d
  ON e.DepartmentID = d.DepartmentID

Database object may also be accessed using fully qualified names:

 SELECT * FROM [server_name].[database_name].[schema_name].[table_name]

This is not necessarily recommended, as changing the server and/or database names would cause the queries using fully_qualified names to no longer execute due to invalid object names. Note that the fields before table_name can be omitted in many case if the queries are executed on a single server, database and schema, respectively. However, it is common for a database to have multiple schema and in these cases the schema name should not be omitted when possible.

Warning: Using SELECT * in production code or stored procedures can lead to problems later on (as new columns are added to the table, or if columns are rearranged in the table), especially if your code makes simple assumption about the order of columns returned. So it's safer to always explicitly specify column names in SELECT statements for production code.

  SELECT col1, col2, col3


  FROM table_name

Saturday, June 15, 2019

CHAPTER 1: Microsoft SQL Sever

Getting started with Microsoft SQL Sever

Microsoft SQL Server - is a Relational Database Management System. It use to store and retrieve data request by other applications.

Version                             Release Date
SQL SERVER 2017         2017-10-01
SQL SERVER 2016         2016-06-01
SQL SERVER 2014         2014-03-18
SQL SERVER 2012         2011-10-11
SQL SERVER 2008 R2  2010-04-01
SQL SERVER 2008         2008-08-06
SQL SERVER 2005         2005-11-01
SQL SERVER 2000         2000-11-01



CHAPTER1. INSERT/SELECT/UPDATE/DELETE: the basics of Data Manipulation Language

Date Manipulation Language (DML for short) includes operations such as INSERT, UPDATE AND DELETE:

  --Create a table HelloWorld
  CREATE TABLE HelloWorld(
  id INT IDENTITY,
  Description VARCHAR (1000)
  )

  --DML Operation INSERT, inserting a row into the table
  INSERT INTO HelloWorld(Description) VALUES('Hello World')

  --DML Operation SELECT, displaying the table
  SELECT * FROM HelloWorld

  --Select a specific column from table
  SELECT Description FROM HelloWorld

 --Select a specific column from table
 SELECT Description FROM HelloWorld

  --Display number of records in the table
  SELECT Count (*) FROM HelloWorld

  --DML Operation UPDATE, updating a specific row in the table
  UPDATE HelloWorld SET Description = 'Hello World!' WHERE Id=1

If the database table contains columns which are named like reserved word. e.g. DATE , you need to enclose the column name in brackets, like this:

-- descending order
SELECT TOP 10 (Date) FROM dbo.MyLogTable
ORDER BY (Date) DESC

The same applies if the column name contains spaces in its name (which not recommended). An alternative syntax is to use double quotes instead of square brackets,e.g:

-- descending order
SELECT TOP 10 "Date" from dbo.MyLogTable
where Userid='johndoe'
order by "Date"=desc

JOINS
Joins are useful if you want to query fields which don't exist in one single table, but in multiple tables. For example:

You want to query all columns from the Regions table in the Northwind database. But you notice that you require also the RegionDescription, which is stored in a different table, Region. However, there is a common key. RegionID which you can use to combine this information in a single query as follows (top 5 just return the first 5 rows, omit it to get all rows):

SELECT TOP 5 Territories.*,
  Regions.RegionDescription
FROM Territories
INNER JOIN Region
  ON Territories.RegionID=Region.RegionID
ORDER BY TerritoryDescription.



TABLE ALIASES

When your query requires a refference to two or more tables, you may find it useful to use a table Alias. Table aliases are shorthand references to a tables that can be used in place of a full table name, and can reduce typing and editing. The syntax for using an alias is:

<tablename> [as] <alias>

Where as in optional keyword. For example, the previous query can be rewritten as:

SELECT TOP 5 t.*,
  r.RegionDescription
FROM Territories t
INNER JOIN Region r
  ON t.RegionID = r.RegionID
ORDER BY TerritoryDescription

Aliases must be unique for all tables in a query, even if you use the same table twice. For example, if your Employee table included a SupervisorId field, you can use this query to return an employee and his supervisor's name:

SELECT e.*,
  s.Name as SupervisorName --Rename the field for output
FROM Employee e
INNER JOIN Employee s
  ON e.supervisorId = s.EmployeeId
WHERE e.EmployeeId=111

By: Princess Joy Aubrey Belecina

Wednesday, May 1, 2019

NEM vs Ethereum vs Hyperledger

In my journey as one of the cadets in UnionBank’s Blockchain Institute, we have covered so far three potential platforms for designing and developing decentralized applications (dapps). I am going to tackle these platforms, namely NEM, Ethereum, and Hyperledger, as how they differ from each other and what are the strengths and weaknesses in terms of technology, usage and implementation.

NEM

The first platform introduced in Blockchain Institute is called NEM (pronounced as nem). It is a blockchain and cryptocurrency platform launched in 2015 that uses proof-of-importance (PoI) as its consensus algorithm. Unlike other platforms, POI checks the overall support of the user on the platform especially if one had huge investment in NEM. The platform’s main currency is called XEM which is valued at Php 3.14 at the time this is written but creating own currency or token called mosaics is possible.

Advantages:

Experimenting with the platform is quite easy. A user only needs to download NanoWallet, a browser-based application. This allows any user to create accounts, send or receive XEMs, create and manage mosaics, and enabling a feature called multisignatures. Multisig, for short, adds security to one’s NanoWallet by allowing a transaction to proceed only if certain amount of trusted people approve the transaction, just like a joint bank account.

Disadvantages:

While blockchain platforms are usually slow, NanoWallet always suffers from connection issues such as the ‘node’ needs to be changed every time a transaction is made in order to proceed. But the worst thing on this platform in terms of developing dapps is the documentation, or the lack thereof. While NEM has few of it discussing about its SDK, tools, and function calls, their documentations are somewhat unclear. Because of it, NEM is difficult to integrate in a web or mobile app to the point that in our hackathon, only few groups have properly implemented the platform in their projects. Adding to the injury is NEM’s lack of support from developer forum sites like StackOverflow, where bugs, error, or other problems are undocumented.

Ethereum

Second in our blockchain studies is Ethereum. Mostly known as a cryptocurrency in the (almost) same popularity as Bitcoin, Ethereum is also a blockchain development platform for dapps. It uses smart contracts written in its own programming language called Solidity. Smart contracts are where the functions of dapps are located once it is deployed in Ethereum’s blockchain network. Its consensus algorithm is the usual proof-of-work (PoW) where user is checked based on the number or length of work one has made on the platform. It uses a pricing mechanism for transactions called Gas for better resource allocation and in order to avoid spam. To avoid confusion, Ethereum is the platform while Ether (ETH) is the currency priced at a whopping Php 4,577.15 as of this writing.

Advantages:

Solidity has an online IDE called Remix, which means learning the language and playing with the platform requires no prerequisite software to be installed. But when one is ready to take developing dapps to the next level, there are several tools that can be used such as Metamask, Geth, Truffle and Ganache. In addition to that, unlike NEM, Ethereum app development is well-documented and has many support from developer forum sites, meaning searching for solution is a breeze.

Disadvantages:

One major issue of Solidity for me is there is still no stable version of the compiler. While I don’t mind it being in “beta”, the inconsistency of function calls and syntaxes between version updates is a bummer. For example, when I write a code using an online guide and I need to add functions on my own, that requires switching between many compiler versions to see whether it will compile or not. Until Solidity reaches a stable version 1.0, the reliability of the platform is in question.

Hyperledger

The platform we are currently playing with is Hyperledger. It is a collaboration of open-source blockchain platforms initiated by The Linux Foundation in 2016, with major global companies contributing to the project. Among the many frameworks and tools on the initiative, we focus specifically on the Hyperledger Fabric and Hyperledger Composer made by IBM and Digital Asset. Fabric is the framework where smart contracts are deployed, while Composer is a set of tools for developing smart contracts and dapps. Unlike NEM and Ethereum, Hyperledger is only a platform and does not have a cryptocurrency, nor charging fees for every transaction.
                          
Advantages:

The first thing I noticed when learning about Hyperledger is it has a very neat documentation compared to other platforms. More than guides, it offers free and comprehensive online courses through Cognitive Class, and it even has an online GUI called Playground for experimenting the platform.  For me, it is as expected from a well-known company like IBM.

Disadvantages:

While I am still in the process of studying Hyperleger, I cannot justify the fullness of the platform just yet. My two nitpick so far is 1.) it always shows connection problems and Docker issues while performing the lab activity in IBM Blockchain Foundation Developer online class. It is probably just a problem in my computer, so I still solve it as of the moment. Another is 2.) developing in it is resource-heavy, as it downloads files with enormous sizes (usually 100 to 200 MB per file) and activating tools such as Docker use significant amount of RAM and CPU power.

To wrap things up, all three platforms have its ups and downs so none of these are perfect. And for me, the rough sides are acceptable as these are relatively new, but once NEM, Ethereum and Hyperledger have matured enough in terms of performance and stability, it will become widespread across many industries across the world, including UnionBank’s blockchain initiative. With that, the power of blockchain is truly promising and I can’t wait to see what we can build with these in the future.

By Johnny Zarate

What You Need To Know About Ethereum and Hyperledger

In today’s financial space, blockchain is the talk of the town. Many companies are trying to incorporate blockchain technologies in their processes, thus the need for blockchain developers is increasing. Two of the most prominent blockchain technologies are Ethereum and Hyperledger. Before diving deeper into technical aspects of the two, there are some things that needs to be understood first.

Know what blockchain is

Imagine a database, but it has several copies across many computers and is encrypted using cryptographic keys. That is blockchain in a nutshell, as it stores data in blocks distributed in a network. Its first widely known use is in a cryptocurrency called Bitcoin, where every transaction is saved in a blockchain.

    Know the principles of blockchain
            
One of Blockchain’s key “selling” point is the use of consensus when submitting transactions, as data is verified by people in the network before a transaction enters into the blockchain. Another is immutability, meaning once a transaction is stored it can no longer be tampered or deleted. This is significant in the long run as this mechanism preserves records better than databases.

  Know the difference between a private and public blockchain

Let’s go with public blockchain first, as it was the initial idea of blockchain. Being public means virtually anyone across the world has access to the blockchain. Ethereum is public and is for general purpose such as cryptocurrency. One risk associated with this is high risk of being hacked by highly-programming-skilled criminals. To prevent this, transactions must be “paid” using cryptocurrency. In addition, Ethereum has a thing called “gas”, a second currency required so a transaction can go through.

Security concerns lead to the development of private blockchain. Instead of being worldwide accessible, transaction records are stored on a specific, limited network. This is where Hyperledger belongs, as it offers development tools for specifying own blockchain network. Private blockchains do not have cryptocurrency by default, but it can integrate cryptocurrencies from other platforms.

    Know the significance of blockchain in a use case

You might end up saying blockchain is cool, but this does not mean everything is “blockchainable”. Review and understand each aspects of a use case scenario. Once you have created an application design based on the scenario, think carefully if the principles of blockchain can benefit potential users of the application, or its disadvantages will make people “turn off”.

Friday, April 19, 2019

Things To Do In Tagaytay

If you are tired of the city and wanted to have a relax time near in the city, Tagaytay is one of the best for you. They are known for being near in the city but at the same time, you will experience being in the province. And not only that, Tagaytay is known for its cold weather unsual to the temperature in the whole Philippines. 

So now, I will share with you the things that you can do when you visit the small city of Tagaytay:

1. Tagaytay Day Tour

In this tour, it will give you a chance for a quick trip in the most popular spots in Tagaytay like Gingerbread House, Sonya´s Garden, Mahoogany Market, Good Shephers, Picnic Grove and more. As well as the breathtaking views of Taal lake and Taal Volcano. Ang ofcourse, try the local´s specialty called Bulalo made by cooking beef shanks and marrow bones.




Book your tour here.

2. Nature Wellness Spa

To fully experience a relaxation in Tagaytay, you should try the Nature Wellness Spa. Enjoy a massage or scrub. As well the spa´s distinctive brand of ecotherapy or healing by and through nature. 
Reserve here

3. Paradizoo

Another place to visit that is available for all ages is the Paradizoo. It is a 10 hectare land to discover nature and wildlife. They offer you an encounter with your favorite farm animals and get to feed them and flower gardens. 


Book here


4. Zoori at Residence Inn

Another zoo that you can visit is Zoori. Aside from animals, they offer you a scenic view of Taal Volcano while having fan with different animals. Animals that you can see are Serpentarium, Eagles Ridge, Aviary and zoo ground. Aside from all of it, you can also experience to go on an exhilarating scenic bike zip or cable car. 


Reserve now


5. Taal Private Hike

One of the trends right now is hiking. So Tagaytay city also offers a Taal Private Hike which allows you to hike in the smalles volcano in the Philippines. 


Book now!

Friday, March 1, 2019

Things To Do in Manila, Philippines

Manila is the center of the Philippines. Aside from islands, Philippines also offered a beautiful city. And if you are travelling in Philippines, you should not miss its capital.

Now, I am going to show to you the things and activities that you can do whenever you are in Manila.

1. Manila Ocean Park






Manila Ocean Park offers different activities such as follow: Oceanarium, Symphony Evening Show, Barnyard, Birdhouse, Sea Lion Show, All Star Bird Show, Penguid Talk Show, Back of the House, World of Creepy Crawlies, Trails to Antartica Penguin Exhibit, Trails to Antartica Christmas Village, Birds of Prey Kindom, Supertoy Collection and Jellies Exhibit.

The Manila Ocean Park opens at 10:00am-8:00pm every weekdays and 9:00am-8:00am every wednesday.

You can buy your discounted tickets here.

2. The Dessert Museum




It is one of the most trending Museum in the Philippines for its instagramable theme. It is good for all ages. It offers 8 mouthwatering rooms of  sugar filled happiness like the Marshmallow Room, Gummy Room and more!

They are open everyday from 10:00am to 9:00pm

Book your discounted tickets here.

 3. KidZania Manila



KidZania is one of the newest interactive venue for the entire family. It has different activities for children that teaches them lessons such as stuff they need to do during emergencies. It lets them discover their values like responsibility, confidence and independence.

Reserve your tickets here.

4. The Mind Museum


Feel science come alive, which exhibits the wonders of the universe through five interconnected stories. Get access to the Atom Gallery, Life Gallery, Earth Galerry, Universe Galery and Technology Gallery.

Get your tickets here

5. Art in Island



Experience this 3d museum! I remember way back 2015 getting a free ticket to enter Art in Island and it is amazing. It is indeed the best choice for children, couples and family!

Reserve your ticket now

Tuesday, February 5, 2019

Top Companies Chosen By The Korean Embassy

I am sure that most of us already watched a kdrama. Most of Pinoys are fan of kdrama and kpops. Some spend too much time watching kdramas or spending too much money for their kpop concerts. So those are one of the reasons that most of us are planning to go to Korea. Some wants to experience the cold weather or want to see the beauty of korea during sprind.

We all have our own reasons to visit Korea so now, I will give you the list of top companies chosen by Korean Embassy and that are exempted from submitting bank certificate, bank statement and ITR.


  1.  ABS-CBN Network
  2. Citibank, N.A.
  3. Holcim Philippines, Inc.
  4. Honda Philippines
  5. JG Summit Holding Inc.
  6. Maybank
  7. Petron Corporation
  8. Philippine Airlines, Inc.
  9. Philippine Savings Bank
  10.  Samsung Electro-Mechanics Philipines Corp.
  11.  San Miguel Food, Inc.
  12. Seaoil Philippines, Inc.
  13. Toyota Motor Philippines Corporation
  14. Unilab
  15. Universal Robina Corporation
So if you are employees of these companies, you are exempted from submitting bank certificate, bank statement and ITR.

I hope this helped you and good luck to your travel to South Korea!

2019 Holidays and Long Weekends in Philippines


As travelers, holidays and long weekends are such a big gift for all of us. This way, we do not have to ask for leave. So let me share with you the list of 2019 holidays and long weekends in Philippines.

REGULAR HOLIDAYS
  • January 1 (Tuesday) – New Year’s Day
  • April 9 (Tuesday) – Araw ng Kagitingan
  • April 18 – Maunday Thursday
  • April 19 – Good Friday
  • May 1 (Wednesday) – Labor Day
  • June 12 (Wednesday) – Independence Day
  • August 26 (last Monday of August) – National Heroes Day
  • November 30 (Saturday) – Bonifacio Day
  • December 25 (Wednesday) – Christmas Day
  • December 30 (Monday) – Rizal Day

SPECIAL NON-WORKING DAYS
  • February 5 (Tuesday) – Chinese New Year
  • February 25 (Monday) – EDSA People Power Revolution Anniversary
  • April 20 – Black Saturday
  • August 21 (Wednesday) – Ninoy Aquino Day
  • November 1 (Friday) – All Saint’s Day
  • December 8 (Sunday) – Feast of the Immaculate Conception of Mary
  • December 31 (Tuesday) – Last Day of the Year

ADDITIONAL NON-WORKING HOLIDAYS
  • November 2 (Saturday) – All Souls Day
  • December 24 (Tuesday) – Christmas Eve
PLAN AHEAD: 9 long weekends in 2019. This list covers only holidays that fall on a Monday/Friday or Tuesday/Thursday (with one vacation leave in between), making the long weekend possible.
1. December 29, 2018 to January 1, 2019 (Rizal Day and New Year weekend)
2. February 2 to 5, 2019 (Chinese New Year weekend)
3. February 23 to 25, 2019 (EDSA Anniversary weekend)
4. April 6 to 9, 2019 (Araw ng Kagitingan weekend)
5. April 18 to 21, 2019 (Holy Week)
6. August 24 to 26, 2019 (National Heroes' Day weekend)
7. November 1 to 3, 2019 (All Saints/Souls' Day weekend)
8. December 21 to 25, 2019 (Christmas weekend)
9. December 28, 2019 to January 1, 2020 (Rizal Day and New Year weekend)