SlideShare a Scribd company logo
2018 02 20_biological_databases_part2_v_upload
FBW
27-02-2018
Biological Databases
Wim Van Criekinge
2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload
Syllabi left
Project
Big Data Volumes
2018 02 20_biological_databases_part2_v_upload
Data Levels in Biological Research
Primary dataDerived data
Primary dataDerived data
Interpreted data/
knowledge
Experimental metadata
Analytical metadata
Direct Queryability of Selected Bioinformatics Databases
Database Direct Querying? How? Modality DB Engine
ArrayExpressWarehouse Eventually http://www.ebi.ac.uk/aedw/ SQL Oracle
BioWarehouse Yes
http://biowarehouse.ai.sri.com/
- need account
SQL Oracle/MySQL
Ensembl Yes
http://www.ensembl.org/info/d
ata/download.html
SQL MySQL
Mouse Genome Database Yes ask for account SQL Sybase
PharmGKB Yes
http://www.pharmgkb.org/hom
e/projects/webservices/
SOAP-based Oracle
Saccharomyces Genome
Database
EventuallyMaybe Oracle
Stanford Microarray Database No Oracle
Example 3-tier model in biological database
Rationale to study SQL
• Learning SQL to Query Biological Databases
• Are you getting too much data, or missing crucial
data when querying via a Web interface? Many
biological databases can be queried directly via
SQL, thus bypassing the limitations of the
database's interface. SQL is at the heart of
biological databases as diverse as Ensembl,
ArrayExpress and the Mouse Genome Database.
• Focus on understanding relational databases by
studying a repository of biological data and learn
how to query it using SQL.
SQL consists of only 4 statements, sometimes
referred to as CRUD:
–Create - INSERT - to store new data
–Read - SELECT - to retrieve data
–Update - UPDATE - to change or modify
data.
–Delete - DELETE - delete or remove data
Structured Query Language
Definitions
Definitions
• Database: Collection of tables 
• Table
– Collection of records that share a common
fundamental characteristic
• E.g., patients and locations can each be stored in
their own table
• Record
– Basic unit of information in a relation
information
– A record is composed of fields
– E.g., 1 record per person
• Query
– Set of instructions to a database “engine” to
retrieve, sort and format returning data.
• “find me all patients in my database”
Table Characteristics
• Two-dimensional structure with rows and
columns
• Rows (tuples) represent single entity
• Columns represent attributes
• Row/column intersection represents single value
• Tables must have an attribute to uniquely identify
each row
• Column values all have same data format
• Each column has range of values called attribute
domain
• Order of the rows and columns is immaterial to
the DBMS
Numeric Data Types
MySQL uses all the standard ANSI SQL numeric data types, so if you're coming to MySQL from a different
database system, these definitions will look familiar to you. The following list shows the common numeric data
types and their descriptions:
INT - A normal-sized integer that can be signed or unsigned. If signed, the allowable range is from -2147483648 to
2147483647. If unsigned, the allowable range is from 0 to 4294967295. You can specify a width of up to 11 digits.
TINYINT - A very small integer that can be signed or unsigned. If signed, the allowable range is from -128 to 127.
If unsigned, the allowable range is from 0 to 255. You can specify a width of up to 4 digits.
SMALLINT - A small integer that can be signed or unsigned. If signed, the allowable range is from -32768 to
32767. If unsigned, the allowable range is from 0 to 65535. You can specify a width of up to 5 digits.
MEDIUMINT - A medium-sized integer that can be signed or unsigned. If signed, the allowable range is from -
8388608 to 8388607. If unsigned, the allowable range is from 0 to 16777215. You can specify a width of up to 9
digits.
BIGINT - A large integer that can be signed or unsigned. If signed, the allowable range is from -
9223372036854775808 to 9223372036854775807. If unsigned, the allowable range is from 0 to
18446744073709551615. You can specify a width of up to 20 digits.
FLOAT(M,D) - A floating-point number that cannot be unsigned. You can define the display length (M) and the
number of decimals (D). This is not required and will default to 10,2, where 2 is the number of decimals and 10 is
the total number of digits (including decimals). Decimal precision can go to 24 places for a FLOAT.
DOUBLE(M,D) - A double precision floating-point number that cannot be unsigned. You can define the display
length (M) and the number of decimals (D). This is not required and will default to 16,4, where 4 is the number of
decimals. Decimal precision can go to 53 places for a DOUBLE. REAL is a synonym for DOUBLE.
DECIMAL(M,D) - An unpacked floating-point number that cannot be unsigned. In unpacked decimals, each
decimal corresponds to one byte. Defining the display length (M) and the number of decimals (D) is required.
NUMERIC is a synonym for DECIMAL.
String Data Type
• Although numeric and date types are fun, most data you'll store will be in string format. This list describes
the common string datatypes in MySQL.
• CHAR(M) - A fixed-length string between 1 and 255 characters in length (for example CHAR(5)), right-
padded with spaces to the specified length when stored. Defining a length is not required, but the default
is 1.
• VARCHAR(M) - A variable-length string between 1 and 255 characters in length; for example
VARCHAR(25). You must define a length when creating a VARCHAR field.
• BLOB or TEXT - A field with a maximum length of 65535 characters. BLOBs are "Binary Large Objects"
and are used to store large amounts of binary data, such as images or other types of files. Fields defined
as TEXT also hold large amounts of data; the difference between the two is that sorts and comparisons
on stored data are case sensitive on BLOBs and are not case sensitive in TEXT fields. You do not specify
a length with BLOB or TEXT.
• TINYBLOB or TINYTEXT - A BLOB or TEXT column with a maximum length of 255 characters. You do
not specify a length with TINYBLOB or TINYTEXT.
• MEDIUMBLOB or MEDIUMTEXT - A BLOB or TEXT column with a maximum length of 16777215
characters. You do not specify a length with MEDIUMBLOB or MEDIUMTEXT.
• LONGBLOB or LONGTEXT - A BLOB or TEXT column with a maximum length of 4294967295
characters. You do not specify a length with LONGBLOB or LONGTEXT.
• ENUM - An enumeration, which is a fancy term for list. When defining an ENUM, you are creating a list of
items from which the value must be selected (or it can be NULL). For example, if you wanted your field to
contain "A" or "B" or "C", you would define your ENUM as ENUM ('A', 'B', 'C') and only those values (or
NULL) could ever populate that field.
Built-in Data Types in SQL
• date: Dates, containing a (4 digit) year, month and
date
– Example: date ‘2005-7-27’
• time: Time of day, in hours, minutes and seconds.
– Example: time ‘09:00:30’ time ‘09:00:30.75’
• timestamp: date plus time of day
– Example: timestamp ‘2005-7-27 09:00:30.75’
• interval: period of time
– Example: interval ‘1’ day
– Subtracting a date/time/timestamp value from another gives
an interval value
– Interval values can be added to date/time/timestamp values
Build-in Data Types in SQL (Cont.)
• Can extract values of individual fields from
date/time/timestamp
– Example: extract (year from r.starttime)
• Can cast string types to
date/time/timestamp
– Example: cast <string-valued-expression>
as date
– Example: cast <string-valued-expression>
as time
User-Defined Types
• create type construct in SQL creates user-defined
type
create type Dollars as numeric (12,2) final
• create domain construct in SQL-92 creates user-
defined domain types
create domain person_name char(20) not null
• Types and domains are similar. Domains can have
constraints, such as not null, specified on them.
Large-Object Types
• Large objects (photos, videos, CAD files, etc.)
are stored as a large object:
– blob: binary large object -- object is a large
collection of uninterpreted binary data (whose
interpretation is left to an application outside of
the database system)
– clob: character large object -- object is a large
collection of character data
– When a query returns a large object, a pointer is
returned rather than the large object itself.
Creating a Table
• To create a table, use the CREATE TABLE command:
mysql> CREATE TABLE pet (
-> name VARCHAR(20),
-> owner VARCHAR(20),
-> species VARCHAR(20),
-> sex CHAR(1),
-> birth DATE, death DATE);
Query OK, 0 rows affected (0.04 sec)
Keys
• One or more attributes that
determine other attributes
– Key attribute
– Composite key
• Full functional dependence
• Entity integrity
– Uniqueness
– No ‘null’ value in key
Example Tables
Simple Relational Database
Keys (con’t.)
• Primary key
– Candidate key to uniquely identify all other
attributes in a given row
• Foreign key
– Values must match primary key in another
table
Integrity Rules
• Entity integrity
– Ensures all entities are unique
– Each entity has unique key
• Referential integrity
– Foreign key must have null value or match
primary key values
– Makes it impossible to delete row whose
primary key has mandatory matching foreign
key values in another table
Integrity Constraints
• Integrity constraints guard against
accidental damage to the database, by
ensuring that authorized changes to the
database do not result in a loss of data
consistency.
– A checking account must have a balance
greater than $10,000.00
– A salary of a bank employee must be at
least $4.00 an hour
– A customer must have a (non-null) phone
number
Referential Integrity
• Ensures that a value that appears in one relation for a given set of
attributes also appears for a certain set of attributes in another
relation.
– Example: If “Perryridge” is a branch name appearing in one of the
tuples in the account relation, then there exists a tuple in the
branch relation for branch “Perryridge”.
• Primary and candidate keys and foreign keys can be specified as part
of the SQL create table statement:
– The primary key clause lists attributes that comprise the primary
key.
– The unique key clause lists attributes that comprise a candidate
key.
– The foreign key clause lists the attributes that comprise the
foreign key and the name of the relation referenced by the foreign
key. By default, a foreign key references the primary key attributes
of the referenced table.
2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload
Install BIOSQL locally
• Get latest version of mysql (MAMP,
mariaDB)
• Download biosqldb-mysql.sql
• Remove type=innodb
• Launch database server
• Connect using toad (port 8889)
• Create database biosql;
• Set as active database
• Use worksheet to execute biosqldb-
mysql.sql
Typical ODBC Architecture
How ODBC Works?
• ODBC inserts a middle layer called a Client
Driver
• Purpose of the Client Driver is to translate the
applications queries into commands that the
DBMS understands
Other Parts of the Architecture
• Application – calls functions defined in the
ODBC API to access a data source
• Driver Manager – implements the ODBC API
and provides information to the application
• Database – contains all the data
Setting Up a Data Source in Windows
• A data source is just a database that ODBC
connects to
• This allows the person to change database
types without any changes to the program
• Step 1. Get a database.
– Using access for this example because it’s on this
computer
Conclusion
The four parts that make up ODBC:
Conclusion
• Advantages:
– Allows access to different types of databases
– Uniform way of retrieving information
– Highly efficient
– Low memory requirements
• Disadvantages
– Complex and steep learning curve
– All data in database must look like a relational
database
Conclusion
• ODBC changed the way people code their programs
that have to interact with databases.
• The efficiency of programmers in the business world
has increased due to ODBC because they no longer
are wasting time to create multiple copies of a
program.
• ODBC has vastly improved the way programmers
deal with databases.
2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload
Application/utilities
Project

More Related Content

PPTX
2018 03 27_biological_databases_part4_v_upload
PPT
What to do when one size does not fit all?!
PPTX
PPTX
Introduction - Using Stata
PPTX
SPSS How to use Spss software
PDF
Creating a Coding Book in IBM SPSS Statistics
PPTX
اىفناىنمفبانفيا
2018 03 27_biological_databases_part4_v_upload
What to do when one size does not fit all?!
Introduction - Using Stata
SPSS How to use Spss software
Creating a Coding Book in IBM SPSS Statistics
اىفناىنمفبانفيا

What's hot (19)

PDF
Defining Data in IBM SPSS Statistics
PDF
SPSS introduction Presentation
PPTX
Introduction to spss 1
PDF
T-SQL Data Types (Quick Overview)
PDF
Spss training notes
PDF
PPT
Spss an introduction
DOC
Crosstab query techniques
PDF
Spss tutorial 1
PPTX
Spss
PPT
Spss data capturing training
PPTX
sorting and filtering data in excel
PPTX
Presentation on spss
PPTX
Elementary Data Analysis with MS Excel_Day-4
PPTX
Advanced Filter Concepts in MS-Excel
PPT
Spss beginners
PPTX
Data entry in Excel and SPSS
PPTX
Introduction
Defining Data in IBM SPSS Statistics
SPSS introduction Presentation
Introduction to spss 1
T-SQL Data Types (Quick Overview)
Spss training notes
Spss an introduction
Crosstab query techniques
Spss tutorial 1
Spss
Spss data capturing training
sorting and filtering data in excel
Presentation on spss
Elementary Data Analysis with MS Excel_Day-4
Advanced Filter Concepts in MS-Excel
Spss beginners
Data entry in Excel and SPSS
Introduction
Ad

Similar to 2018 02 20_biological_databases_part2_v_upload (20)

PPTX
2016 02 23_biological_databases_part2
PPTX
2017 biological databasespart2
PPTX
2019 02 21_biological_databases_part2_v_upload
PDF
UNIT 3 SQL 10.pdf ORACEL DATABASE QUERY OPTIMIZATION
PPTX
Session 2 - "MySQL Basics & Schema Design"
PPTX
unit 1_unit1_unit1_unit 1_unit1_unit1_ ppt.pptx
PPTX
unit 1_unit1_unit1_unit 1_unit1_unit1_ ppt.pptx
PPTX
PPTX
unit 1 ppt.pptx
PPTX
MSAvMySQL.pptx
PPTX
Structured Query Language (SQL) _ Edu4Sure Training.pptx
PPT
Mangala Deshpande MySQL0710.ppt
PPTX
SQL Commands Part 1.pptx
PPTX
Sql Basics And Advanced
DOCX
PDF
Simple Queriebhjjnhhbbbbnnnnjjs In SQL.pdf
PDF
NCTU ppt 2023-2024_WEEK3-DataTypes-Clauses-Operators.pdf
PPTX
DBMS Relational Data Model .pptx
PPTX
Unit 10 - Realtional Databases.pptxxxxxxxxx
2016 02 23_biological_databases_part2
2017 biological databasespart2
2019 02 21_biological_databases_part2_v_upload
UNIT 3 SQL 10.pdf ORACEL DATABASE QUERY OPTIMIZATION
Session 2 - "MySQL Basics & Schema Design"
unit 1_unit1_unit1_unit 1_unit1_unit1_ ppt.pptx
unit 1_unit1_unit1_unit 1_unit1_unit1_ ppt.pptx
unit 1 ppt.pptx
MSAvMySQL.pptx
Structured Query Language (SQL) _ Edu4Sure Training.pptx
Mangala Deshpande MySQL0710.ppt
SQL Commands Part 1.pptx
Sql Basics And Advanced
Simple Queriebhjjnhhbbbbnnnnjjs In SQL.pdf
NCTU ppt 2023-2024_WEEK3-DataTypes-Clauses-Operators.pdf
DBMS Relational Data Model .pptx
Unit 10 - Realtional Databases.pptxxxxxxxxx
Ad

More from Prof. Wim Van Criekinge (20)

PPTX
2020 02 11_biological_databases_part1
PPTX
2019 03 05_biological_databases_part5_v_upload
PPTX
2019 03 05_biological_databases_part4_v_upload
PPTX
2019 03 05_biological_databases_part3_v_upload
PPTX
2019 02 12_biological_databases_part1_v_upload
PPTX
P7 2018 biopython3
PPTX
P6 2018 biopython2b
PPTX
P4 2018 io_functions
PPTX
P3 2018 python_regexes
PPTX
T1 2018 bioinformatics
PPTX
P1 2018 python
PDF
Bio ontologies and semantic technologies[2]
PPTX
2018 05 08_biological_databases_no_sql
PPTX
2018 03 20_biological_databases_part3
PPTX
2018 02 20_biological_databases_part1_v_upload
PPTX
P7 2017 biopython3
PPTX
P6 2017 biopython2
PPTX
Van criekinge 2017_11_13_rodebiotech
PPTX
PPTX
T5 2017 database_searching_v_upload
2020 02 11_biological_databases_part1
2019 03 05_biological_databases_part5_v_upload
2019 03 05_biological_databases_part4_v_upload
2019 03 05_biological_databases_part3_v_upload
2019 02 12_biological_databases_part1_v_upload
P7 2018 biopython3
P6 2018 biopython2b
P4 2018 io_functions
P3 2018 python_regexes
T1 2018 bioinformatics
P1 2018 python
Bio ontologies and semantic technologies[2]
2018 05 08_biological_databases_no_sql
2018 03 20_biological_databases_part3
2018 02 20_biological_databases_part1_v_upload
P7 2017 biopython3
P6 2017 biopython2
Van criekinge 2017_11_13_rodebiotech
T5 2017 database_searching_v_upload

Recently uploaded (20)

PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
IGGE1 Understanding the Self1234567891011
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Digestion and Absorption of Carbohydrates, Proteina and Fats
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
PDF
Complications of Minimal Access Surgery at WLH
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PDF
Indian roads congress 037 - 2012 Flexible pavement
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
Classroom Observation Tools for Teachers
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
What if we spent less time fighting change, and more time building what’s rig...
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
IGGE1 Understanding the Self1234567891011
Computing-Curriculum for Schools in Ghana
Digestion and Absorption of Carbohydrates, Proteina and Fats
Final Presentation General Medicine 03-08-2024.pptx
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
Complications of Minimal Access Surgery at WLH
Supply Chain Operations Speaking Notes -ICLT Program
UNIT III MENTAL HEALTH NURSING ASSESSMENT
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
Orientation - ARALprogram of Deped to the Parents.pptx
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Indian roads congress 037 - 2012 Flexible pavement
History, Philosophy and sociology of education (1).pptx
Classroom Observation Tools for Teachers
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
What if we spent less time fighting change, and more time building what’s rig...
Chinmaya Tiranga Azadi Quiz (Class 7-8 )

2018 02 20_biological_databases_part2_v_upload

  • 9. Data Levels in Biological Research
  • 11. Primary dataDerived data Interpreted data/ knowledge Experimental metadata Analytical metadata
  • 12. Direct Queryability of Selected Bioinformatics Databases Database Direct Querying? How? Modality DB Engine ArrayExpressWarehouse Eventually http://www.ebi.ac.uk/aedw/ SQL Oracle BioWarehouse Yes http://biowarehouse.ai.sri.com/ - need account SQL Oracle/MySQL Ensembl Yes http://www.ensembl.org/info/d ata/download.html SQL MySQL Mouse Genome Database Yes ask for account SQL Sybase PharmGKB Yes http://www.pharmgkb.org/hom e/projects/webservices/ SOAP-based Oracle Saccharomyces Genome Database EventuallyMaybe Oracle Stanford Microarray Database No Oracle
  • 13. Example 3-tier model in biological database
  • 14. Rationale to study SQL • Learning SQL to Query Biological Databases • Are you getting too much data, or missing crucial data when querying via a Web interface? Many biological databases can be queried directly via SQL, thus bypassing the limitations of the database's interface. SQL is at the heart of biological databases as diverse as Ensembl, ArrayExpress and the Mouse Genome Database. • Focus on understanding relational databases by studying a repository of biological data and learn how to query it using SQL.
  • 15. SQL consists of only 4 statements, sometimes referred to as CRUD: –Create - INSERT - to store new data –Read - SELECT - to retrieve data –Update - UPDATE - to change or modify data. –Delete - DELETE - delete or remove data Structured Query Language
  • 16. Definitions Definitions • Database: Collection of tables  • Table – Collection of records that share a common fundamental characteristic • E.g., patients and locations can each be stored in their own table • Record – Basic unit of information in a relation information – A record is composed of fields – E.g., 1 record per person • Query – Set of instructions to a database “engine” to retrieve, sort and format returning data. • “find me all patients in my database”
  • 17. Table Characteristics • Two-dimensional structure with rows and columns • Rows (tuples) represent single entity • Columns represent attributes • Row/column intersection represents single value • Tables must have an attribute to uniquely identify each row • Column values all have same data format • Each column has range of values called attribute domain • Order of the rows and columns is immaterial to the DBMS
  • 18. Numeric Data Types MySQL uses all the standard ANSI SQL numeric data types, so if you're coming to MySQL from a different database system, these definitions will look familiar to you. The following list shows the common numeric data types and their descriptions: INT - A normal-sized integer that can be signed or unsigned. If signed, the allowable range is from -2147483648 to 2147483647. If unsigned, the allowable range is from 0 to 4294967295. You can specify a width of up to 11 digits. TINYINT - A very small integer that can be signed or unsigned. If signed, the allowable range is from -128 to 127. If unsigned, the allowable range is from 0 to 255. You can specify a width of up to 4 digits. SMALLINT - A small integer that can be signed or unsigned. If signed, the allowable range is from -32768 to 32767. If unsigned, the allowable range is from 0 to 65535. You can specify a width of up to 5 digits. MEDIUMINT - A medium-sized integer that can be signed or unsigned. If signed, the allowable range is from - 8388608 to 8388607. If unsigned, the allowable range is from 0 to 16777215. You can specify a width of up to 9 digits. BIGINT - A large integer that can be signed or unsigned. If signed, the allowable range is from - 9223372036854775808 to 9223372036854775807. If unsigned, the allowable range is from 0 to 18446744073709551615. You can specify a width of up to 20 digits. FLOAT(M,D) - A floating-point number that cannot be unsigned. You can define the display length (M) and the number of decimals (D). This is not required and will default to 10,2, where 2 is the number of decimals and 10 is the total number of digits (including decimals). Decimal precision can go to 24 places for a FLOAT. DOUBLE(M,D) - A double precision floating-point number that cannot be unsigned. You can define the display length (M) and the number of decimals (D). This is not required and will default to 16,4, where 4 is the number of decimals. Decimal precision can go to 53 places for a DOUBLE. REAL is a synonym for DOUBLE. DECIMAL(M,D) - An unpacked floating-point number that cannot be unsigned. In unpacked decimals, each decimal corresponds to one byte. Defining the display length (M) and the number of decimals (D) is required. NUMERIC is a synonym for DECIMAL.
  • 19. String Data Type • Although numeric and date types are fun, most data you'll store will be in string format. This list describes the common string datatypes in MySQL. • CHAR(M) - A fixed-length string between 1 and 255 characters in length (for example CHAR(5)), right- padded with spaces to the specified length when stored. Defining a length is not required, but the default is 1. • VARCHAR(M) - A variable-length string between 1 and 255 characters in length; for example VARCHAR(25). You must define a length when creating a VARCHAR field. • BLOB or TEXT - A field with a maximum length of 65535 characters. BLOBs are "Binary Large Objects" and are used to store large amounts of binary data, such as images or other types of files. Fields defined as TEXT also hold large amounts of data; the difference between the two is that sorts and comparisons on stored data are case sensitive on BLOBs and are not case sensitive in TEXT fields. You do not specify a length with BLOB or TEXT. • TINYBLOB or TINYTEXT - A BLOB or TEXT column with a maximum length of 255 characters. You do not specify a length with TINYBLOB or TINYTEXT. • MEDIUMBLOB or MEDIUMTEXT - A BLOB or TEXT column with a maximum length of 16777215 characters. You do not specify a length with MEDIUMBLOB or MEDIUMTEXT. • LONGBLOB or LONGTEXT - A BLOB or TEXT column with a maximum length of 4294967295 characters. You do not specify a length with LONGBLOB or LONGTEXT. • ENUM - An enumeration, which is a fancy term for list. When defining an ENUM, you are creating a list of items from which the value must be selected (or it can be NULL). For example, if you wanted your field to contain "A" or "B" or "C", you would define your ENUM as ENUM ('A', 'B', 'C') and only those values (or NULL) could ever populate that field.
  • 20. Built-in Data Types in SQL • date: Dates, containing a (4 digit) year, month and date – Example: date ‘2005-7-27’ • time: Time of day, in hours, minutes and seconds. – Example: time ‘09:00:30’ time ‘09:00:30.75’ • timestamp: date plus time of day – Example: timestamp ‘2005-7-27 09:00:30.75’ • interval: period of time – Example: interval ‘1’ day – Subtracting a date/time/timestamp value from another gives an interval value – Interval values can be added to date/time/timestamp values
  • 21. Build-in Data Types in SQL (Cont.) • Can extract values of individual fields from date/time/timestamp – Example: extract (year from r.starttime) • Can cast string types to date/time/timestamp – Example: cast <string-valued-expression> as date – Example: cast <string-valued-expression> as time
  • 22. User-Defined Types • create type construct in SQL creates user-defined type create type Dollars as numeric (12,2) final • create domain construct in SQL-92 creates user- defined domain types create domain person_name char(20) not null • Types and domains are similar. Domains can have constraints, such as not null, specified on them.
  • 23. Large-Object Types • Large objects (photos, videos, CAD files, etc.) are stored as a large object: – blob: binary large object -- object is a large collection of uninterpreted binary data (whose interpretation is left to an application outside of the database system) – clob: character large object -- object is a large collection of character data – When a query returns a large object, a pointer is returned rather than the large object itself.
  • 24. Creating a Table • To create a table, use the CREATE TABLE command: mysql> CREATE TABLE pet ( -> name VARCHAR(20), -> owner VARCHAR(20), -> species VARCHAR(20), -> sex CHAR(1), -> birth DATE, death DATE); Query OK, 0 rows affected (0.04 sec)
  • 25. Keys • One or more attributes that determine other attributes – Key attribute – Composite key • Full functional dependence • Entity integrity – Uniqueness – No ‘null’ value in key
  • 28. Keys (con’t.) • Primary key – Candidate key to uniquely identify all other attributes in a given row • Foreign key – Values must match primary key in another table
  • 29. Integrity Rules • Entity integrity – Ensures all entities are unique – Each entity has unique key • Referential integrity – Foreign key must have null value or match primary key values – Makes it impossible to delete row whose primary key has mandatory matching foreign key values in another table
  • 30. Integrity Constraints • Integrity constraints guard against accidental damage to the database, by ensuring that authorized changes to the database do not result in a loss of data consistency. – A checking account must have a balance greater than $10,000.00 – A salary of a bank employee must be at least $4.00 an hour – A customer must have a (non-null) phone number
  • 31. Referential Integrity • Ensures that a value that appears in one relation for a given set of attributes also appears for a certain set of attributes in another relation. – Example: If “Perryridge” is a branch name appearing in one of the tuples in the account relation, then there exists a tuple in the branch relation for branch “Perryridge”. • Primary and candidate keys and foreign keys can be specified as part of the SQL create table statement: – The primary key clause lists attributes that comprise the primary key. – The unique key clause lists attributes that comprise a candidate key. – The foreign key clause lists the attributes that comprise the foreign key and the name of the relation referenced by the foreign key. By default, a foreign key references the primary key attributes of the referenced table.
  • 42. Install BIOSQL locally • Get latest version of mysql (MAMP, mariaDB) • Download biosqldb-mysql.sql • Remove type=innodb • Launch database server • Connect using toad (port 8889) • Create database biosql; • Set as active database • Use worksheet to execute biosqldb- mysql.sql
  • 44. How ODBC Works? • ODBC inserts a middle layer called a Client Driver • Purpose of the Client Driver is to translate the applications queries into commands that the DBMS understands
  • 45. Other Parts of the Architecture • Application – calls functions defined in the ODBC API to access a data source • Driver Manager – implements the ODBC API and provides information to the application • Database – contains all the data
  • 46. Setting Up a Data Source in Windows • A data source is just a database that ODBC connects to • This allows the person to change database types without any changes to the program • Step 1. Get a database. – Using access for this example because it’s on this computer
  • 47. Conclusion The four parts that make up ODBC:
  • 48. Conclusion • Advantages: – Allows access to different types of databases – Uniform way of retrieving information – Highly efficient – Low memory requirements • Disadvantages – Complex and steep learning curve – All data in database must look like a relational database
  • 49. Conclusion • ODBC changed the way people code their programs that have to interact with databases. • The efficiency of programmers in the business world has increased due to ODBC because they no longer are wasting time to create multiple copies of a program. • ODBC has vastly improved the way programmers deal with databases.