Table Creation / Data Types. A Data type is... Specifies what kind of information a column will hold so that the system will know how the data is to be.

Slides:



Advertisements
Similar presentations
CIT 613: Relational Database Development using SQL Revision of Tables and Data Types.
Advertisements

Session 2Introduction to Database Technology Data Types and Table Creation.
PL/SQL.
Structured Query Language - SQL Carol Wolf Computer Science.
Sanjay Goel, School of Business, University at Albany, SUNY 1 SQL- Data Definition Language ITM 692 Sanjay Goel.
Beginning SQL Tutorial Author Jay Mussan-Levy. What is SQL?  Structured Query Language  Communicate with databases  Used to created and edit databases.
Representing Data Elements Gayatri Gopalakrishnan.
1 Arrays  Arrays are objects that help us organize large amounts of information  Chapter 8 focuses on: array declaration and use passing arrays and array.
Creating a Blank Database 1. Open up Microsoft Access 2. Click on Blank document button 3. On the right panel, Specify the location for saving your database.
Database Modifications A modification command does not return a result as a query does, but it changes the database in some way. There are three kinds.
DT211 Stage 2 Databases Lab 1. Get to know SQL Server SQL server has 2 parts: –A client, running on your machine, in the lab. You access the database.
Chapter 9: Arrays and Strings
30-Jun-15 SQL A Brief Introduction. SQL SQL is Structured Query Language Some people pronounce SQL as “sequel” Other people insist that only “ess-cue-ell”
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
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,
Oracle Data Definition Language (DDL)
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
Relational DBs and SQL Designing Your Web Database (Ch. 8) → Creating and Working with a MySQL Database (Ch. 9, 10) 1.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Database Design lecture 3_1 1 Database Design Lecture 3_1 Data definition in SQL.
2440: 141 Web Site Administration Database Management Using SQL Professor: Enoch E. Damson.
Chapter 4 Introduction to MySQL. MySQL “the world’s most popular open-source database application” “commonly used with PHP”
Oracle Data Definition Language (DDL) Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
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 (DDL & DML Commands)
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
1 Creating and Modifying Database Objects. 2 An Oracle database consists of multiple user accounts Each user account owns database objects Tables Views.
Chapter 10: The Data Tier We discuss back-end data storage for Web applications, relational data, and using the MySQL database server for back-end storage.
LECTURE 1 INTRODUCTION TO PL/SQL Tasneem Ghnaimat.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
Guide to Oracle 10g ITBIS373 Database Development Lecture 4a - Chapter 4: Using SQL Queries to Insert, Update, Delete, and View Data.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
CREATE TABLE CREATE TABLE statement is used for creating relations Each column is described with three parts: column name, data type, and optional constraints.
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.
Conversion Functions.
Chapter 3 – Variables and Arithmetic Operations. Variable Rules u Must declare all variable names –List name and type u Keep length to 31 characters –Older.
SQL CREATING AND MANAGING TABLES lecture4 1. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns ViewLogically.
Sql DDL queries CS 260 Database Systems.
©Silberschatz, Korth and Sudarshan1 Structured Query Language (SQL) Data Definition Language Domains Integrity Constraints.
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
Pointers in C++. Topics Covered  Introduction to Pointers  Pointers and arrays  Character Pointers, Arrays and Strings  Examples.
Academic Year 2015 Autumn. MODULE CC2006NI: Data Modelling and Database Systems Academic Year 2015 Autumn.
Arrays Declaring arrays Passing arrays to functions Searching arrays with linear search Sorting arrays with insertion sort Multidimensional arrays Programming.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
MySQL Tutorial. Databases A database is a container that groups together a series of tables within a single structure Each database can contain 1 or more.
Oracle 10g Retrieving Data Using the SQL SELECT Statement.
COM621: Advanced Interactive Web Development Lecture 11 MySQL – Data Manipulation Language.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Creating Database Objects
Introduction To Oracle
Chapter 5 Introduction to SQL.
Managing Tables, Data Integrity, Constraints by Adrienne Watt
BASIC ELEMENTS OF A COMPUTER PROGRAM
Computer Programming BCT 1113
MySQL - Creating donorof database offline
Oracle Data Definition Language (DDL)
MSIS 655 Advanced Business Applications Programming
Indexes and more Table Creation
The University of Akron College of Applied Science & Technology Dept
Structured Query Language Path from Unorganized to Organized….
Creating Database Objects
SQL (Structured Query Language)
Presentation transcript:

Table Creation / Data Types

A Data type is... Specifies what kind of information a column will hold so that the system will know how the data is to be physically stored and manipulated. Example: an integer data type can only hold whole numbers and can be manipulated arithmetically.

Different Datatypes

Defining Data type Length Defining the length of a data type allocates storage space for that specified data. Using a fixed length data typed allocates the same amount of space regardless of the actual data length. Variable length datatypes can adjust to the length of the data as long as the maximum is not exceeded.

What does this mean? If we define the following fixed datatype: char(10) 10 bytes of storage space is allocated regardless of the actual data length. If we redefine as a variable datatype: varchar(10) the data length can not exceed 10 bytes but the actual storage space will only be as long as the data stored.

Implications? Data type allocation: Dataactualchar(10)varchar(10) bluhens7 b10 b7 b basketball10 b americaeast11 b10 b champs6 b10 b6 b total34 b40 b33 b

Conclusions Choose your datatypes and lengths carefully. Choosing a fixed length can yield higher performance since the system need not maintain allocation. However, if you know your data will not have a consistent length then a variable length is best as this will conserve space.

Nulls are... Nulls represent data that is absent and/or unavailable. Nulls are not blank or zero Assigning null status to a column tells the system to insert a null value if there is no data available Assigning a ‘not null’ status means that the system will reject any entries that do not provide data for this column. An error is usually generated.

To Be Null or Not to Be Null? Is the data essential? Is the column a primary key? Would things make sense if the data was not present? Do other things rely on this data?

4 Steps to Table Creation Name it What is the entity? Name the columns it contains What are the properties of this entity and which am I interested in? Specify the datatype of each column What kind of data do these properties represent? Specify the NULL status of each column

Table Creation Syntax SQL statement CREATE TABLE tablename (colnamedatatype(length) null/not null, …. ….)

Example create table titles (title_id char(6)not null, titlevarchar(80)not null, typechar(12)null)

Table Creation Process Decide on datatype (length, precision, etc.) of each column Decide which columns should be null Decide which columns need to be unique Note foreign/primary key pairings Make sure permissions are properly assigned

Charting table structure

Query Construction Spelling is and always will be important Strings must be enclosed in single quotes ex. ‘Jane Doe’ Numeric data should not All search conditions must be separated by AND or OR depending on the desired condition

Testing Equality For numeric data >, <, =, != For string data =, != Wildcard comparison for strings LIKE or NOT LIKE %- zero or more character _- one use to escape a wildcard