Database systems Lecture 2 – Data Types

Slides:



Advertisements
Similar presentations
VTYS 2012 Mehmet Emin KORKUSUZ Ders  Create  Alter  Drop Data Defination Language.
Advertisements

Database Chapters.
Pertemuan ke 2 Tipe data & ERD Kurniawan Eka Permana.
Day 3 - Basics of MySQL What is MySQL What is MySQL How to make basic tables How to make basic tables Simple MySQL commands. Simple MySQL commands.
MySQL-Database Teppo Räisänen Oulu University of Applied Sciences School of Business and Information Management.
SLIDE 1IS 257 – Fall 2010 Physical Database Design and Referential Integrity University of California, Berkeley School of Information IS 257:
Representing Data Elements Gayatri Gopalakrishnan.
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
DATABASES AND SQL. Introduction Relation: Relation means table(data is arranged in rows and columns) Domain : A domain is a pool of values appearing in.
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.
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.
CHAPTER 8 Database: SQL, MySQL. Topics  Introduction  Relational Database Model  Relational Database Overview: Books.mdb Database  SQL (Structured.
Chapter 4 Introduction to MySQL. MySQL “the world’s most popular open-source database application” “commonly used with PHP”
Introduction to MySQL Lab no. 10 Advance Database Management System.
CSC 2720 Building Web Applications Database and SQL.
SQL Data Definition Language (DDL) Using Microsoft SQL Server 1SDL Data Definition Language (DDL)
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.
Advanced Web 2012 Lecture 3 Sean Costain What is a Database? Sean Costain 2012 A database is a structured way of dealing with structured information.
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.
Visual Programing SQL Overview Section 1.
Fox MIS Spring 2011 Database Week 6 ERD and SQL Exercise.
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.
Introduction to MySQL Lab no. 9 Advance Database Management System.
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
1 CS 430 Database Theory Winter 2005 Lecture 11: SQL DDL.
Class 3Intro to Databases Class 4 Simple Example of a Database We’re going to build a simple example of a database, which will allow us to register users.
Relational Databases and MySQL. Relational Databases Relational databases model data by storing rows and columns in tables. The power of the relational.
LECTURE FOUR Introduction to SQL DDL with tables DML with tables.
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:
Lecture 1.21 SQL Introduction Steven Jones, Genome Sciences Centre.
Data Model / Database Implementation Jeffery S. Horsburgh Hydroinformatics Fall 2015 This work was funded by National Science Foundation Grants EPS
Creating Database Objects
Relational Algebra and Calculus: Introduction to SQL
Managing Tables, Data Integrity, Constraints by Adrienne Watt
Data Definition and Data Types
MySQL-Database Jouni Juntunen Oulu University of Applied Sciences
Module 2: Creating Data Types and Tables
CIS 136 Building Mobile Apps
Lecture 6 Data Model Design (continued)
Data Definition and Data Types
Attributes and Domains
Ouch! Our Data Type Choices Did THAT?
SQL Server 2016 JSON Support FOR Data Warehousing
SQL Implementation & Administration
Data Resources Management
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
CIS 136 Building Mobile Apps
CIS16 Application Programming with Visual Basic
CS122 Using Relational Databases and SQL
Attributes and Domains
CS1222 Using Relational Databases and SQL
Data Definition Language
Data Definition Language
Chapter 4 Introduction to MySQL.
Data.
MySQL Database System Installation Overview SQL summary
Kirkwood Center for Continuing Education
Creating Database Objects
CS122 Using Relational Databases and SQL
Database Instructor: Bei Kang.
Presentation transcript:

Database systems Lecture 2 – Data Types Roman Danel 2016

Data types Numeric String Date and Time Others (binary, spatial, XML…)

Numeric data types Integer Real (with decimal point) Decimal, Numeric Float - floating point

Numeric in MySQL (Integer) Tinyint −128 až 127 nebo 0 až 255 pro UNSIGNED, 1 byte Smallint −32768 to 32767 or 0 to 65535 for UNSIGNED, 2 bytes MediumInt −8388608 to 8388607 or 0 to 16777215 for UNSIGNED, 3 bytes Int −2147483648 to2147483647 or 0 to 4294967295 for UNSIGNED, 4 bytes Bigint −9223372036854775808 to 9223372036854 or 0 to 18446744073709551615 pro UNSIGNED, 8 bytes

Numeric Data Types in MySQL Float(p) Float(M,D) Double(M,D) Decimal(M,D) - large numbers in floating point stored as a string (1 byte per numeral)

Numeric – Microsoft SQL Server Data Type Range Memmory Allocation bigint -263 až 263 8 bytes int -231 až 231 4 bytes smallint -215 až 215 2 bytes tinyint 0 až 255 1 byte Data Type Precision Memmory Allocation decimal 1-9 5 bytes 10-19 9 bytes 20-28 13 bytes 29-38 17 bytes

Numeric – Microsoft SQL Server Data type Range Memory Allocation money -922,337,203,6­85,477.58 to 922,337,203,6­85,477.58 8 bytes smallmoney - 214,748.3648 to 214,748.3647 4 bytes

Numeric – Microsoft SQL Server Data type Range Memory Allocation float(n) 1-24 4 bajty 25-53 9 bajtů

Numeric Numeric(5,2) = 99.99

String Data Types - MySQL Char(m), m=0-255, longer will be „lost“ Varchar(m), m=0-255 Tinyblob - 0 to 255 Bytes Blob - 0 to 65535 Bytes Mediumblob, Longblob TinyText -  0 až 255 bajtů Text, MediumText, LongText Enum - enumeration values; the values in the column can be assigned just one value from a list of values

Date Data Types DATE TIME DATETIME SMALLDATETIME

Date – Microsoft SQL Server Data type Range Memory Allocation date 0001-01-01 to 9999-12-31 3 bytes Time 00:00:00.000 to 23:59:59.999 5 bytes Datetime Rozsah pro datum 01.01.1753 až 31.12.9999 Rozsah pro čas 00:00:00 až 23:59:59.997 8 bytes Datetime2(n) Range for Date 01.01.0001 to 31.12.9999 Range for time 00:00:00 to 23:59:59.9999999 According precission from 6 to 8 bytes Datetimeoffset Range for Date 01.01.0001 to 31.12.9999 Range for time00:00:00 to 23:59:59.9999999 Time zone-14:00 až +14:00 10 bytes Smalldatetime Range for Date 01.01.1900 to 06.06.2079 Range for time 00:00:00 to 23:59:00 4 bytes

Others Data Types – MS SQL Bit – 1/0, memmory allocation - 1 bit Timestamp – It is a data type that generates unique binary number, which is used for version resolution lines "rowversion". This data type does not store date and time! To store the date and time should be used datetime2. In memory occupies 8 bytes. Uniqueidentifier – It is a data type that, for example, in conjunction with the function NEWID () generates a unique identifier. In memory it takes up 16 bytes.

Value NULL Value, which is not intended Property of the column: NULL/NOT NULL Example in SELECT: SELECT * from table where column_name IS NULL;

Primary Key Primary Key – defined over one or more columns of the table. The main purpose of a primary key is ensure the uniqueness of records in a table. Primary key values can not contain duplicate or null.

Automatically generated number MySQL – AUTO_INCREMENT MS SQL – IDENTITY Oracle – sequence Access – Automatic Number create table Table_name ( column_name int IDENTITY(1,1) primary key,

Default Value Apply if during operation insert the value is not determined If we want to avoid NULL values

Column Properties UNIQUE NULL/NOT NULL PRIMARY KEY DEFAULT

Converting Data Types CONVERT CAST CAST ( $157.27 AS VARCHAR(10) ) Syntax for CAST: CAST ( expression AS data_type [ (length ) ]) Syntax for CONVERT: CONVERT ( data_type [ ( length ) ] , expression [ , style ] )