Lecturer: Eng. Mohamed Adam Isak PH.D Researcher in CS. M.Sc. and B.Sc. of Information Technology Engineering Senior Lecturer in University of Somalia, Mogadishu university and Dar-al-Hikma university Tell: February –July 2016 SQL SERVER DATABASES
LECTURE 1. BASIC CONCEPT OF SQL SERVER
Outlines Eng.Mohamed Adam Isak, Ph.D. Researcher 3 Why SQL Server? How do I know if my hardware meets the requirements? Can I just confirm that I have the right operating system? What can I do with SQL Server? Installing SQL Server on a Windows platform Where to install SQL Server physically How SQL Server runs on a machine How security is implemented Logon IDs for SQL Server, especially the sa (system administrator) logon
Overview Eng.Mohamed Adam Isak, Ph.D. Researcher 4 SQL stands for Structured Query Language SQL lets you access and manipulate databases SQL is an ANSI (American National Standards Institute) standard. SQL Server is used by: Database Administrator (DBA) Programmers SQL Literate End-users Application Programs
Why SQL Server? Eng.Mohamed Adam Isak, Ph.D. Researcher 5 SQL Server faces competition from other databases, not only from other Microsoft products such as Microsoft Access and Microsoft Visual FoxPro, but also from competitors such as Oracle, Sybase, DB2, and Informix, to name a few. Microsoft Access is found on a large number of PCs. The fact that it is packaged with some editions of Office and has been around for a number of years in different versions of Office has helped make this database ubiquitous; in fact, a great number of people actually do use the software. Unfortunately, it does have its limitations when it comes to scalability, speed, and flexibility, but for many small, in- house systems, these areas of concern are not an issue, as such systems do not require major database functionality. Oracle isn’t as user friendly from a developer’s point of view. Then there is Sybase. Yes, i t is very much like SQL Server with one major exception: it has no GUI front end.
Why SQL Server? Eng.Mohamed Adam Isak, Ph.D. Researcher 6 Each database has its own SQL syntax, although they all will have the same basic SQL syntax, known as the ANSI-92 standard. This means that the syntax for retrieving data, and so on, is the same from one database to another. However, each database has its own special syntax to maintain it, and trying to use a feature from this SQL syntax in one database may not work, or may work differently, in another. So SQL Server seems to be the best choice in the database marketplace, and in many scenarios it is. It can be small enough for a handful of users, or large enough for the largest corporations. It doesn’t need to cost as much as Oracle or Sybase, but it does have the ability to scale up and deal with terabytes of data without many concerns. As you will see, it is easy to install, as it comes as one complete package for most of its functionality, with a simple install to be performed for the remaining areas if required
Evolution of SQL Server (1/2) SQL Server has evolved over the years into the product it is today. 7 Eng.Mohamed Adam Isak, Ph.D. Researcher
Evolution of SQL Server (2/2) Eng.Mohamed Adam Isak, Ph.D. Researcher 8
Hardware Requirements Eng.Mohamed Adam Isak, Ph.D. Researcher 9 CPU The minimum recommended CPU that SQL Server will run on is a 1GHz processor for the 32-bit edition and a 1.6GHz for the 64-bit version, or a compatible processor, or similar processing power; however, 2GHz is recommended Memory Microsoft recommends 1GB or above Hard Disk Space For SQL Server alone, ignoring any data files that you are then going to add on top, you will need over 1GB of space.
Operating System Requirements Eng.Mohamed Adam Isak, Ph.D. Researcher 10 You will find that SQL Server 2008 will run on Windows Vista Home Basic Edition and above, as well as Windows XP. SQL Server 2012 will run on Windows 7 Service Pack 1 and above, as well as Vista Service Pack 2. From the server side, it will work on Windows Server 2003 with Service Pack 2 and Windows Server It will also work on the 64-bit operating systems for Windows XP Professional, as well as the 64-bit editions of Windows Server 2003 and So there is plenty of scope for running SQL Server on many operating systems.
Installation Eng.Mohamed Adam Isak, Ph.D. Researcher 11 Microsoft offers a 120-day trial version at sql/evaluation/trial/ To connect to the server after installation process completion:
The sa Login Eng.Mohamed Adam Isak, Ph.D. Researcher 12 The sa login is a default login that has full administration rights for SQL Server. If you had selected mixed mode authentication during the installation process, you would have seen that you would be forced to include a password for this account. This is because the sa user ID is such a powerful login. It also exists in every SQL Server installation; therefore, any hacker knows that this user ID exists and so will try to connect to the server using it. It is essential to set up a strong password on the sa account. A good password is one that mixes numbers and letters, but doesn’t include letters than can be made into numbers and numbers into letters. For example, pa55word is just as easy to guess as password
What Can SQL do? SQL can execute queries against a database SQL can retrieve data from a database SQL can insert records in a database SQL can update records in a database SQL can delete records from a database SQL can create new databases SQL can create new tables in a database SQL can create stored procedures in a database SQL can create views in a database SQL can set permissions on tables, procedures, and views Eng.Mohamed Adam Isak, Ph.D. Researcher 13
Using SQL in Your Web Site To build a web site that shows some data from a database, you will need the following: An RDBMS database program (i.e. MS Access, SQL Server, MySQL) A server-side scripting language, like PHP or ASP HTML / CSS Eng.Mohamed Adam Isak, Ph.D. Researcher 14
Tasks of a SQL Server DBA Install and configure SQL Server Plan and create databases Backup the databases Restore databases when required Setup and manage users for SQL Servers Manage Security for SQL Server users Setup / Manage task, alerts, operators Setup / Manage replication environment Performance Tune SQL Server Troubleshoot SQL Server related problems Eng.Mohamed Adam Isak, Ph.D. Researcher 15
THE FOLLOWING TWO TABLES: Eng.Mohamed Adam Isak, Ph.D. Researcher 16 OUR EXAMPLES WILL BE BASED ON:
Database Tables A database most often contains one or more tables. Each table is identified by a name (e.g. “EmployeeTable" or “DepartmentTable"). Tables contain records (rows) with data and attributes (columns). Eng.Mohamed Adam Isak, Ph.D. Researcher 17
Employee Table Eng.Mohamed Adam Isak, Ph.D. Researcher 18
SQL DML and DDL SQL can be divided into two parts: The Data Manipulation Language (DML) and the Data Definition Language (DDL). Eng.Mohamed Adam Isak, Ph.D. Researcher 19
DML part of SQL SELECT - extracts data from a database UPDATE - updates data in a database DELETE - deletes data from a database INSERT INTO - inserts new data into a database Eng.Mohamed Adam Isak, Ph.D. Researcher 20
The DDL part of SQL The DDL part of SQL permits database tables to be created or deleted. It also defines indexes (keys), specify links between tables, and impose constraints between tables. The most important DDL statements in SQL are: Eng.Mohamed Adam Isak, Ph.D. Researcher 21
DDL CREATE DATABASE - creates a new database ALTER DATABASE - modifies a database CREATE TABLE - creates a new table ALTER TABLE - modifies a table DROP TABLE - deletes a table CREATE INDEX - creates an index (search key) DROP INDEX - deletes an index Eng.Mohamed Adam Isak, Ph.D. Researcher 22
The SQL SELECT Statement The SELECT statement is used to select data from a database. The result is stored in a result table, called the result-set. SQL SELECT Syntax SELECT column_name(s) FROM table_name SELECT * FROM table_name Note: SQL is not case sensitive. SELECT is the same as select Eng.Mohamed Adam Isak, Ph.D. Researcher 23
The SQL SELECT Statement-Example The asterisk (*) is a quick way of selecting all columns. Eng.Mohamed Adam Isak, Ph.D. Researcher 24
THE DISTINCT SYNTAX In a table, some of the columns may contain duplicate values. This is not a problem; however, sometimes you will want to list only the different (distinct) values in a table. The DISTINCT keyword can be used to return only distinct (different) values. Eng.Mohamed Adam Isak, Ph.D. Researcher 25
THE DISTINCT SYNTAX Eng.Mohamed Adam Isak, Ph.D. Researcher 26
The WHERE Clause The WHERE clause is used to extract only those records that fulfill a specified criterion. Eng.Mohamed Adam Isak, Ph.D. Researcher 27
Select your project from the list you will see after you click here orhere Visit Start up your own project !!!!!!!! Eng.Mohamed Adam Isak, Ph.D. Researcher 28