2016년 8월 22일 월요일

SQL Syntax - Part1


TABLE NAME : 'Customers' 

  • SELECT
    • Used ALMOST ALWAYS! Select the specific columns you want or '*' for every columns in a table

SELECT column_name1, column_name2
FROM table_name1;

or 

SELECT *


FROM table_name1;
-- everything!
  • DISTINCT
    • Select only the different(distinct values) among many duplicate

SELECT DISTINCT column_name, column_name
FROM table_name1;

  • WHERE
    • filter records; extract clause is used to extract only a specified criterion

SELECT column_name, column_name
FROM table_name1
WHERE column_name operator value;

ex) SELECT *
FROM Customers
WHERE Country='Mexico';

SELECT *
FROM Customers
WHERE ID=5;
-- you do not need single quotes('') in a number

Operators in the WHERE Clause

  • = : equal
  • <> / != : not equal
  • > : greater than
  • < : less than
  • >= : greater than or equal
  • <= : less than or equal
  • BETWEEN: Between an inclusive range
  • LIKE: Search for a pattern
  • IN : multiple possible values including 'the value'

  • AND
    • Satisfies both the first AND second condition

SELECT * FROM Customers
WHERE Country = 'Germany' AND City = 'Berlin';
  • OR
    • Satisfies EITHER the first OR second condition

SELECT * FROM Customers
WHERE City = 'London' OR City = 'Berlin';
  • Combining AND & OR

SELECT * FROM Customers
WHERE Country = 'Germany' AND (City = 'London' OR City = 'Berlin');
  • Order By
    • Sort the data by one or more columns
    • could be ascending | descending

SELECT * FROM table_name
ORDER BY column_name ASC|DESC,  column_name ASC|DESC;

SELECT * FROM Customers
ORDER BY Country ASC, City DESC;
  • INSERT INTO
    • Insert new records in a table

INSERT INTO table_name
VALUES (value1, value2, value3, ...);

INSET INTO table_name(column1, column2, column3, ...)
VALUES(value1, value2, value3, ...);

INSERT INTO Customers(CustomerName, ContactName, Address, City, PostalCode, Country)
VALUES('Sue', 'Park', 'TeheranRo', 'Seoul', '15320', South Korea)




Important SQL Commands

Here are some of the most widely used SQL commands
*they are not case-sensitive

  • SELECT : extracts data from a database
  • UPDATE: updates data in a database
  • DELETE: deletes data from a database
  • INSERT INTO: inserts new data into a database
  • CREATE DATABASE: creates a new database
  • ALTER DATABASE: modifies a database
  • CREATE TABLE: creates a new table
  • ALTER TABLE: modifies a table
  • DROP TABLE: deletes a table
  • CREATE INDEX: creates an index(search key)
  • DROP INDEX: deletes an index 


Intro to SQL & Data Types in SQL

Let's learn SQL.

SQL stands for Structured Query Language.
It is used to communicate with a database. Query in SQL lets you organize and find the data you want in large database.

So what can you do with SQL?

  • Execute queries against a DB
  • Retrieve data from a DB
  • Insert/update/delete records in a DB
  • Create new DB
  • Create new table in a DB
  • Create stored procedures in DB
  • Create views in a DB
  • Set permissions on tables, procedures and views


We are first going to learn the main data types used in SQL.

There are a few different data types in SQL.
Data types could be divided into 3 main types :

1. Text and string types
text - a string of any length like Python str or unicode types
char(n) - a string of exactly n characters
archer(n) - a string of up to n characters

- String should always be put in 'single quotes' around text strings and date/time values
ex) '2012-11-23' : date/ text
without quotes 2012-11-23 : this is an integer expression

2. Numeric types
integer - an integer value, like Python int
real - a floating-point value, like Python float. Accurate up to six decimal places.
double precision - a higher-precision floating-point value. Accurate up to 15 decimal places.
decimal - an exact decimal value

3. Date and time types
date - a calendar date; including year, month, and day.
time - a time of day
timestamp - a date and time together



2016년 8월 8일 월요일

[Bloomberg Article] Wal-Mart to Acquire Jet.com for $3.3 Billion to Fight Amazon

Wal-Mart has recently took over Jet.com to gain more dominance in the e-commerce market.

I am going to write down a list of sentences from the article and highlight the important words and explain their meanings for everyone to share and use it in their daily lives.

1.  The move is Wal-Mart’s biggest attempt to date to chase down Amazon, which has dominated e-commerce in much the same way that Wal-Mart has ruled brick-and-mortar retail.
- brick-and-mortar : it describes the physical presence of a building or other structure.
ex) For sure, Wal-Mart is a dominant player in the brick-and-mortar retail!

2. It also started a subscription service similar to Amazon Prime, at half the price, but still trails the e-commerce behemoth in online sales.
- behemoth : a huge or monstrous creature
ex) Amazon is the e-commerce behemoth in the USA.

3. Traditional store-based mass retailers such as Wal-Mart, Target Corp. and Costco Wholesale Corp. have been struggling to fend off Amazon’s momentum in online shopping.
- fend off : prevent the occurrence of; prevent from happening
ex) South Korea fends off any potential attacks from North Korea by initiating THAAD system.

4. Wal-Mart is betting that if anyone can help it catch up to Amazon, it’s Jet.com founder Lore, 45, duked it out with Amazon as founder and chief executive officer of Quidsi, best known for Diapers.com, before a protracted price war and tight credit market during the Great Recession forced him to sell to his competitor for $550 million in 2010.
- duke something out : to fight, usually fist fight.
ex) Amazon ducked Ebay out with dramatic increase of market share via Prime Membership.
- protracted : relatively long in duration
ex) The negotiation has been protracted for months now. It's gotta end sooner or later.

source :

http://www.bloomberg.com/news/articles/2016-08-08/wal-mart-agrees-to-buy-jet-com-for-3-billion-to-fight-amazon

2016년 8월 6일 토요일

Building an Android App

Building Layout Part 1


UI (User Interface) : the whole layout of the app

1. VIEWS
- rectangle on an app
ex) picture, button...etc.

- it always has to be in camel case, meaning no spaces and the  first letter always capitalized

Parts consisting views are;
1. TextView : text
2. ImageView : pictures
3. Button

2. IDE(Integrated Design Environment) - Android Studio in our case!

- XML(eXtensible Markup Language) : 
way to describe how your android app's gonna look 

- XML Syntax:
syntax means rules that make valid/invalid xml

example of XML; 
<TextView
android:text = "Hello world"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

*wrap_content: adjusts the width of the text view to perfectly fit the contents inside it!

- Attributes:
width/height/background/text
-> describes how the 'textview' is gonna look
-> should be put in quotation("")

- <TextView> has default values
-> if you are okay with default values, you don't have to set attributes
-> you have to use precise names/symbols or not there will be errors!
     ex)TextView CANNOT BE TxtView, Textview, text view... etc.

3. Density-independent pixels(DP)

medium resolution device < high resolution device < extra-high resolution device
same physical device for 2 dp by 2dp but different no. of pixels are used in different resolution device!
*dp: density independent pixels

*TIP:
Make touch targets 48dp at least! Otherwise it's gonna be really small.

4. Typography/ Color

- SP(screen pixels) to declare font size
ex) android:textSie = "45sp"

* Useful URL to typography:
https://material.google.com/style/typography.html#
* color: https://material.google.com/style/color.html#

- XML: How to change the color of the background & the content
<TextView
    android:text="wait wait today is your birthday?"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#B71C1C"
    android:background="#FFCDD2"
    android:textSize="45sp"
/>

ImageView
<ImageView
    android:src="@drawable/rocks"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="centerCrop"
/>

android:scaleType="centerCrop"
-> gets the image to fully fill the screen
-> good tool to make the immersive looking screen

URL to Android Developers:
https://developer.android.com/index.html

2016년 8월 4일 목요일

My first post!

Hello,

I have just started to learn some programming.
My major is Psychology am I am now working as a product manager(PM).

I always thought it'd be a good idea to learn some programming skill whenever I have the time to do it.

While learning programming, I thought I'd share what I'm learning on the blog for everyone who's interested in programming.

I hope that one day I will be able to make my own program/app from the scratch and benefit others with my program/app!