32
loading...
This website collects cookies to deliver better user experience
"Over the last decade, the amount of data that systems and devices generate has increased significantly. Because of this increase, new technologies, roles, and approaches to working with data are affecting data professionals" - Microsoft
Microsoft SQL Server 2017 Express Edition
, this version is free, whatever you will learn in this version applies to other versions as well.sql server express 2017
in your favourite browser.Install SSMS
this is the SQL Server Management Studio
. It is where we will be writing our sql queries and all the manipulation.If you have credentials to another server, then you will enter it here.
entities
containing all the data structured in various tables. schema's
, think of schema's
as the ownership structure. Essentially meaning within each database we can have different owners. For instance, sales team that owns their own schema and objects underneath and another schema
that belongs to customer service.objects
. Objects are entities such as tables
, stored procedures
, views
etc...file
, at the top left, and choosing the Connect Object Explorer
option. This will open a window, which requires us fill in the details of the second server to access that particular database. We can click cancel
since we are not connecting to another database. AdventureWorks
. You can download it by following the link below.Remember!!! choose the OLTP, AdventureWorks2017.bak file
AdventureWorks
on our newly created database.Store the .bak file in your C:Drive/Program Files/Windows SQL Server, for convienience.
Restore Database
, a window will open.device
option and then click on the ellipsis
on the right-end of the window, they look like three dots **...**
select backup devices
will open, click on the add button on the middle-right of the window. We need to find the .bak file we downloaded earlier. Once we find it, we need to add it and click OK. Then click OK again to add it to the databases folder.AdventureWorks
database, it will show us another set of folders, this is how a database organises objects underneath it.Tables
, this is where all the data gets stored, here we can see all the list of tables. Table are prefixed with the schemaName. The schemaName defines who owns the schema.If things are not completely clear, do not fret. Things will become more digestible as we continue on this journey together.
New Query
it will open a window which is where we will write all our SQL queries. On the left of the menu you will see a dropdown, it will indicate which database we are currently connecting to.When you first click on New Query
, it might connect to the master database, Remember if you want to run a query correctly, you need to be in the correct database. We won't be using the master database because it is used by SQL internally.
Customer ID | FirstName | Lastname | Company | State | Main Store |
---|---|---|---|---|---|
1 | James | Butt | Microsoft | Dallas | Mall |
2 | Josephine | Dimson | Dell | Washington | Strip mall |
3 | Rib | Collar | Dallas | Mall | |
4 | Barry | White | Microsoft | California | Square |
5 | Ian | Sims | New York | Square | |
6 | Michelle | Niel | Asus | Texas | Mall |
7 | Greg | Lawson | Dell | Washington | Strip mall |
This is an example of denormalised data.
Customer ID | FirstName | Lastname | Company | State | Main Store |
---|---|---|---|---|---|
1 | James | Butt | 1 | DA | 1 |
2 | Josephine | Dimson | 2 | WA | 3 |
3 | Rib | Collar | 4 | DA | 1 |
4 | Barry | White | 1 | CA | 2 |
5 | Ian | Sims | 4 | NY | 2 |
6 | Michelle | Niel | 3 | TX | 1 |
7 | Greg | Lawson | 2 | WA | 3 |
Store ID | Store |
---|---|
1 | Mall |
2 | Square |
3 | Strip mall |
State ID | State |
---|---|
DA | Dallas |
CA | California |
WA | Washington |
NY | New York |
TX | Texas |
Company ID | Company |
---|---|
1 | Microsoft |
2 | Dell |
3 | Asus |
4 |
This is an example of a normalised database structure.