Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQL Server Fundamentals for Beginners

Similar presentations


Presentation on theme: "SQL Server Fundamentals for Beginners"— Presentation transcript:

1 SQL Server Fundamentals for Beginners
Harvey Hyman “the database whisperer” Contact:

2 Hyman Bio Senior Chief USCG, OIF PhD, 2012
Georgia Southern, 2013 – 2014 Florida Polytechnic, 2014 – 2015 New College of Florida, 2015 – 2016 Library of Congress, 2016 Moffitt Cancer Center, 2017 Muma College of Business at University of South Florida,

3 Topics Covered Getting Started with SSMS (downloading, installing)
Basic and Interesting Features of 17.9 Navigating the Object Explorer Panel Using the Database Diagram feature Creating a database from your ERD Building Tables and Views Adding a Column after you have data (null problem), adding a PK later Setting up Checks, Rules, Defaults, Triggers Simple Query Operators and SPROCs Joins, inner, outer, “on”

4 Additional References
Separate PPT slide decks are available for each topic listed. They are accompanied by practice databases. Contact Author Directly:

5 If you are starting completely from scratch
SQL Server Engine Express versus Developer SSMS versus SQLCMD Where to find it Downloading Installing

6 Tour of Basic Features 17.9 versus 18 (dropped support for Database Diagram) Navigating the Object Explorer Panel: Folders Databases (where you will spend most of your time) Security (roles, setting logins) Server Objects (server level triggers) Using Database Diagram functionality mapping an existing database, create new database drag and drop, modify an existing database drag and drop Using Table Designer “Right clicking your way to happiness” Table level design versus modify column

7 Creating a database from an ERD
Entities and their relations Attributes PK (selecting data type, identity, seed, increment) Relational Schema Selecting your FK – PK relationships

8 Let’s build some tables
Things to know before you start: Create, attach, detach database DATA folder Tools  Options Designer (uncheck ‘the box’)

9 Creating Tables Items to consider:
Setting PK, Identity, Seed, Increment Column Data Types, Size

10 Setting Relations Between Tables
Adding Column FK in the foreign table. Linking FK in foreign table to PK in primary table.

11 Indexes: Cluster or Non-cluster
Default is PK is indexed as clustered Only one clustered index per table. I recommend setting PK as non-cluster. Index conventions: AK, UN, IX

12 Views What are views? How we can use them to: Test View: Hide columns
Hide rows “Pre-join” columns from multiple tables (we will visit this in Joins) Test View: Select * table vs Select top 20 Select * table_vw Edit top 200 rows SQLCMD

13 SQL Codes create view MaryBrown_vw as select * from Employee
where empno = '1012' CREATE VIEW Employee_vw AS SELECT EmpNo, FirstName, LastName, JobTitle, HireDate, MgrNo, DeptNo FROM Employee

14 Adding a new Column Dealing with a new column null values
Adding a new FK column Adding a new PK column (use identity to avoid the null constraint issue)

15 Constraints Checks Rules Defaults Triggers

16 Queries Select From Where Order by Wild cards: %, *
Comparisons: Like, =

17 SPROCs – Stored Procedure A query wrapped as an executable
Practical Uses: Reusable query Embedded in the database Avoid the need to open .sql file

18 Join Types Inner Left / Right “outer” Full
Operation: exclusive, most common Purpose: Include only matching rows from tables on both sides of join command. Left / Right “outer” Operation: inclusive matching Purpose: Include all from inclusive side (left or right), and only the matching rows from other side. Full Operation: shows all rows from both tables. Purpose: Include matching rows, and rows that don’t have a match from left and rows that don’t have a match from right. Left Right

19 Harvey Hyman “the database whisperer” Any questions?


Download ppt "SQL Server Fundamentals for Beginners"

Similar presentations


Ads by Google