Data Types & File Size Calculations

Slides:



Advertisements
Similar presentations
Introduction to Computing Concepts Note Set 7. Overview Variables Data Types Basic Arithmetic Expressions ▫ Arithmetic.
Advertisements

10-Jun-15 Introduction to Primitives. 2 Overview Today we will discuss: The eight primitive types, especially int and double Declaring the types of variables.
Computer Science 1620 C++ - Basics. #include using namespace std; int main() { return 0; } A very basic C++ Program. When writing your first programs,
Databases. Objectives Define what a database is. Understand the difference between a flat and relational database Design and create a relational database.
1 Lecture 5 Floating Point Numbers ITEC 1000 “Introduction to Information Technology”
National Diploma Unit 4 Introduction to Software Development Data types, variables and constants.
Java Data Types. Primitive Data Types Java has 8 primitive data types: – char: used to store a single character eg. G – boolean: used to store true or.
19/10/20151 Data Structures Arrays. 219/10/2015 Learning Objectives Explain initialising arrays and reading data into arrays. Design and write routine/s.
Databases The Kingsway School. Database Systems Databases are programs which store information in a logical way. Databases have a structure which helps.
Presented By: Gail Rose-Innes Camps Bay High School ICT & CAT Department Microsoft Access 2010.
Relational Databases. Relational database  data stored in tables  must put data into the correct tables  define relationship between tables  primary.
Data types  CHAR (size): This data type is used to store character strings values of fixed length. The size in brackets determines the number of characters.
Computing and Information Science 1 Databases START.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Data Tonga Institute of Higher Education. Variables Programs need to remember values.  Example: A program that keeps track of sales needs to remember.
Mr C Johnston ICT Teacher
Variables and Strings. Variables  When we are writing programs, we will frequently have to remember a value for later use  We will want to give this.
05/02/ Records. 205/02/2016 Learning Objectives State: The difference between records and arrays. The difference between records and arrays. How.
09/06/ Data Representation ASCII, Binary Denary Conversion, Integer & Boolean data types.
Chapter 9: Data types and data structures OCR Computing for A Level © Hodder Education 2009.
Data Types Mr Tottman Link. Data Types Programs need to use data for calculations and for output to various devices The best programs will always use.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
2b. Create an Access Database Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis with Spreadsheets 1.
BTEC NCF IT Unit 02 Creating Systems to Manage Information Lesson 05 – Data Types Mr C Johnston.
Floating Point Numbers
Chapter 3 Data Representation
Choosing Data Types Database Administration Fundamentals
DATA TYPES.
Creating Database Objects
DATABASE.
IGCSE 4 Cambridge Designing a database table Computer Science
Week 2 - Wednesday CS 121.
Creating a database table
Data Types and Structures
Databases Chapter 9 Asfia Rahman.
GO! with Microsoft Office 2016
CHP - 9 File Structures.
Programming constructs
Practical Office 2007 Chapter 10
Data Representation Binary Numbers Binary Addition
Chapter 6: Data Types Lectures # 10.
LEARNING OBJECTIVES O(1), O(N) and O(LogN) access times. Hashing:
Unit 16 – Database Systems
Types of data This presentation differentiates between ICT professional and end users.
GO! with Microsoft Access 2016
Understand Computer Storage and Data Types
3 - STORAGE: DATA CAPACITY CALCULATIONS
BTEC NCF IT Unit 02 Creating Systems to Manage Information Lesson 05 – Data Types Mr C Johnston.
Creating a table in Access
IDENTIFIERS CSC 111.
Data Types.
Computer Science 210 Computer Organization
Databases Software This icon indicates the slide contains activities created in Flash. These activities are not editable. For more detailed instructions,
C++ Data Types Data Type
Variables Title slide variables.
Unit 1.3 Storage Lesson 2: Storing Data
Data Types and Variables Part A – Introduction Numeric Data Types
Database Theory.
Random Access Files / Direct Access Files
VB Variables and Data
Spreadsheets, Modelling & Databases
B065: PROGRAMMING Variables 1.
Introduction to Primitives
Introduction to Primitives
Databases This topic looks at the basic concept of a database, the key features and benefits of a Database Management System (DBMS) and the basic theory.
Creating Database Objects
8 Records 25/07/2019.
Variables and Constants
Planning a Database © EIT, Author Gay Robertson, 2019.
Presentation transcript:

Data Types & File Size Calculations Data Structures Data Types & File Size Calculations 09/12/2018

Learning Objectives Explain concepts of files, records, fields. Explain the function of key fields. Calculate an estimated file size given the number of records. 09/12/2018

Data Data stored in computers is normally connected in some way. For example, some data about 20 students has a connection because it all refers to the same set of people. Each person will have the same information stored about them, for instance their name, address, telephone number, exam grades… 09/12/2018

Fields & Records Each column is a field. Each row is a record. 45278 Account Number Surname Forename Balance 45278 Smith Sally €10.00 1208 Jones John €20.00 3217 Cain Shazad €100.00 4310 White Peter €250.00 09/12/2018

Key Field Some fields may contain the same items of data in more than one record. e.g. there may be two people with the same name or balance. It is important that the computer can identify individual records, and it can only do this if it can be sure that one of the fields will always contain different data in all the records. The key field is unique and is used to identify the record. In our example the key field would be the account number. 09/12/2018

Range / Fractional Real Precision Storage Requirements (bytes) Data Types Main Data Types Data Types Range / Fractional Real Precision Storage Requirements (bytes) Text (Characters) / String in VB Any characters 1 per character Char Any character 1 byte Integer (Numeric, Whole numbers, no fractions) Byte 0 - 255 1 Integer In Access stored by 2 bytes so +/- 32,768. In VB stored by 4 bytes so approx. +/- 2 billion 2 - 4 Long (Integer) In Access stored by 4 bytes so approx. +/- 2 billion. In VB stored by 8 bytes so approx. +/– 9.2...E+18. 4 – 8 Floating Point (Fractional Real Numbers) Single 7 4 Double 15 8 Decimal 28 12 Boolean (Y/N True/False) Often 1 byte is reserved Date/Time

Summary of Data Types Storage Requirements Storage Requirements (bytes) Text 1 byte per character Char 1 byte Byte 0 – 255 Integer > 255 4 bytes Decimal 8 bytes Boolean (True/False – Yes/No – 2 answers only) Date / Time 09/12/2018 Note: Use this summary in exam questions. The previous slide is for general interest only.

All numbers/dates etc.. take up the same memory space It does not matter how big or small a number is, it will always take up the specified number of bytes. e.g. A variable declared as Byte: Numbers 0, 1, 2 or 255 will take ALL up 1 byte each. The size of the number does not matter. e.g. A variable declared as Integer: Numbers 0, 1, 2 or 100000 will ALL take up 4 bytes each. Also note that you cannot pick and choose, e.g. a small number cannot be held as a byte and a big number held as an integer. The data type has to be chosen at the point of declaration and is chosen depending on how big the number might be, not what it actually is at any one time. e.g. A variable declared as a decimal. Numbers 3.1, 3.141, 1000.453278 will ALL take up 8 bytes each. The size of the number or length of the decimal part does not matter.

Text Fields must be “Fixed Lengths” As text fields are 1 byte per character they are different lengths which makes it impossible to estimate their size. So we must fix them to an appropriate maximum length. I suggest you do this in 10’s: e.g. 10 / 20 / 30 / 40 / 50 / … / 100 / … Exams won’t require you do this but my quizzes will and it is more sensible anyway. For example, the length of someone’s name should be fixed at 10 (or 20) characters long so, as each character is 1 byte, its size would be 10 bytes (or 20 bytes). 30 characters or more is too long and would be considered incorrect in an exam (and my quizzes). Note that this means all names are this size, irrespective of its real length ; names are not 10 characters long would have spaces added to the end and names which are longer than this would be cut short.

1. A library stores details of the books that are available. Apart from title and author, state 3 other fields that it would be sensible for the library to store in this file, giving a reason why each of your chosen fields would be necessary. (6) One mark for each of three sensible fields with an extra mark for an explanation of the need for that field. e.g. ISBN/to identify book Shelf number/ to allow for ease of search for book Fiction or reference or children's (some form of category)/ to decide whereabouts in library it should go 09/12/2018

A library stores details of the books that are available. State which field would be used as the key field of the record and explain why a key field is necessary. (2) Book number (ISBN) because it is unique to that record and hence can be used as an identifier. Name a suitable data type for this field. String / Integer Why? 09/12/2018

Whether or not an order is outstanding. 2. A stock file in a warehouse has the following fields in each record. (i) State data types suitable for each of the fields. Name of item. Date of last delivery. Price of item. Whether or not an order is outstanding. Number of that item left in stock. Text / String Date Currency / Decimal Boolean Integer 09/12/2018

Whether or not an order is outstanding. (ii) Given that there are approximately 10000 different items in the warehouse, estimate the size of the stock file. You should clearly show all the stages in the calculation. Name of item. Date of last delivery. Price of item. Whether or not an order is outstanding. Number of that item left in stock. 10 bytes 8 bytes 1 bytes 4 bytes 09/12/2018

(ii) Given that there are approximately 10000 different items in the warehouse, estimate the size of the stock file. You should clearly show all the stages in the calculation. 10 + 8 + 8 + 1 + 1 = Name of item Last delivery date Price of item Outstanding? Number in stock 31 bytes 31 * 10000 = 310000 bytes 10000 items = 10000 rows

(ii) Calculation Total 31 bytes 31 x 10000 = 310000 bytes Overhead: 10% of 310000 = 310000 * 0.1 = 310000 + 31000 = 341000 341000 / 1024 ~ 341 Kbytes Notes: You must write /1024 because computers do not work in base 10 as we do, but in base 2 – see Data Representation Presentation later. However, exams allow you to actually /1000 to make the calculation easier, as long you write /1024, then approximate (~) and actually /1000. If you get answers in the millions you will need to convert it into Megabytes (Mb) which means /1048576 (~1000000 bytes or 1 million bytes). You could add 10% by directly * 1.1 (as long as you allowed to use a calculator which only happens in paper 2, not paper 1). 09/12/2018