Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.

Similar presentations


Presentation on theme: "Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett."— Presentation transcript:

1 Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett

2 What Is A Database? A database is an organized collection of data, today typically in digital form The term database is correctly applied to the data and their supporting data structures, and not to the database management system (DBMS). The term database system implies that the data is managed to some level of quality (measured in terms of accuracy, availability, usability, and resilience)

3 What Are Popular DBMS? Oracle IBM DB2 MS SQLServer MS Access PostgreSQL MySQL WebDNA SQLite

4 Basic Terms Database application programmer/administrator Several software languages exist to build, support, and maintain database software – Data definition languages – Data manipulation languages – Query languages

5 Data Models There are different ways to relate the information in a database to one another First generation dbs were navigational (following a series of pointers from one record to another (think of an old card catalogue)) These used a either: – Hierarchal model – tree like, 1 to many structure – Codasyl model – more flexible, many to many

6

7 Relational Databases The Relational model departed from this tradition by searching for data by content, rather than by following links – Allows the content of the database to evolve without constant rewriting of applications The dominant database language is the standard SQL for the Relational model Because the relational model emphasizes search rather than navigation, it does not make relationships between different entities explicit in the form of pointers

8 Relational Databases Users directly state what information the database contains and what information they want from it – the DBMS takes care of describing data structures for storing the data and retrieval procedures for answering queries The table is the accepted form for storing data & the relationships between data Relational databases allow programmers to write queries that were not anticipated by the designers

9 How Relational DBs Work “Users” request data by sending the db a query, usually written in SQL In response the db generates a result set (a list of rows containing the answers) – You can ask for all rows from a table or define some specific subset You can join information from multiple tables into one result set – There are many modifications and ways of changing what results you receive and how you receive them

10

11 Entity-relationship Model ER Model is a conceptual and (very) abstract way to represent the data within a database ER models describe information needs or the type of information that is to be stored in a database 3 basic elements: entities, relationships, attributes

12 Entity – relationship diagram Entity – attribute diagram Relationship – attribute diagram Primary Key 1 N

13 Database Transactions Databases use a system of turn-taking procedures to make sure all of the data is maintains consistency while still being available to those who need it Each turn of the conversation is called a transaction (i.e. a discrete action is accomplished)

14 Transactions on ACID DB transactions follow a set of rules called ACID – Atomicity – all the effects occur or none of the effects occur – Consistency – each transaction must leave the db in a consistent (correct) state – Isolation – transaction cannot interfere with each other and incomplete results of a transaction are invisible to other transactions – Durability – effects of successful transactions must persist through crashes (usually through logging of transactions). Locking – When a transaction has its turn to go it can “lock” the data it’s dealing with so that data can’t be altered in alignment with the ACID rules

15 Summary There are many types of databases Relational databases are the most common today – MySQL is the relational database this class is using Relational databases use tables to store data and show relationships between data Most relational databases use SQL (structured query language) to access, retrieve, change information

16 MySQL MySQL is just one of the many types of DBMS available on the market today. However, it is one of the more popular for running webpages – Due to its cost and general community support The SQL in MySQL stands for Structured Query Language – It is a standard for creating queries and many other DBMSs use it

17 MySQL A simple (and common) query written in MySQL looks like : SELECT title FROM publications WHERE author = 'Charles Dickens'; A MySQL database contains one or more tables, each of which contain records or rows. Within these rows are various columns or fields that contain the data itself

18 Accessing MySQL There are many different ways to access your MySQL database – Command line, through a web interface, with a programming language MySQL is case-insensitive but the standard format is to use all uppercase The first thing you need to begin using MySQL is a database to work within

19 Working Within A Database In order to maintain control over a database and make sure that it remains consistent create users with restricted access GRANT PRIVILEGES ON database.object TO 'username@hostname' IDENTIFIED BY 'password'; After making a user you need to make a table to store the data in CREATE TABLE classics ( author VARCHAR(128), title VARCHAR(128), type VARCHAR(16), year CHAR(4)) ENGINE MyISAM; Typing DESCRIBE will show the table you just made

20 Common Terms Field - The name of each field or column within a table. Type - The type of data being stored in the field. Null - Whether a field is allowed to contain a value of NULL. Key - MySQL supports keys or indexes, which are quick ways to look up and search for data. The Key heading shows what type of key (if any) has been applied. Default - The default value that will be assigned to the field if no value is specified when a new row is created. Extra - Additional information, such as whether a field is set to auto-increment.

21 Data Types MySQL supports many data types VARCHAR (variable length character) CHAR (character) used for predictable inputs Binary – strings of bytes without a character set Text – cannot have default values BLOB (Binary Large Object) – data that exceeds Binary limits Int, float, double, real – numeric types

22 AUTO_INCREMENT AUTO_INCREMENT will cause a integer in that column to go up by one each time a row is added to the table Useful for creating primary keys since they are always unique Used in combination with NOT NULL and KEY

23 Adding Data The INSERT command adds data to the table you specify It must be used each time a piece of data is added to the table INSERT INTO table(column, column, column, column) VALUES(‘value',‘value',‘value',‘value'); SELECT * FROM will show all the records in the table that you specify

24 Removing Data The key word to use any time you want to remove some information from the database is DROP However, you want to be extremely careful using DROP since there is no undo This is a good command to limit most DB users from having access to.

25 For More Help And Exercises Google Code University - http://code.google.com/edu/tools101/mysql. html http://code.google.com/edu/tools101/mysql. html


Download ppt "Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett."

Similar presentations


Ads by Google