is6146 databases for management information systems lecture 1: introduction to is6146 rob gleasure...

Post on 08-Jan-2018

218 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

IS6146 Module content and learning outcomes  Using databases (i.e. SQL)  Semistructured data (i.e. XML)  Unstructured data

TRANSCRIPT

IS6146 Databases for Management Information SystemsLecture 1: Introduction to IS6146

Rob GleasureR.Gleasure@ucc.ierobgleasure.com

IS6146

Lecture times 13.00-15.00, Wednesday (KANE B10A)

Contact me at Ext 2503 Room 2.112 R.Gleasure@ucc.ie

Website for this course robgleasure.com

IS6146 Module content and learning outcomes

Using databases (i.e. SQL) Semistructured data (i.e. XML) Unstructured data

IS6146

Course Assessment Continuous assessment: 50 marks

In-class exam* – 20 marks Group report* – 30 marks

Exam: 50 marks

* To be confirmed

Database Management Systems A Database Management System (DBMS) is a software package

designed to store and manage databases.

This is different from a database file for several reasons DBMS makes tables visible and generates reports DBMS helps less technical users to use data efficiently DBMS protects data from inconsistency and duplication due to

multiple concurrent users DBMS handles crash recovery DBMS handles security and access control

Database Management Systems DBMS operates at the physical level

This is where data handling becomes increasingly technical

Physical model

Logical model

Conceptual modelManagement and business

users

Database administrators

System analysts

and designers

Database Management Systems DBMS are typically managed by a set Database Administrator,

whose responsibilities include Defining or refining logical schema in response to requirements Granting appropriate access to users Monitoring DBMS performance Updating/changing DBMS software

Database Management Systems Other users will include

Application developers (write programs that need to access/modify data)

Sophisticated/specialised users (use DBMS directly to generate reports and assist business analysis)

Naïve users (use applications that access/modify data)

Examples of DBMSOracleLarge multi-user DBMS that excels at handling many clients requesting, accessing, and modifying dataPopular in large organisations and cloud services due to scalabilityVery effective handling of concurrency, read consistency, parallel execution, and locking mechanisms

MS AccessPopular DBMS for small scale projects due to its relatively low cost and usabilityImports and exports data to many formats commonly used in organisations, e.g. Excel, Outlook, SQL Server, OracleIntegrates easily with MS tools like VB, C# and .NET

Examples of DBMS

MySQLOpen source SQL database with free and paid versionsFlexible and scalableOpen source means lots of support and the potential for adaptability

MS SQL ServerGood performance XML integrationInclusion of try/catch queries

Comparison of DBMS from lab manuals (out of 5 stars)

Oracle MS Access MySQL MS SQL Server

Cost 2.5 4 5 3

Web friendly 3 3 3 3.5

Reliable 4 2 3 4.5

Complex 3 2 4 4.5

Security 4 3 3 3

Capacity 3.5 2 3 5

Flexibility 3 2 4 4

Technical fit 3 2 4 5

Ease of use 3 4.5 3 4.5

Accessing a DBMS with SQL

So once we have our data models in place and our DBMS set up, how do we get started using our data?

The SQL (pronounced like sequel) query language

SQL (Structured Query Language) was introduced in the 70’s and has evolved since to add features such as Compatibility with object-oriented programming Compatibility with XML Compatibility with XQuery

Accessing a DBMS with SQL

The Structure of SQL

SQL can be divided into two parts: The Data Manipulation Language (DML)

Used to create, read, update and delete tuples (CRUD operations)

Mostly used by application programmers and sophisticated/specialised users

The Data Definition Language (DDL) Used to define database structure (relation schemas) and

data access control, as well as integrity constraints and views Mostly used by database administrator

Executing SQL in a DBMS

Accessing DBMS with SQL

The basic syntax of SQL queries are as follows:

COMMAND column_name1, column_name2, …

FROM/SET/VALUES table_name1, table_name2, …

WHEREcolumn_name comparison_operator value;

All statements in a semi-colon

The SQL Select statement

The SELECT statement is used to retrieve data from a database into a result table, or result-set

You can use an asterisk (*) instead of a column name if you wish to select all columns satisfying the criteria

e.g. SELECT * FROM my_table;

The SQL Select statement

Let’s open up an online example from W3Schools http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all

The SQL Select statement

Sometimes non-primary key columns may contain duplicate values - you can also use SELECT DISTINCT when you want to avoid duplicates in your result-set

e.g. SELECT DISTINCT * FROM my_table;

The SQL Where clause

A number of comparison operators are possible with the WHERE clause

Examples http://www.w3schools.com/sql/

trysql.asp?filename=trysql_select_between_in

http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_in

Operator Description= Equal

<>, != Not equal

> Greater than

< Less than

>= Greater than or equal

<= Less than or equal

BETWEEN Between an range of numbers

LIKE Searches for patterns

IN When a specific value is sought

The ‘LIKE’ condition and Wildcards Sometimes we want to identify records based on slices of the data

within a cell - we do this using wildcards and the LIKE condition

Examples http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_wildcard_percent http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_wildcard_underscore http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_wildcard_charlist&ss=-1

Wildcard Description% A substitute for zero or more characters_ A substitute for a single character[charlist] Sets and ranges of characters to match[^charlist]or [!charlist]

Matches only a character NOT specified within the brackets

The SQL Where clause (continued) Numerous clauses can be combined with the keywords AND & OR

e.g.SELECT * FROM my_table WHERE val1=‘true’ AND val2=‘false’;

Complex clause can be creates by nesting clauses in parentheses e.g.

SELECT * FROM my_table WHERE val1=‘true’ AND (val2=‘false’ OR val2=‘null’);

Examplehttp://www.w3schools.com/sql/trysql.asp?filename=trysql_select_where_and_or

The SQL Order By keyword

The ORDER BY keyword is used to sort the result-set e.g.

SELECT * FROM my_table ORDER BY NAME;

You may also specify whether you want the returned result-set to be sorted in ascending or descending order by using the keywords ASC or DESC

e.g. SELECT * FROM my_table ORDER BY NAME DESC;

Example http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_orderby_desc

Readings

http://www.w3schools.com/sql http://www.tizag.com/sqlTutorial/

top related