Data Types Lesson 4. Skills Matrix Table A table stores your data. Tables are relational in that they are organized as rows and columns (a matrix). Each.

Slides:



Advertisements
Similar presentations
Yukon – What is New Rajesh Gala. Yukon – What is new.NET Framework Programming Data Types Exception Handling Batches Databases Database Engine Administration.
Advertisements

Project Management Database and SQL Server Katmai New Features Qingsong Yao
Tables Lesson 6. Skills Matrix Tables Tables store data. Tables are relational –They store data organized as row and columns. –Data can be retrieved.
Module 4: Creating Data Types and Tables. Overview Creating Data Types Creating Tables Generating Column Values Generating Scripts.
1 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management.
Copyright ©2014 Pearson Education, Inc. Chapter 6 Physical Design Chapter6.1.
Database Fundamentals
Introduction to SQL  SQL or sequel  It is a standardised language with thousands of pages in the standard  It can be in database system through GUI,
Working with Data Types February 7, 2015 John Deardurff Website:
Module 2 Working with Data Types. Module Overview Using Data Types Working with Character Data Converting Data Types Working with Specialized Data Types.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 13 Managing Databases with SQL Server 2000.
Rationale Aspiring Database Developers should be able to efficiently query and maintain databases. This module will help students learn the Structured.
Functions Lesson 10. Skills Matrix Function A function is a piece of code or routine that accepts parameters and stored as an object in SQL Server. The.
Databases Lesson 5.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Chapter 7 SQL HUANG XUEHUA. SQL SQL server2005 introduction Install components  management studio.
Architecture Rajesh. Components of Database Engine.
Using New Data Types in 2008 Andrew Couch UK Access User Group ASC associates
Module 3 Designing a Physical Database Model. Module Overview Selecting Data Types Designing Database Tables Designing Data Integrity.
Sizing Basics  Why Size?  When to size  Sizing issues:  Bits and Bytes  Blocks (aka pages) of Data  Different Data types  Row Size  Table Sizing.
SQL Data Definition Language (DDL) Using Microsoft SQL Server 1SDL Data Definition Language (DDL)
Unit 6 Data Storage Design. Key Concepts 1. Database overview 2. SQL review 3. Designing fields 4. Denormalization 5. File organization 6. Object-relational.
11 3 / 12 CHAPTER Databases MIS105 Lec15 Irfan Ahmed Ilyas.
Module 3: Creating Data Types and Tables. Overview Working with Data Types Working with Tables Generating Column Values Generating Scripts.
Christopher M. Pascucci.NET Programming: Databases & ADO.NET.
Access 2007 ® Use Databases How can Microsoft Access 2007 help you structure your database?
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
SQL Server 2005 Implementation and Maintenance Chapter 3: Tables and Views.
Session 11 Creating Tables and Using Data Types. RDBMS and Data Management/Session 11/2 of 40 Session Objectives Define the data types and list the categories.
GLOBEX INFOTEK Copyright © 2013 Dr. Emelda Ntinglet-DavisSYSTEMS ANALYSIS AND DESIGN METHODSINTRODUCTORY SESSION EFFECTIVE DATABASE DESIGN for BEGINNERS.
Sql DDL queries CS 260 Database Systems.
IMS 4212: Data Modeling—Attributes and Domains 1 Dr. Lawrence West, Management Dept., University of Central Florida Attributes and Domains.
Constraints Lesson 8. Skills Matrix Constraints Domain Integrity: A domain refers to a column in a table. Domain integrity includes data types, rules,
INTRODUCING SQL SERVER 2012 COLUMNSTORE INDEXES Exploring and Managing SQL Server 2012 Database Engine Improvements.
Academic Year 2015 Autumn. MODULE CC2006NI: Data Modelling and Database Systems Academic Year 2015 Autumn.
SQL server Section 2&3. What are Data Types Character Data Types Number Data Types Date and Time Data Types CAST and CONVERT functions TRY_PARSE and TRY_CONVERT.
Module 9: Using Advanced Techniques. Considerations for Querying Data Working with Data Types Cursors and Set-Based Queries Dynamic SQL Maintaining Query.
Creating E/R Diagrams with SQL Server Management Studio, Writing SQL Queries D0ncho Minkov Telerik School Academy schoolacademy.telerik.com Technical Trainer.
What is your Character Data Type? March 5, 2016 John Deardurff Website:
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
Advanced SQL - DDL Advanced Database Dr. AlaaEddin Almabhouh.
14 New T-SQL Functions By Sam Nasr, MCAD, MCT, MCTS NIS
Querying with Transact-SQL
Creating Database Objects
Managing Tables, Data Integrity, Constraints by Adrienne Watt
Module 2: Creating Data Types and Tables
Lecture 6 Data Model Design (continued)
Data Definition and Data Types
Lesson 7 Managing Data Creating a database with Web Matrix.
Attributes and Domains
Ouch! Our Data Type Choices Did THAT?
SQL Server 2016 JSON Support FOR Data Warehousing
SQL Implementation & Administration
14 T-SQL Functions You May Not Know
Migrating a Disk-based Table to a Memory-optimized one in SQL Server
Proper DataType Usage = Guaranteed Better Performance and Accuracy
What is your Character Data Type?
Working with Data Types
Database systems Lecture 2 – Data Types
A JSON’s Journey through SQL Server
CIS16 Application Programming with Visual Basic
PT2520 Unit 5: Physical Design
Data Types Do Matter Start local instance of SQL Start ZoomIt
14 T-SQL Functions You May Not Know
Attributes and Domains
Chapter 8 Advanced SQL.
Creating Database Objects
Presentation transcript:

Data Types Lesson 4

Skills Matrix

Table A table stores your data. Tables are relational in that they are organized as rows and columns (a matrix). Each intersection of a row and column provides a storage location. Each storage field must be defined with a data type.

Data Type Specifies the kind of information that can be stored in a column, parameter, or variable. System-supplied data types are provided by SQL Server. Alias data types (formerly known as user- defined data types) can be created by any database user.

Built-in Data Types Each field, or column, in a table has a specific data type, which causes the RDBMS to restrict the type of data that can be inserted.

SQL Server Built-in Data Types biging binary bit char date datetime datetime2 datetimeoffset decimal float geography geometry hierarchyid image int money nchar ntext numeric nvarchar

SQL Server Built-in Data Types nvarchar(max) real smalldatetime smallint smallmoney sql_variant text time timestamp tinyint uniqueidentifier varbinary varbinary (max) varchar varchar(max) vardecimal xml

Data Type Precedence Data types have a certain order, or precedence. This means when combining data types, implicit data conversion occurs, and the data type with the highest rank will be given priority.

Data Type Precedence 1.User-defined data types (highest) 2.Sql_Variant 3.Xml 4.DateTimeOffset 5.DateTime2 6.DateTime 7.SmallDateTime 8.Date 9.Time 10.Float 11.Real 12.Decimal 13.Money 14.SmallMoney 15.BigInt 16.Int 17.SmallInt 18.TinyInt 19.Bit 20.NText

Data Type Precedence 21.Text 22.Image 23.Timestamp 24.Uniqueidentifier 25.Nvarchar/Nvarchar(Max) 26.Nchar 27.Varchar/Varchar(Max) 28.Char 29.VarBinary/VarBinary(Max) 30.Binary (lowest)

Formatting and Converting Data You’ll often need to convert and modify data. SQL Server offers an extensive set of functions you can use to perform conversions and formatting. You can categorize these functions into groups, as delineated in the following sections.

Introducing Alias Data Types Sometimes it’s useful to create your own data types in order to streamline your business environment and use a common method for referring to specific data. You gain a major benefit when using managed code, CLR (common language runtime), because it also gives you the ability to create a complex data type and define its methods and properties. You define an alias data type in SQL Server by using either the CREATE TYPE or the sp_addtype syntax.

Creating CLR User-Defined Types Working with managed code data types or CLR alias types adds an additional dimension to how you work with SQL Server. –A user-defined type can be a CLR class that has reference types and value types. Alias types contain multiple elements and are useful in environments to indicate geospatial data, to indicate date and time functionality, or even to perform data encryption or object-oriented storage.

Creating CLR User-Defined Types Catalog the assembly (CREATE ASSEMBLY). Create the data type by using a CREATE TYPE statement, in which you reference the assembly.

Data Row A data row consists of a row header (4 bytes) followed by a data portion. The data portion can contain: –Fixed-length data –Null block –Variable block –Variable-length data

Page SQL Server enters fixed-length data into a slot on a page before variable-length data. An empty fixed-length data entry takes as much space as a populated entry. A table with only fixed-length columns always stores the same number of rows on a page.

Estimating Table Storage Requirements Tables provide templates specifying data storage. All data stored in a table must adhere to a data type.

Estimating Table Storage Requirements You can follow a specific process to estimate the space required by a table: –1.Calculate the space used by a single row of the table. –2.Calculate the number of rows that fit on one page. –3.Estimate the number of rows the table will hold. –4.Calculate the total number of pages that might be required to hold these rows.

Data Types and Sizes

Calculating Rows Per Page Once you have a number indicating the total bytes used per row, you can easily calculate the number of rows that fit on a single page. Because every page equals 8 KB in size and has a header, about 8,096 bytes are free for storing data. You can calculate the total number of rows per page as follows: 8096 ÷ (RowSize + 2)

Estimating Table Storage Requirements Estimating the Number of Rows for the Table Calculating the Number of Pages Needed Estimating Index Storage Requirements

Summary You learned that tables consist of columns and rows (entities and instances) and that each of the fields (the intersections) in the table has a specific data type that restricts the form of data it can hold and return.

Summary Then you learned you can create your own data types both with Transact-SQL and with several procedural languages. –Transact-SQL data types use system data types with all the required parameters presupplied and labeled in a more obvious way; for example, zip instead of char(5).

Summary You learned that each of these data types has a storage requirement. –Based on your choices your database can be larger than optimum to meet your business needs. –Consider sitting down with subject matter experts and plan data requirements prior to creating database objects.

Summary –Consider using the techniques espoused by Business Process Reengineering, Joint Application Design, or Service-Oriented Architecture techniques to help you. –You need to decide what tables will contain and make the tables as specific and efficient as possible.

Summary Consider using automated tools such as ER/Studio (Embarcadaro Systems) or ERWIN (Computer Associates) to help you with such tasks as affinity analysis (the grouping of related items appropriate to a single table).

Summary for Certification Examination Know your data types. Be familiar with the built-in data types and know when to use each one. For example, it might be obvious to you when you should use varchar instead of float, but it might not be as obvious when you need to use smallmoney versus money. Designing databases considers trade-offs and balances. The certification examination poses questions requiring the best solution.

Summary for Certification Examination Know the basics of how to retrieve and format data into information. In conjunction with the SELECT statement, know the difference between CAST and CONVERT. Both can do most functions. CONVERT adds style formatting capabilities.