Monday, June 17, 2013

MS SQL:Create Index (Transact-SQL)

An index can be created before there is data in the table. Relational indexes can be created on tables or views in another database by specifying a qualified database name.

Refer  notes from: http://msdn.microsoft.com/en-us/library/ms188783.aspx

Sample:
create index PARAMETER on TABLE (COLUMN)



CREATE INDEX SHP_ID_CREATE_DATE
ON C.SHOPPER (CREATE_DATE)


CREATE INDEX ORDER_CREATE_DATE
ON E.ORDERS(CREATE_DATE)


.

Monday, December 24, 2012

Wordpress: Permalinks problem in UBUNTU

How to get WordPress permalinks / pretty links to work in Ubuntu 10.10 with Apache2

1. Manually create a ".htaccess" file and save it in your main WordPress directory. (This is the one with the wp-admin, wp-includes, and wp-content folders.)

2. Go to the Ubuntu terminal and type:
sudo chown -v :www-data "/enterYourFilePathHere/.htaccess"

You should see a line printed saying that the (group) file ownership has been changed to www-data (Apache2).

3. Give Apache2 write access to the file:
sudo chmod -v 664 "/enterYourFilePathHere/.htaccess"
You should see a line printed saying that the mode of the file has been retained.

4. Next, we have to allow WordPress to write to the .htaccess file by enabling mod_write in the Apache2 server. Type the following in the terminal:
sudo a2enmod rewrite

You should see a line printed saying that it is enabling mod rewrite and reminding you to restart the web server

5. So let's do that. Restart the web server, Apache2, for the changes to take effect by typing:
sudo /etc/init.d/apache2 restart

We are all done with the command line prompt; you can close the command line window now.

5. Go into your WordPress admin panel (i.e. http://yourDomain/wp-admin). Go to the Settings --> Permalinks and select the permalink format of your choice. Hit the "Save Changes" button.

6. DONE! Go to your site and check any page (other than your homepage) to ascertain that everything is working as expected.

**
7. The additional step I had to take was to edit /etc/apache2/sites-enabled/000-default.
    In that file you'll find an AllowOverride setting for /var/www, saying "None".

    Change the setting to say: AllowOverride All
    Restart the web server, Apache2, for the changes to take effect by typing:
  sudo /etc/init.d/apache2 restart
   

Thursday, November 1, 2012

XAMPP: Apache cannot start because IIS

I was in a middle to activate my localhost using xampp, apache web service. But unluckily, my pc already have iis automatically run on startup. So I try to find a way to disable the IIS Service.

Finally I found this:

1. Control Panel > Programs and Features > Turn Windows features on or off. 

2. Uncheck the box for Internet Information Services.

3. Ok

Wednesday, October 31, 2012

Data Warehouse: Data Normalization

Data Normalization splits up data to avoid redundancy (duplication) by moving commonly repeating groups of data into new tables. 


Database Normalization Example


The following graphic gives an example of a typical conversion of an un-normalized table to multiple normalized tables.
Advantages of Database Normalization:
  • Data integrity is maintained.
  • Results of queries are predictable.
  • Changes to data have to be made only once.

  • Amount of storage required by the database is optimal.


Read more reference:
http://en.wikipedia.org/wiki/Data_normalization
http://en.wikipedia.org/wiki/Database_normalization
http://www.sqlsteps.com/what-sql-classes-dont-normally-cover
.

Data Warehouse: Snowflake Schema


Snowflake Schema

In data warehouse, a snowflake schema is a logical arrangement of tables in a multidimensional database such that the entity relationship diagram resembles a snowflake in shape. The snowflake schema is represented by centralized fact tables which are connected to multiple dimensions.

It is similar to the star schema. However, in the snowflake schema, dimensions are normalized into multiple related tables, whereas the star schema's dimensions are normalized with each dimension represented by a single table.

Example:Snowflake schema used by example query.


SELECT
        B.Brand,
        G.Country,
        SUM(F.Units_Sold)
FROM Fact_Sales F
INNER JOIN Dim_Date D             ON F.Date_Id = D.Id
INNER JOIN Dim_Store S            ON F.Store_Id = S.Id
INNER JOIN Dim_Geography G        ON S.Geography_Id = G.Id
INNER JOIN Dim_Product P          ON F.Product_Id = P.Id
INNER JOIN Dim_Brand B            ON P.Brand_Id = B.Id
INNER JOIN Dim_Product_Category C ON P.Product_Category_Id = C.Id
WHERE
        D.YEAR = 1997 AND
        C.Product_Category = 'tv'
GROUP BY
        B.Brand,
        G.Country




Read more: http://en.wikipedia.org/wiki/Snowflake_schema

Data Warehouse: Star Schema

Star Schema
In Data Warehouse, the combination of facts and dimensions is sometimes called a star schema.

The star schema (also called star-join schema, data cube, or multi-dimensional schema) is the simplest style of data warehouse schema. The star schema consists of one or more fact tables referencing any number of dimension tables.

Model (refer the graphic above)

  • The fact table holds the metric values recorded for a specific event. Because of the desire to hold atomic level data, there generally are a very large number of records (billions). Special care is taken to minimize the number and size of attributes in order to constrain the overall table size and maintain performance. Fact tables generally come in 3 flavors - transaction (facts about a specific event e.g. Sale), snapshot (facts recorded at a point in time e.g. Account details at month end), and accumulating snapshot tables (e.g. month-to-date sales for a product).
  • Dimension tables usually have few records compared to fact tables, but may have a very large number of attributes that describe the fact data.

    Read more: http://en.wikipedia.org/wiki/Star_schema

Data: Data Marts


Data warehouses can be subdivided into data marts. Data marts store subsets of data from a warehouse.

Data Mart is the access layer of the data warehouse environment that is used to get data out to the users. The data mart is a subset of the data warehouse that is usually oriented to a specific business line or team.

In deployments, each department/business unit is considered the owner of its data mart including all the hardware, software and data.

Each department able to manipulate and develop their data any way they see fit; without altering information inside other data marts or the data warehouse. 

Read more: http://en.wikipedia.org/wiki/Data_mart