






















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!























For educational purposes only Mater Dei College Tubigon, Bohol 1st Semester, A.Y. 2021- 2022 IM 2 (INFORMATION MANAGEMENT 2) Topic 7 - Connecting to MYSQL using PDO Study Guide CONNECTING TO MYSQL Prerequisites Before connecting to a MySQL database server, you need to have:
Mater Dei College Tubigon, Bohol 1st Semester, A.Y. 2021- 2022 IM 2 (INFORMATION MANAGEMENT 2) Topic 7 - Types of Databases Study Guide A DBMS can support many different types of databases. Databases can be classified according to the number of users, the database location(s), and the expected type and the extent of use.
⚫ Structured audio : A sequence of audio components comprising note, tone, duration, and so forth. ⚫ Audio : Sample data generated from aural recordings in a string of bits in digitized form. Analog recordings are typically converted into digital form before storage. ⚫ Composite or mixed multimedia data : A combination of multimedia data types such as audio and video which may be physically mixed to yield a new storage format or logically mixed while retaining original types and formats. Composite data also contains additional control information describing how the information should be rendered. ⚫ Presentation applications : A large amount of applications involve delivery of multimedia data subject to temporal constraints; simple multimedia viewing of video data, for example, requires a system to simulate VCR-like functionality. Complex and interactive multimedia presentations involve orchestration directions to control the retrieval order of components in a series or in parallel. Interactive environments must support capabilities such as real-time editing analysis or annotating of video and audio data. ⚫ Collaborative work using multimedia information : This is a new category of applications in which engineers may execute a complex design task by merging drawings, fitting subjects to design constraints, and generating new documentation, change notifications, and so forth. Intelligent healthcare networks as well as telemedicine will involve doctors collaborating among themselves, analyzing multimedia patient data and information in real time as it is generated. Multimedia Database Applications Large-scale applications of multimedia databases can be expected encompasses a large number of disciplines and enhance existing capabilities. ⚫ Documents and records management ⚫ Knowledge dissemination ⚫ Education and training ⚫ Marketing, advertising, retailing, entertainment, and travel ⚫ Real-time control and monitoring
4. Geographic Information System Geographic information systems (GIS) are used to collect, model, and analyze information describing physical properties of the geographical world and designed to captures, stores, manipulates, analyze, manage, and present all types of geographical data. The scope of GIS broadly encompasses two types of data:
8. OLAP enable users o interactively analyze multidimensional data from multiple perspective. It is a tool or approach to answer multidimensional analytical queries. Ex. App. - business reporting for sales - marketing and management report - budget forecasting 9. Real-time database is a processing system designed to handle workloads whose state is very dynamic or in a rapid change. It is a processing which means that a transaction is processed fast enough for the result to come back and be acted on right away. ex. Stock market 10. Data warehouse ( DW or DWH ) is a database used for reporting and analysis. The data stored in the warehouse are uploaded from the operational systems (such as marketing, sales etc.) may pass through an operational data store for additional operations before they are used in the DW for reporting. 11. Data Mining also known as data or knowledge discovery. It is the computer-assisted process of digging through and analyzing enormous sets of data and then extracting the meaning of the data. - Data mining tools predict behaviors and future trends, allowing businesses to make proactive, knowledge-driven decisions. Data mining tools can answer business questions that traditionally were too time consuming to resolve. - For businesses, data mining is used to discover patterns and relationships in the data in order to help make better business decisions. Data mining can help spot sales trends, develop smarter marketing campaigns, and accurately predict customer loyalty. Specific uses of data mining include: - Market segmentation - Identify the common characteristics of customers who buy the same products from your company. - Trend analysis - Reveal the difference between a typical customer this month and last.
Ex. Select Cust_id as “customer id”, Lname as Lastname, address from customer; Eliminating duplicate rows with DISTINCT Columns often contain duplicate values, and it’s common to want a result tjat list each duplicate only once. Ex. Select DISTINCT address from customer; Sorting rows with ORDER BY Rows in query result are unordered. Use the order by clause to sort rows by a specified columns or columns in ascending (asc) or descending (desc). Ex. Select * from customer order by age asc; Filtering rows with WHERE Use the WHERE clause to filter unwanted rows from the result. WHERE clause- specifies a search condition that comprises one or more conditions that need to be satisfied by the rows of a table. A condition , or predicate, is a logical expression that evaluates to true, false or unknown. The unknown result arises from nulls. Rows for which the condition is true are included in the result; rows for which the condition is false or unknown are excluded. SQL provides operators that express different types of conditions. Operators are symbols or keywords that specify actions to be performed in values or other elements. You can combine and negate conditions by using the logical operators AND, OR,NOT Types of Condition and Their corresponding operators Comparison – with the following operators =, <>, <, <=, >, >= Pattern Matching – LIKE Range Filtering – BETWEEN List Filtering – IN Null Test – IS NULL Comparison EXAMPLE
‘re%’ - matches a string values of length >= 3 that begins with any character and has re as its second and third characters. ‘%re’ - matches a string value of length >=3 that has re as the second and third characters from its end, and ends with any character. Range Filtering with BETWEEN Use between to determine whether a given value falls within a specified range. Important characteristics of between conditions are: ➢ Between works with character strings, numbers, and datetimes. ➢ The between range contains a low value and a high value, separated by AND. The low value must be less than of equal to the high value. ➢ Between is a convenient shorthand clause, you can replicate its behavior by using AND; o Where test_column BETWEEN low_value and high_value Is equivalent to Where (test_column>= low_value) and (test_column<= high_value) ➢ Between specifies an inclusive range, in which the high value and low value are included in the result/search. To specify an exclusisve range, which excludes endpoints, use > and < comparisons operator instead of between operator. ➢ You can negate a between conditions with not between operator. ➢ You can combine BETWEEN conditions and other conditions with AND and OR. List Filtering with IN Use IN to determine whether a given value matches any value in a specified list. ➢ IN works with character strings, numbers, and datetimes ➢ The IN list is a parenthesized listing of one or more comma-separated values. ➢ IN is a convenient, shorthand clause. You can replicate its behavior by using OR: Where test_columnIN(value1, value2, value3) Is equivalent to Where (test_column = value1) OR (test_column = value2) OR (test_column = value3) ➢ You can negate an IN condition with NOT IN. ➢ You can combine IN conditions and other conditions with AND and OR. Testing for Nulls with IS NULL Null represent missing or unknown values. This situation causes a problem: LIKE, BETWEEN, IN, and other WHERE clause options can’t find nulls because unknown values don’t satisfy specific conditions. Nulls match no value. IS NULL determines whether a given value is null. ➢ Works for columns of any data type ➢ You can negate an IS NULL condition with IS NOT NULL ➢ You can combine IS NULL conditions and other conditions with AND and OR. EX. SELECT columns from table where test_column IS [NOT] NULL; OPERATORS AND FUNCTIONS Operators and functions permit you to calculate results derived from column data, system-determined values, and constant expressions. Where in you can perform the following:
➢ CASE has two formats: simple and searched. The simple case expression compares an expression to a set of simple expressions to determine the result. The searched case expression evaluates a set of logical (Boolean) expressions to determine the result ➢ CASE returns an optional ELSE result as the default value if no test condition is true ➢ Ex. Simple case expression Select title_id, type, price, Case type When ‘history’ then price * 1. When ‘psychology’ then price * 1. Else price End as “new price” from book; Ex: Searched CASE expression Select title_id, case when sales is null then “unknown’ When sales <= 1000 then “sale is low” When sales <= 50000 then “sale is high” Else ‘sale is high’ end as ‘sales category’ From book Order by sales asc; SUMMARIZING AND GROUPING DATA The preceding chapter described scalar functions, which operate on individual row values. This topic introduces SQL’s aggregate functions, or set functions, which operate on a group of values to produce a single, summarizing value. You apply an aggregate to a set of rows, which may be: ➢ All the rows in a table ➢ Only those rows specified by a where clause ➢ those rows created by a group by clause No matter how many rows the set contains, an aggregate function returns a single statistic: a sum, minimum, or average. USING AGGREGATE FUNCTIONS Function Returns MIN(expr) Minimum value in expr MAX(expr) Maximum value in expr SUM(expr) Sum of the values in expr AVG(expr) Average(arithmetic mean) of the values in expr COUNT(expr) The number of non-null values in expr COUNT() The number of rows in a table or set The characteristics of the aggregate functions are: ➢ Expression often is a column name. ➢ SUM () and AVG() work with only numeric data type. MIN() AND MAX() work with characters, numeric, and date time data types. COUNT(expr) and COUNT() work with all data types. ➢ All aggregate functions except COUNT() ignore nulls ➢ Often use with the group by clause ➢ Use WHERE clause to restrict the rows used in aggregate calculations ➢ Default column headings for aggregate vary by DBMS use: use column alias to name the result column Ex. Select sum(sales), min(price), max(price) from item group by description; Select count() as ‘total number of items’ from item; Select count(description) as ‘total’ from item group by description order by description asc;
Database Anomalies ● Insert Anomalies ● Update Anomalies ● Delete Anomalies
Insert Anomaly delivery _id item_name date branch 11234 Item 1 8/24/2019 Cebu 11235 Item 5 8/30/2019 Bohol 11236 Item 3 9/5/2019 Cebu 11237 Item 9 9/8/2019 Leyte Considering this table, we cannot add a new branch until a delivery for the new branch will be recorded.
Delete Anomaly If we are to close one branch and delete that branch from our database, all the deliveries to that branch will also be deleted. delivery _id item_name date branch 11234 Item 1 8/24/2019 Cebu 11235 Item 5 8/30/2019 Bohol 11236 Item 3 9/5/2019 Cebu 11237 Item 9 9/8/2019 Leyte
Source Table (not normalized)