Part 2 – Setting up a database using Microsoft SQL Server
Ok, so assuming you’ve read part 1 of this tutorial and everything went ok, we’ll now need to setup some kind of database backend to store our information. There are various ways we can do this but for this example we’re going to use Microsoft SQL Server 2016 Developer edition. This is now a free download (for development use only not production) when you sign up for developer essentials – click here to open a link to the Microsoft download page. There is of course the other cut down, but completely free version which is the good old SQL Server Express which you can get here. Either version should be fine for this example, although it’s likely that in some production environments you would probably be using SQL Standard or Enterprise editions due to some of the resilience features they have.
When installing SQL Server we’ll only need the database engine for this example, so untick any of the other stuff that maybe selected when you get to the components to install screen. Also don’t forget to add yourself as an admin when you’re given the option!
Another thing to note is unlike previous versions of SQL Server, they’ve changed things in the 2016 version in terms of how you install SSMS (SQL Server Management Studio). Previously it was installed as part of the main install. However, now you need to select it from the front install page after SQL Server has finished installing. I thought something had gone wrong when I first installed it and couldn’t find my trusty old management studio! 🙂
Ok, assuming the install went fine, now open management studio (SSMS) and enter the name of your server when prompted – which in this case will either be your computer name or you can use ‘localhost’ instead, if you had selected a ‘named instance’ when installing then you’d need to enter ‘localhost\instancename’ where ‘instancename’ is the (duh) name of the instance.
Anyway, you should then be presented with a screen a little like this…
Ok then lets create a database!
Right click on the ‘Databases’ folder and create database. You’ll then be presented with a few options to change or set but we only want to set the database name as per below, to ‘Example’ and then click ok…
When creating your database for real production use you would probably change the owner to be something else, either that or you DBA would setup the database for you. In any case, leaving the owner set to <default> is ok for our purposes now, this means it will set the owner of the database as you!
Ok, that’s it for the database side of things for now. We can’t add anything else yet until we decide what we are going to do with our application. We also have a choice coming up where we must decide to take either (what is generally termed) a code first approach, or design our database structure ourselves manually which is usually referred to as the ‘database first’ approach.
More on that in the next part…