0% found this document useful (0 votes)
6 views26 pages

Lecture 01 - Quiz 01 - Midterm - Advdbmgmt - Elms

DATABASE MANAGEMENT

Uploaded by

abir shad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views26 pages

Lecture 01 - Quiz 01 - Midterm - Advdbmgmt - Elms

DATABASE MANAGEMENT

Uploaded by

abir shad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

ADVANCE

DATABASE
MANAGEMENT
MIS 4388, Section A
Lecture: 01
Instructor: AAFD
WHAT THIS COURSE WILL
FOCUS ON
We live in a data driven world. No matter where and how you spend your work life,
whether it is a job or your own business, You must posses the analytical competency
to work with data. In this course, we will use MySQL Workbench extensively so that
you feel confident and ready to dive into the ocean of data after finishing the course.
In class, I will also show you how relevant this skill is to real life, probably one of the
top 5 skills there are, around the world.

2
Traditional Data vs Big
Data/NOSql

Traditional Data:
Traditional data are structured data that are managed in the forms of records, files and
tables by languages such as Structured Query Language (SQL) in traditional data-processing
application software.
Example: Students records, order records, employee data etc.
Big Data/NOSQL:
Big data refers to very large or complex data sets which are difficult to manage in traditional
data-processing application software. Any data that exceeds current capability of processing at
a firm, can be regarded as “big Data” for that firm.
Examples: Social media posts, tweets, images, video clips etc.

3
Data Terms
❑ Data: Data is facts & figures such as numbers, words, measurements, observations that can
be processed to form valuable information.
❑ Database: A database is an organized collection of information typically stored electronically
in a computer system
❑ DBMS: A database management system is a collection of programs that allow you to create,
manage, and operate a database. Example: Microsoft SQL server, MariaDB, Microsoft Access
etc.

4
Data Terms
❑ Data Mining: Data mining is the process of digging for valuable data, identify precious
patterns and relationships that can serve needed purpose of a business through data analysis
❏ Data integration: Data integration is the process of combining data from
multiple sources to create unified sets of information.
❏ Data Cleaning: Data cleaning is the process of fixing or removing incorrect, corrupted,
incorrectly formatted, duplicate, or incomplete data within a dataset.
❏ Data analysis: Data analysis is the practice of using ready data to glean useful
information that helps us draw conclusions, make predictions & decisions.

5
What does a DBMS facilitate?
1. Manipulation of database by RAM
❏ Retrieval: Querying, generating reports
❏ Access: Accessing the database through applications
❏ Modification: Insertions, deletions and updates of its content
2. Sharing of a database by concurrent users and application programs
3. Protection of database by unauthorized access facility
4. Presentation and visualization of data

6
Rows & Columns in SQL

Rows:
Columns:
Record/Observation/Item: Field/Attributes/Properties:

A record is each individual A field is a column in a table


information that exists in a that is designed to maintain
table horizontally. specific information about
every record in the table
vertically.

7
Start the practice
MYSQL Workbench
❑ Open MYSQL Workbench

8
Creating Tables in Workbench
How to create a table:
SYNTAX:
• The column parameters specify the names of the columns of the table.
• The datatype parameter specifies the type of data the column can hold
(e.g. varchar, integer, date, etc.).

SYNTAX: RESULT:
Creating Tables in Workbench

❑ Are there any inconsistencies you see when you are inserting values, do you have a
questions?

❏ Apostrophe is not necessary when inserting numerical data.


❑ Why use Semicolon after SQL Statements?
❏ In most databases, semicolon is the standard way to separate each SQL
statement.
Creating Tables in Workbench
 Let’s create our 2nd table.
SYNTAX:

RESULT:

❑ After you get the result with a green tick, write the following syntax.
Creating Tables in Workbench
❑ Now insert these data into the table.

StudentID FirstName LastName Major Semester City Badge


1 Imamul Bashar B.A 12 Badda Junior
2 Ahsan Shihab D.A 15 Dhanmondi Senior
3 Kowser Mohiuddin B.I 13 Badda Junior
4 Maisha Rafa D.A 14 Gulshan Senior
5 Mahajabin Momotaz D.A 13 Uttara Junior
6 Durjoy Mahmood B.A 15 Banani Senior
7 Azmain Ahnaf B.I 12 Uttara Junior
8 Hasibul Hasan D.A 14 Dhanmondi Senior
9 Mohammad Ali Mridul B.A 13 Gulshan Junior
10 Syeda Sadia Chowdhury D.A 12 Banani Junior
Creating Tables in Workbench
❑ It should look like this

RESULT:
Pulling data from tables [ ‘Where’ clause]
❑ The “WHERE” clause is used to filter data.
❑ Let’s say the BBA office wants to know how many MIS students have chosen Business analytics as major.
❑ Syntax: SELECT * FROM MISStudents
WHERE Major ='B.A';

❏ Similarly, pull the data for “Business Intelligence” (B.I) & “Data Analytics” (D.A)
❑ Note:
❏ We created 2 tables. At one table we started with “CREATE TABLE” and in another “create table”.
So what we know now is:
SQL keywords are NOT case sensitive
Pulling data from tables [ ‘Select Distinct’ statement]
❑ The SELECT DISTINCT statement is used to return only distinct (different) values, in other words, no repeated
values.
❑ Inside a table, a column often contains many duplicate values, such as majors.
❏ SELECT Major
❏ FROM Misstudents;

❑ However, lets assume the BBA department wants a list of exactly how many different majors there
are (Without repeating a major).
❑ Now we run the query with DISTINCT
❏ SELECT DISTINCT Major
❏ FROM Misstudents;

❑ In real life, this is very important. Let’s say an Amazon.com marketing manager wants to see the “list of
cities” from where his company had a purchase yesterday.
Pulling data from tables [ ‘Select Distinct’ statement with ‘COUNT’]
❑ Now, Let’s say in that real life scenario, the Amazon.com manager asked his colleague to just to
let him/her know the number of cities that the company had a purchase from.
Or
The BBA department at UIU do not want the list, but the number of different majors.

❑ To get such specific result, you will use the Distinct statement again, but now with the count
syntax
❏ You syntax will be what you wrote before, only add Count before “Distinct Major” & put
“Distinct Major” inside a bracket. Note: There should be no space between count and the
start of bracket.
❏ SELECT COUNT(Distinct Major)
❏ FROM Misstudents;
❑ What is Alias in SQL?
Alias
❏ SQL aliases are used to give a table, or a column in a table, a temporary name.
It is created with the AS keyword & only exists for the duration of that query.
❑ Syntax

❑ Result

❑ Let’s change the column name of a result we previously generated.


❑ Syntax:
AND, OR and NOT Operators in SQL

❑ AND Example
❏ The BBA department wants to know who are the student that are junior and have
Data Analyst as their majors.
❏ Syntax:

❏ Result:

❏ Exercise: Find data for the students who are in “Business Intelligence” major and
has “Senior” badge.
AND, OR and NOT Operators in SQL
❑ OR Example
❏ The BBA department wants to facilitate bus service for students living close by
campus. They want to know students who live in either Banani or Gulshan.
❏ Syntax:

❏ Result:

❏ Exercise: Find the students who live in “Dhanmondi” or “Badda”.


AND, OR and NOT Operators in SQL
❑ NOT Example
❏ The BBA department decided the bus service will now be all student except the ones
living in Dhanmondi and Uttara.
❏ Syntax:

❏ Result:

❏ Exercise: Find data for students with all semesters except semester number 12 or 13.
Like Operator
❑ What is Like Operator?
❏ The LIKE operator is usually used with a WHERE clause to search
for a specified pattern in a column by using something called wildcards.
❏ We will learn 2 of these wildcards.
1. The percent sign (%)
2. The underscore sign ( _ )
❏ What’s the use of Like operator in real life?
❏ The like operator finds a specific pattern. Imagine transactions IDs,
that are often generated with similar patterns. The Like operator gives
data practitioners the power to filter data based on specific patterns.
❑ Use of Like operator with % & _ wildcards.
Like Operator
LIKE Operator Description
WHERE FirstName LIKE ‘M%' Finds any values that start with “M"
WHERE LastName LIKE '%N' Finds any values that end with “N"
WHERE Badge LIKE '%ni%' Finds any values that have “ni" in any position
❑ Let’s find First name that start with “M”
❑ Syntax:

❑ Result:

❑ Exercise:
❑ Let’s find Last name that end with “N”
❑ Let find any values that have “ni” in the badge column
❑ Use of Like operator with % & _ wildcard.
Like Operator
LIKE Operator Description
WHERE City LIKE Finds any values that starts with ‘D’ and atleast 2 characters in length
‘D_%'
WHERE City LIKE Finds any values that starts with ‘U’ and atleast 3 characters in length
‘U__%'
WHERE City LIKE Finds any values that starts with ‘G’ and ends with ‘N’.
‘G%N'

❑ Let’s find city names that starts with “D” and are at least 2 characters in length.
❑ Syntax:

❑ Result:

❑ Exercise:
❑ Let’s find cities that starts with ‘U’ and atleast 3 characters in length
❑ Let find cities that starts with ‘B’ and ends with ‘I’.
String Data Types

Data type Description


CHAR(size) A FIXED length string (can contain letters, numbers, and special characters). The size parameter specifies the
column length in characters - can be from 0 to 255. Default is 1

VARCHAR(size) A VARIABLE length string (can contain letters, numbers, and special characters). The size parameter specifies the
maximum column length in characters - can be from 0 to 65535

BINARY(size) Equal to CHAR(), but stores binary byte strings. The size parameter specifies the column length in bytes. Default is
1

VARBINARY(size) Equal to VARCHAR(), but stores binary byte strings. The size parameter specifies the maximum column length in
bytes.

TINYBLOB For BLOBs (Binary Large OBjects). Max length: 255 bytes

TINYTEXT Holds a string with a maximum length of 255 characters

TEXT(size) Holds a string with a maximum length of 65,535 bytes


BLOB(size) For BLOBs (Binary Large OBjects). Holds up to 65,535 bytes of data

MEDIUMTEXT Holds a string with a maximum length of 16,777,215 characters

MEDIUMBLOB For BLOBs (Binary Large OBjects). Holds up to 16,777,215 bytes of data

LONGTEXT Holds a string with a maximum length of 4,294,967,295 characters

LONGBLOB For BLOBs (Binary Large OBjects). Holds up to 4,294,967,295 bytes of data

ENUM(val1, val2, A string object that can have only one value, chosen from a list of possible values. You can list up to 65535 values in
val3, ...) an ENUM list. If a value is inserted that is not in the list, a blank value will be inserted. The values are sorted in the
order you enter them

SET(val1, val2, A string object that can have 0 or more values, chosen from a list of possible values. You can list up to 64 values in a
val3, ...) SET list
Numeric Data Types

Data type Description


BIT(size) A bit-value type. The number of bits per value is specified in size. The size parameter can hold a value from 1 to 64. The default value
for size is 1.
TINYINT(size) A very small integer. Signed range is from -128 to 127. Unsigned range is from 0 to 255. The size parameter specifies the maximum
display width (which is 255)
BOOL Zero is considered as false, nonzero values are considered as true.
BOOLEAN Equal to BOOL
SMALLINT(size) A small integer. Signed range is from -32768 to 32767. Unsigned range is from 0 to 65535. The size parameter specifies the maximum
display width (which is 255)
MEDIUMINT(size) A medium integer. Signed range is from -8388608 to 8388607. Unsigned range is from 0 to 16777215. The size parameter specifies the
maximum display width (which is 255)
INT(size) A medium integer. Signed range is from -2147483648 to 2147483647. Unsigned range is from 0 to 4294967295. The size parameter
specifies the maximum display width (which is 255)
INTEGER(size) Equal to INT(size)
BIGINT(size) A large integer. Signed range is from -9223372036854775808 to 9223372036854775807. Unsigned range is from 0 to
18446744073709551615. The size parameter specifies the maximum display width (which is 255)

FLOAT(size, d) A floating point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in
the d parameter. This syntax is deprecated in MySQL 8.0.17, and it will be removed in future MySQL versions

FLOAT(p) A floating point number. MySQL uses the p value to determine whether to use FLOAT or DOUBLE for the resulting data type. If p is from
0 to 24, the data type becomes FLOAT(). If p is from 25 to 53, the data type becomes DOUBLE()

DOUBLE(size, d) A normal-size floating point number. The total number of digits is specified in size. The number of digits after the decimal point is
specified in the d parameter
DOUBLE
PRECISION(size, d)
DECIMAL(size, d) An exact fixed-point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in
the d parameter. The maximum number for size is 65. The maximum number for d is 30. The default value for size is 10. The default
value for d is 0.
DEC(size, d) Equal to DECIMAL(size,d)
Date and Time Data Types

Data type Description


DATE A date. Format: YYYY-MM-DD. The supported range is from '1000-01-01' to '9999-12-31'

DATETIME(fsp) A date and time combination. Format: YYYY-MM-DD hh:mm:ss. The supported range is from '1000-01-01 00:00:00' to '9999-
12-31 23:59:59'. Adding DEFAULT and ON UPDATE in the column definition to get automatic initialization and updating to
the current date and time

TIMESTAMP(fsp) A timestamp. TIMESTAMP values are stored as the number of seconds since the Unix epoch ('1970-01-01 00:00:00' UTC).
Format: YYYY-MM-DD hh:mm:ss. The supported range is from '1970-01-01 00:00:01' UTC to '2038-01-09 03:14:07' UTC.
Automatic initialization and updating to the current date and time can be specified using DEFAULT CURRENT_TIMESTAMP
and ON UPDATE CURRENT_TIMESTAMP in the column definition

TIME(fsp) A time. Format: hh:mm:ss. The supported range is from '-838:59:59' to '838:59:59'

YEAR A year in four-digit format. Values allowed in four-digit format: 1901 to 2155, and 0000.
MySQL 8.0 does not support year in two-digit format.

You might also like