Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Database & Client Server Introduction to MS SQL Server 2000 and Transact SQL -

Similar presentations


Presentation on theme: "Advanced Database & Client Server Introduction to MS SQL Server 2000 and Transact SQL -"— Presentation transcript:

1 Advanced Database & Client Server Introduction to MS SQL Server 2000 and Transact SQL -

2 Module Structure This part of the module consists of –3 lectures –3 lab sessions –The material gives an overview of Microsoft SQL Server 2000 –There are resources on Black Board for some of the lab activities

3 Assessment for this component Is based on the type of assessment used by Microsoft for their certification exams. There will be a Phase Test made up of multiple choice questions taken from a pool of questions in Blackboard. Mock Questions will be available. Questions used in the Mock may appear again in the Phase Test along with new questions. Students are asked to submit questions which may be added to the pool for use in the Mock & Phase Test.

4 An Introduction to : MS SQL Server Architecture Databases and Database Objects Database File Storage Database Security Using MS SQL Server

5 MS SQL Server 2000 Client Server Architecture Server –RDBMS for OLTP and OLAP –Meets many of the general requirements for any RDBMS e.g. Integrity, Relationships, Recovery Clients –Enterprise Manager –Query Analyser –Command line Interface Clients can use –Transact SQL –XML –MDX

6 The 3 Tier Architecture Data presentation –Browser –Custom application Data services –Data access –Data storage Application Logic –Data rules –Business rules

7 MS SQL Server 2000 Application OLEDB ODBC Transact SQL XML MDX Transact SQLADO ADO MD VB ASP VB Script

8 database1 database2 database4 database3 database5 database6 MS SQL Server 2000

9 MSSQLS Databases System : Master msdb model tempdb User : Pubs Northwind User1 User2.....

10 Types of Database Objects Tables Data types Constraints Defaults Rules Indexes Views User Defined Functions Stored Procedures Triggers

11 System Tables Meta Data –Table definitions including column names and data types, null, defaults –Constraints –Rules –Indexes –View definitions –User defined functions, Stored procedures and Triggers

12 Because meta data is stored in tables we access this data the same way as ordinary table data. Using : Information_Schema Views SELECT * FROM INFORMATION_SCHEMA.TABLES System Procedures EXEC SP_HELP objectName System Functions SELECT COL_LENGTH (columnName) System Tables

13 SQL Server Object Names Begin with a letter Delimited Identifiers: – are used when a name contains spaces or reserved words –[....] or "....." Special characters imply special types –@name  a variable or parameter –#name  a temporary object

14 Naming Database Objects server.database.owner.object galba.dbcmssc.cmssc.staff galba.dbcmssc..staff galba.NorthWind.. [Order Details]

15 Physical Storage of Each Database is in 2 or more files Primary File.mdf Primary File.mdf Secondary.ndf Secondary.ndf Transaction Log.ldf Transaction Log.ldf Zero or many secondary files There must be one primary file There must be at least one log file

16 SQL Server Security Login authentication –to access the SQL Server Windows SQL Server Permissions –to access a specific database part of a database (e.g. a column) –to perform actions

17 Working with SQL Server Graphical tools (Enterprise Manager, Query Analyser) Wizards Command line scripts (osql and bcp) Access Web browser Help – Books on line

18 Data Manipulation Language SELECT SELECT FROM JOIN... ON WHERE GROUP BY HAVING ORDER BY

19 ADDITIONS –- TOP n SELECT TOP 10 staff_id, salary FROM staff ORDER BY salary; (10 rows returned) SELECT TOP 5 Percent staff_id, salary FROM staff ORDER BY salary; (1 row returned)

20

21

22 ADDITIONS –Joining Tables Inner Joins Cross Joins Outer Joins (Left, Right and Full)

23 Joining Tables S_ID Name DeptNo DeptNo D_Name Loc Staff S_ID Name Department DeptNo D_Name Location belongs to 1 0..* has

24 Inner Join SELECT staff_id, d_name FROM staff s, department d WHERE s.deptno = d.deptno; Legacy statement SELECT staff_id, d_name FROM staff s JOIN department d ON s.deptno = d.deptno; INNER JOIN department d

25 Cross Join SELECT staff_id, d_name FROM staff s, deptartment d; SELECT staff_id, d_name FROM staff s CROSS JOIN deptartment d;

26 LEFT OUTER JOIN SELECT staff_id, d_name FROM staff s LEFT OUTER JOIN department d ON s.deptno = d.deptno; All values in left table (staff) even if no matches in dept SELECT staff_id, d_name FROM staff s, department d where s.deptno *= d.deptno;

27 LEFT OUTER JOIN staff_ids.deptnod.deptnod_name 19622LIGHT.... 566NULL

28 RIGHT OUTER JOIN SELECT staff_id, d_name FROM staff s RIGHT OUTER JOIN department d ON s.deptno = d.deptno; All values in right table (dept) even if no matches in staff SELECT staff_id, d_name FROM staff s, department d where s.deptno =* d.deptno;

29 RIGHT OUTER JOIN staff_ids.deptnod.deptnod_name 19622 LIGHT.... NULL 4 VISION

30 FULL OUTER JOIN SELECT staff_id, d_name FROM staff s FULL OUTER JOIN department d ON s.deptno = d.deptno; All values in left table (emp) and all values in right table (dept)

31 FULL OUTER JOIN staff_ide.deptnod.deptnod_name 19622Light.... NULL 4Vision 566NULL

32 Dealing with Nulls Null is not the same as zero or space Processing columns that may contain nulls – may require outer joins – may return no results Calculation involving null always returns a null value. Use the function IsNull to convert

33

34 replacement value

35 Summary MS SQL Server Architecture Databases and Database Objects Database File Storage Database Security Using MS SQL Server Transact SQL Extensions –Top n –Joins –isnull


Download ppt "Advanced Database & Client Server Introduction to MS SQL Server 2000 and Transact SQL -"

Similar presentations


Ads by Google