You are on page 1of 10

Analysis Services Introduction. Creating OLAP cube Analysis Services Introduction.

Creating OLAP cube


This article show you, how to create data warehouse: database, dimensions, measures and OLAP cube.

1. Creating a Database
1. Create car_transactions database. Open SQL Server Management Studio and execute the command
CREATE DATABASE car_transactions;

2. Swich to car_transacion database and create a few table

use car_transactions; CREATE TABLE Categories ( CatId ); INT IDENTITY(1,1) PRIMARY KEY, Category VARCHAR(50),

Lear more, visit: http://www.learn-with-video-tutorials.com

Analysis Services Introduction. Creating OLAP cube


CREATE TABLE Countries ( CountryId INT IDENTITY(1,1) PRIMARY KEY, Country ); CREATE TABLE Cities ( CityId City ); CREATE TABLE Customers ( CustId CityId Name ); CREATE TABLE Salesmen ( SalesmanId INT IDENTITY(1,1) PRIMARY KEY, Surname Name EmpDate BossId ); CREATE TABLE Company ( CompanyId INT IDENTITY(1,1) PRIMARY KEY, CityId Company ); CREATE TABLE Cars ( INT FOREIGN KEY REFERENCES Cities(CityId), VARCHAR(33), VARCHAR(15), VARCHAR(15), DATETIME, INT, INT IDENTITY(1,1) PRIMARY KEY, INT FOREIGN KEY REFERENCES Cities(CityId), VARCHAR(15), INT IDENTITY(1,1) PRIMARY KEY, VARCHAR(33), CountryId INT FOREIGN KEY REFERENCES Countries(CountryId), VARCHAR(55),

Surname VARCHAR(15),

Lear more, visit: http://www.learn-with-video-tutorials.com

Analysis Services Introduction. Creating OLAP cube


CarId CompanyId Car Model ); CREATE TABLE Transactions_facts_table ( CarId INT FOREIGN KEY REFERENCES Cars(CarId), CustomerId INT FOREIGN KEY REFERENCES Customers(CustId), SalesmanId INT FOREIGN KEY REFERENCES Salesmen(SalesmanId), SalesDate Price Amount Value ); DATETIME, MONEY, INT, MONEY INT IDENTITY(1,1) PRIMARY KEY, INT FOREIGN KEY REFERENCES Company(CompanyId), VARCHAR(50), VARCHAR(50) CategoryId INT FOREIGN KEY REFERENCES Categories(CatId),

2. Insert a few records


Open SQL Server Management Studio and execute the script.
INSERT INTO Categories (Category) VALUES ('Hatchback'); INSERT INTO Categories (Category) VALUES ('Sedan'); INSERT INTO Categories (Category) VALUES ('Coupe'); INSERT INTO Categories (Category) VALUES ('Convertible'); INSERT INTO Categories (Category) VALUES ('Wagon'); INSERT INTO Categories (Category) VALUES ('SUV'); INSERT INTO Countries (Country) VALUES ('Germany'); INSERT INTO Countries (Country) VALUES ('USA'); INSERT INTO Countries (Country) VALUES ('Japan'); INSERT INTO Countries (Country) VALUES ('UK'); INSERT INTO Countries (Country) VALUES ('South Korea'); INSERT INTO Countries (Country) VALUES ('Italy'); INSERT INTO Cities (CountryId, City) VALUES (1,'Stuttgart'); INSERT INTO Cities (CountryId, City) VALUES (1,'Munich');

Lear more, visit: http://www.learn-with-video-tutorials.com

Analysis Services Introduction. Creating OLAP cube


INSERT INTO Cities (CountryId, City) VALUES (2,'Dearborn'); INSERT INTO Cities (CountryId, City) VALUES (2,'Warren'); INSERT INTO Cities (CountryId, City) VALUES (3,'Toyota'); INSERT INTO Cities (CountryId, City) VALUES (3,'Fuchu'); INSERT INTO Cities (CountryId, City) VALUES (4,'Gaydon'); INSERT INTO Cities (CountryId, City) VALUES (4,'Crewe'); INSERT INTO Cities (CountryId, City) VALUES (4,'Whitley'); INSERT INTO Cities (CountryId, City) VALUES (5,'Seoul'); INSERT INTO Cities (CountryId, City) VALUES (6,'Maranello'); INSERT INTO Cities (CountryId, City) VALUES (6,'Modena'); INSERT INTO Company (CityId, Company) VALUES (1,'Mercedes-Benz'); INSERT INTO Company (CityId, Company) VALUES (2,'Bayerische Motoren Werke AG'); INSERT INTO Company (CityId, Company) VALUES (3,'Lincoln'); INSERT INTO Company (CityId, Company) VALUES (4,'Cadillac'); INSERT INTO Company (CityId, Company) VALUES (5,'Toyota Motor Corporation'); INSERT INTO Company (CityId, Company) VALUES (6,'Mazda Motor Corporation'); INSERT INTO Company (CityId, Company) VALUES (7,'Aston Martin Lagonda Limited'); INSERT INTO Company (CityId, Company) VALUES (8,'Bentley Motors Limited'); INSERT INTO Company (CityId, Company) VALUES (9,'Jaguar Cars Ltd'); INSERT INTO Company (CityId, Company) VALUES (10,'Kia Motors'); INSERT INTO Company (CityId, Company) VALUES (10,'Hyundai Motor Company'); INSERT INTO Company (CityId, Company) VALUES (11,'Ferrari S.p.A.'); INSERT INTO Company (CityId, Company) VALUES (12,'Maserati'); INSERT INTO Cars (CategoryId, CompanyId, Car, Model) VALUES (1, 1, 'Mercedes-Benz', 'A-Class'); INSERT INTO Cars (CategoryId, CompanyId, Car, Model) VALUES (1, 1, 'Mercedes-Benz', 'B-Class'); INSERT INTO Cars (CategoryId, CompanyId, Car, Model) VALUES (2, 1, 'Mercedes-Benz', 'C-Class'); (.) INSERT INTO Cars (CategoryId, CompanyId, Car, Model) VALUES (4, 12, 'Ferrari', 'California'); INSERT INTO Cars (CategoryId, CompanyId, Car, Model) VALUES (2, 13, 'Maserati', 'Quattroporte'); INSERT INTO Cars (CategoryId, CompanyId, Car, Model) VALUES (3, 13, 'Maserati', 'GranTurismo'); INSERT INTO Salesmen (Surname, Name, EmpDate, BossId) VALUES ('Smith', 'John', '2002-0504', NULL); INSERT INTO Salesmen (Surname, Name, EmpDate, BossId) VALUES ('Johnson', 'Mark', '2002-

Lear more, visit: http://www.learn-with-video-tutorials.com

Analysis Services Introduction. Creating OLAP cube


06-01', 1); INSERT INTO Salesmen (Surname, Name, EmpDate, BossId) VALUES ('Kolarov', 'Steve', '200206-10', 1); INSERT INTO Salesmen (Surname, Name, EmpDate, BossId) VALUES ('Williams', 'Michael', '2003-10-01', 1); INSERT INTO Salesmen (Surname, Name, EmpDate, BossId) VALUES ('Cronenberg', 'Will', '2004-03-01', 1); INSERT INTO Customers (CityId, Name, Surname) VALUES (1, 'Joshua', 'Brown'); INSERT INTO Customers (CityId, Name, Surname) VALUES (2, 'Jan', 'Davis'); INSERT INTO Customers (CityId, Name, Surname) VALUES (3, 'Willam', 'Novicki'); --(...) INSERT INTO Customers (CityId, Name, Surname) VALUES (3, 'Daniel', 'Williams'); INSERT INTO Customers (CityId, Name, Surname) VALUES (4, 'Jan', 'Cote'); INSERT INTO Customers (CityId, Name, Surname) VALUES (5, 'Ethan', 'Taylor'); INSERT INTO Transactions_facts_table (CarId, CustomerId, SalesmanId, SalesDate, Price, Amount, Value) VALUES (1, 1, 1, '2010-05-29', 30000, 1, 30000); INSERT INTO Transactions_facts_table (CarId, CustomerId, SalesmanId, SalesDate, Price, Amount, Value) VALUES (2, 2, 2, '2010-05-29', 35000, 1, 35000); --(....) INSERT INTO Transactions_facts_table (CarId, CustomerId, SalesmanId, SalesDate, Price, Amount, Value) VALUES (70, 3, 1, '2011-12-22', 250000, 1, 250000);

3. Create a user
1. Open SQL Server Management Studio. 2. In Object Explorer, right-click the Logins folder and select New Login. 3. Type login name. 4. Select SQL Server authentification. 5. Type and confirm password. 6. Our password is simply. We clear Enforce password policy option. 7. Select default database.

Lear more, visit: http://www.learn-with-video-tutorials.com

Analysis Services Introduction. Creating OLAP cube

8. Click Server Roles.tab and Select the appropriate role. 9. Click OK.

4. Creating an Analysis Services Project


1. On the Microsoft Windows task bar, click Start, point to All Programs, expand the Microsoft SQL Server xxxx folder, and then select SQL Server Business Intelligence Development Studio. 2. On the File menu, point to New and then select Project. 3. Name your project. The text in the Solution Name box changes automatically to match the project name. 4. If you want select Create Directory for Solution and change the solution name 5. Click OK to create the project. Lear more, visit: http://www.learn-with-video-tutorials.com

Analysis Services Introduction. Creating OLAP cube


Watch, how to create an Analysis Services Project. Visit: http://www.learn-with-video-tutorials.com/analysis-services-video-tutorial-free

5. Creating a Data Source


The first task in creating an Analysis Services project is to create a data source. The data source contains the information that Analysis Services uses to connect to the source database. It contains the data provider name, the server and database name, and the authentication credentials that Analysis Services will use. 1. In BIDS in Solution Explorer, right-click the Data Sources folder and select New Data Source. The Data Source Wizard appears. 2. On the Welcome page, click Next. 3. On the Select How To Define The Connection page, click the New button. The Connection Manager dialog box appears. 4. Type a server name: localhost. 5. In the Select Or Enter A Database Name list box, select car_transactions 6. Click Test Connection. A dialog box opens with the message Test connection succeeded. Click OK. 7. Click OK to close the Connection Manager dialog box. 8. In the Data Source Wizard, on the Select How To Define The Connection page, click Next. 9. On the Impersonation Information page, select Use The Service Account and click Next. 10. Click Finish to complete the wizard. Now that you have created a data source, you are ready to create a data source view. Watch, how to create a Data Source. Visit: http://www.learn-with-video-tutorials.com/analysis-services-video-tutorial-free

6. Creating a Data Source View


A data source view is a logical data model that exists between your physical source database and Analysis Services dimensions and cubes. When you create a data source view, you designate the tables and views in the source database that contain data that you want to use to build dimensions and cubes. 1. In Solution Explorer, right-click the Data Source Views folder and select New Data Source View. The Data Source View Wizard appears. 2. On the Welcome page, click Next. 3. On the Select a Data Source page, select the car_transactions relational data source and click Lear more, visit: http://www.learn-with-video-tutorials.com

Analysis Services Introduction. Creating OLAP cube


Next. 4. Select dimensions and facts tables and then click Add Related Tables and Click Next. Accept the default name and click Finish. 5. The Data Source View designer appears, displaying the tables you selected Watch, how to create a Data Source View. Visit: http://www.learn-with-video-tutorials.com/analysis-services-video-tutorial-free

7. Creating dimesnions
Creating a customer dimension 1. In Solution Explorer, right-click the Dimensions folder and select New Dimension. 2. On the Welcome to the Dimension Wizard page, click Next. 3. Verify that Use An Existing Table is selected and click Next. 4. Select Customers from the Main Table list. 5. Select Surname from the Name Column list and then click Next. 6. Verify that the Cities and Countries tables are selected and click Next. 7. From the Available Attributes list, select all atributies and click Next. 8. On the Completing The Wizard page, type dimension name and click Finish. 9. Drag the Country attribute from the Attributes pane and drop to Hierarchies pane. 10. Drag the City and Cust ID attribute from the Attributes pane and drop it on <new level>. 11. In the Hierarchies pane, right-click the new hierarchy header and select Rename. Type Country Customers Hierarchy and press Enter. 12. In Object Explorer, right-click the Customers dimension, and select Process. Then click Yes. 13. In the Process Dimension dialog box, click Run. 14. In the Process Progress dialog box, click Close. Now that the Customers dimension has been builded. 15. You can preview the dimension - click Browser tab. Create another dimension: salsmen, cars and time. Watch, how to create all dimensions. Visit: http://www.learn-with-video-tutorials.com/analysis-services-video-tutorial-free Lear more, visit: http://www.learn-with-video-tutorials.com

Analysis Services Introduction. Creating OLAP cube 8. Creating a cube


1. In Solution Explorer, right-click the Cubes folder and select New Cube. 2. On the Welcome To The Cube Wizard page, click Next. 3. Verify that Use Existing Tables is selected and click Next. 4. In the Measure Group Tables list, select the Transactions_facts_table and click Next. 5. The Select Measures page lists the measure groups and measures that the wizard will create. Click Next. 6. On the Select Existing Dimensions page, verify that the Customers, Cars and Salesmen dimensions are selected. Click Next. 7. On the Completing The Wizard page, type the name of the cube and click Finish. 8. The Cube Designer appears, displaying the structure of the Car transactions cube. 9. In the Dimensions, right-click and select Add Cube Dimension. 10. In the Add Cube Dimension, select Time and click OK. 11. In the Cube Designer, click the Dimension Usage tab. 12. Select the cell in the grid at the intersection of the Time dimension and the Transactions Cars Facts measure group. Click the ellipsis button. Choose Regular type. Choose Date. 13. Create the relationship between Date column (Time dimension) and SalesDate column (facts table). Choose SalesDate. 14. In Solution Explorer, right-click the Car Transactions cube and select Process Cube. 15. Click Run to process cube. 16. Select Browser tab to preview cube. Watch, how to create a cube. Visit: http://www.learn-with-video-tutorials.com/analysis-services-video-tutorial-free

Lear more, visit: http://www.learn-with-video-tutorials.com

Analysis Services Introduction. Creating OLAP cube

Lear more, visit: http://www.learn-with-video-tutorials.com

You might also like