Module 2: Creating Data Types and Tables

Slides:



Advertisements
Similar presentations
Creating Databases and E/R Diagrams with SQL Server Management Studio Svetlin Nakov Telerik Corporation
Advertisements

Project Management Database and SQL Server Katmai New Features Qingsong Yao
Module 4: Creating Data Types and Tables. Overview Creating Data Types Creating Tables Generating Column Values Generating Scripts.
Creating Tables, Defining Constraints Rose-Hulman Institute of Technology Curt Clifton.
1 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management.
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
Copyright ©2014 Pearson Education, Inc. Chapter 6 Physical Design Chapter6.1.
Database Fundamentals
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.
Module 4: Data Objects. Overview Tables are the main objects that store data Indexes, views, stored programs and other objects are the support structures.
Irwin/McGraw-Hill Copyright © 2000 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS5th Edition.
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
1 All Powder Board and Ski SQL Server Workbook Chapter 2: Database Design Jerry Post Copyright © 2004.
Module 3 Designing a Physical Database Model. Module Overview Selecting Data Types Designing Database Tables Designing Data Integrity.
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.
Application Data and Database Activities Auditing Dr. Gabriel.
MySQL More… 1. More on SQL In MySQL, the Information Schema is the “Catalog” in the SQL standard SQL has three components: Data definition Data manipulation.
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.
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.
Data Modeling Creating E/R Diagrams SoftUni Team Technical Trainers Software University
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.
Ch 3. Working with Tables and Views. Data type Specify type of data to be entered into a column (text, number, datetime, etc) Unicode (National) Datatypes.
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:
Advanced SQL - DDL Advanced Database Dr. AlaaEddin Almabhouh.
Standards and Conventions
14 New T-SQL Functions By Sam Nasr, MCAD, MCT, MCTS NIS
Querying with Transact-SQL
Creating Database Objects
Databases and SQL Designing a database with tables and primary keys
Managing Tables, Data Integrity, Constraints by Adrienne Watt
Database Management System
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
Working with SQL Server 2016 Data Types
14 T-SQL Functions You May Not Know
Module 5: Implementing Data Integrity by Using Constraints
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
Introduction to partitioning
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
Creating Database Objects
Working with SQL Server 2016 Data Types
Presentation transcript:

Module 2: Creating Data Types and Tables

Overview Creating Data Types Creating Tables Creating Partitioned Tables

Lesson 1: Creating Data Types What Are System-Supplied Data Types? Using System-Supplied Data Types What Are Alias Data Types? Practice: Creating Data Types

What Are System-Supplied Data Types? Category Data types Numeric Integer int, bigint, smallint, tinyint Exact decimal, numeric Approximate float, real Monetary money, smallmoney Date and time datetime, smalldatetime Character Non-Unicode char, varchar, varchar(max), text Unicode nchar, nvarchar, nvarchar(max), ntext Binary binary, varbinary, varbinary(max) Image image Global identifier uniqueidentifier XML xml Special bit, cursor, timestamp, sysname, table, sql_variant

Using System-Supplied Data Types Exact and approximate numeric data types Exact – decimal, numeric Approximate – float, real Character data types Fixed – nchar Variable – nvarchar Date and time data Dates and times – datetime, smalldatetime Row version – timestamp Large data values Large object type – text, image max specifier – varchar(max), nvarchar(max), varbinary(max)

What Are Alias Data Types? Based on system-supplied types Used for common data elements with a specific format Created by using the CREATE TYPE statement CREATE TYPE dbo.StateCode FROM char(2) NULL

Practice: Creating Data Types In this practice, you will: Create a data type by using SQL Server Management Studio Create a data type by using Transact-SQL

Lesson 2: Creating Tables How SQL Server Organizes Data in Rows How SQL Server Organizes Large Data Values Considerations for Creating Tables Generating Transact-SQL Scripts Practice: Creating Tables

How SQL Server Organizes Data in Rows Header Fixed Data NB VB Variable Data 4 Bytes Null Block Variable Block 2 Bytes 10111001 … 2 Bytes 2 Bytes … Number of columns More column bits as required Number of variable-length columns Additional pointer per variable column Nullability bit per column (first 8 columns) Pointer to end of first variable column data

How SQL Server Organizes Large Data Values Large value types out of row option ON Data row nvarchar(max) [ < 8K] nvarchar(max) [ > 8K] Large value types out of row option OFF nvarchar(max) [ < 8K] nvarchar(max) [ > 8K] Data row

Considerations for Creating Tables Column collation Column nullability Special column types Computed columns Identity columns timestamp columns uniqueidentifier columns CREATE TABLE Sales.CustomerOrders (OrderID int IDENTITY NOT NULL, OrderDate datetime NOT NULL, CustomerID int NOT NULL, Notes nvarchar(200) NULL)

Generating Transact-SQL Scripts Object Explorer Connect to a SQL Server Database Engine instance Expand Object Explorer and locate the object Right-click and then click Script <object type> as 1 2 3 Generate Scripts Wizard Right-click a database, point to Tasks, and then click Generate Scripts Follow the steps in the wizard 1 2

Practice: Creating Tables In this practice, you will: Create a table by using SQL Server Management Studio Create a table by using Transact-SQL Generate a Transact-SQL script

Lesson 3: Creating Partitioned Tables What Are Partitioned Tables? What Are Partition Functions? What Is a Partition Scheme? Demonstration: Creating a Partitioned Table What Operations Can Be Performed on Partitioned Data?

What Are Partitioned Tables? Data is partitioned horizontally by range < 2003 2003 -- 2004 2004 -- 2005 > 2005 Sales.Orders

What Are Partition Functions? Partition functions define partition boundaries Boundary values can be assigned to LEFT or RIGHT < 2003 2003 -- 2004 2004 -- 2005 > 2005 CREATE PARTITION FUNCTION pf_OrderDate (datetime) AS RANGE RIGHT FOR VALUES ('01/01/2003', '01/01/2004', 01/01/2005')

What Is a Partition Scheme? A partition scheme assigns partitions to filegroups The “next” filegroup can also be defined < 2003 2003 -- 2004 2004 -- 2005 > 2005 CREATE PARTITION SCHEME ps_OrderDate AS PARTITION pf_OrderDate TO (fg1, fg2, fg3, fg4, fg5)

Demonstration: Creating a Partitioned Table In this demonstration, you will see how to: Create a partition function Create a partition scheme Create a partitioned table View partitioned table behavior

What Operations Can Be Performed on Partitioned Data? SWITCH: Swap a populated table or partition with an empty table or partition MERGE: Combine two adjacent partitions into a single partition SPLIT: Insert a boundary in an existing partition to create a new partition SWITCH SPLIT < 2003 2003 -- 2004 2004 -- 2005 2005 -- 2006 > 2006 MERGE

Lab: Creating Data Types and Tables Exercise 1: Creating Data Types Exercise 2: Creating Tables Exercise 3: Creating Partitioned Tables