databases mis 21. some database terminology database: integrated collection of data database...
TRANSCRIPT
![Page 1: Databases MIS 21. Some database terminology Database: integrated collection of data Database Management System (DBMS): environment that provides mechanisms](https://reader036.vdocument.in/reader036/viewer/2022082820/56649f075503460f94c1cd28/html5/thumbnails/1.jpg)
Databases
MIS 21
![Page 2: Databases MIS 21. Some database terminology Database: integrated collection of data Database Management System (DBMS): environment that provides mechanisms](https://reader036.vdocument.in/reader036/viewer/2022082820/56649f075503460f94c1cd28/html5/thumbnails/2.jpg)
Some database terminology Database: integrated collection of data Database Management System (DBMS):
environment that provides mechanisms for storage and access of data
Relational Database Model: views a database as a collection of relations or tables where each table stores information on an entity
![Page 3: Databases MIS 21. Some database terminology Database: integrated collection of data Database Management System (DBMS): environment that provides mechanisms](https://reader036.vdocument.in/reader036/viewer/2022082820/56649f075503460f94c1cd28/html5/thumbnails/3.jpg)
Tables, attributes and columns A table represents an entity in a system The rows of the table represent records or
instances of the entity The columns of the table represent the
entity’s attributes or characteristics
How do you determine a system’s entities? Spot the nouns (people, places, things) in the
system
![Page 4: Databases MIS 21. Some database terminology Database: integrated collection of data Database Management System (DBMS): environment that provides mechanisms](https://reader036.vdocument.in/reader036/viewer/2022082820/56649f075503460f94c1cd28/html5/thumbnails/4.jpg)
Example: The STUDENT table
ID LastName FirstName Year QPI
081111 Cruz Juan 2 3.5
072222 Smith John 3 2.2
089999 Cruz Maria 3 4.0
077676 Santos Linda 4 3.0
Columns/Attributes
There are four rows/records in this example
![Page 5: Databases MIS 21. Some database terminology Database: integrated collection of data Database Management System (DBMS): environment that provides mechanisms](https://reader036.vdocument.in/reader036/viewer/2022082820/56649f075503460f94c1cd28/html5/thumbnails/5.jpg)
Column types/domains Each column in a table has an associated
type indicating the possible values for the attribute
Most common types Strings: CHAR, VARCHAR Numbers: INTEGER, DOUBLE, NUMERIC Date and time: DATE, TIME, TIMESTAMP
![Page 6: Databases MIS 21. Some database terminology Database: integrated collection of data Database Management System (DBMS): environment that provides mechanisms](https://reader036.vdocument.in/reader036/viewer/2022082820/56649f075503460f94c1cd28/html5/thumbnails/6.jpg)
Primary key, foreign key, relationships Primary key: column or attribute that
uniquely determines a row in the table STUDENT table example: ID is the primary key
Foreign key: attribute in one table that refers to a record in another table Used to store relationships
(relationships are verbs in the system) Example: a department code in the EMPLOYEE
table refers to the DEPARTMENT table, signifying that the employee belongs to the department
![Page 7: Databases MIS 21. Some database terminology Database: integrated collection of data Database Management System (DBMS): environment that provides mechanisms](https://reader036.vdocument.in/reader036/viewer/2022082820/56649f075503460f94c1cd28/html5/thumbnails/7.jpg)
Relationship example
EmpID Name Salary DeptCode
123 CRUZ, JUAN 12345.00 HR
222 SANTOS, MARIA 11111.00 HR
545 MATIPID, PETE 30000.00 ACCT
DeptCode DeptName
ACCT ACCOUNTING
HR PERSONNEL
MAINT MAINTENANCE
EMPLOYEE
DEPARTMENT
Employee SANTOS, MARIAworks for thePERSONNEL department
![Page 8: Databases MIS 21. Some database terminology Database: integrated collection of data Database Management System (DBMS): environment that provides mechanisms](https://reader036.vdocument.in/reader036/viewer/2022082820/56649f075503460f94c1cd28/html5/thumbnails/8.jpg)
Structured Query Language SQL: Structured Query Language
Also called “SeQueL” Standard underlying language for database
definition, manipulation, and query SQL statements
SELECT (query) INSERT UPDATE DELETE Others (Data Definition)
![Page 9: Databases MIS 21. Some database terminology Database: integrated collection of data Database Management System (DBMS): environment that provides mechanisms](https://reader036.vdocument.in/reader036/viewer/2022082820/56649f075503460f94c1cd28/html5/thumbnails/9.jpg)
The SELECT statement A query that returns a table Simplest form:
SELECT column1, column2, … FROM table SELECT EmpID, Salary FROM EMPLOYEE
List all records, all columnsSELECT * FROM table SELECT * FROM DEPARTMENT
List particular record/sSELECT * FROM table WHERE criteria SELECT * FROM STUDENT WHERE year=3
![Page 10: Databases MIS 21. Some database terminology Database: integrated collection of data Database Management System (DBMS): environment that provides mechanisms](https://reader036.vdocument.in/reader036/viewer/2022082820/56649f075503460f94c1cd28/html5/thumbnails/10.jpg)
The WHERE clause Indicates selection criteria or condition against
which records on the table will be checked Contains operators such as <, >, <=, >= =, <>
and LIKE <> means not equal LIKE performs a pattern match with strings
( _ matches a single character, % matches several characters)
Condition may have logical operators (AND, OR, NOT) Note the importance of the column type when
specifying the condition Literal strings (e.g., CHAR) need to be delimited by
quotes or double quotes
![Page 11: Databases MIS 21. Some database terminology Database: integrated collection of data Database Management System (DBMS): environment that provides mechanisms](https://reader036.vdocument.in/reader036/viewer/2022082820/56649f075503460f94c1cd28/html5/thumbnails/11.jpg)
ORDER BY clause Can indicate ORDER BY in the SELECT
statement to specify ghe order in which the records will be listed
Syntax: appendORDER BY col1,col2,…to the SELECT statement
Indicate ORDER BY col1,col2,… DESCto list records in descending order
![Page 12: Databases MIS 21. Some database terminology Database: integrated collection of data Database Management System (DBMS): environment that provides mechanisms](https://reader036.vdocument.in/reader036/viewer/2022082820/56649f075503460f94c1cd28/html5/thumbnails/12.jpg)
More examples SELECT Name FROM EMPLOYEE
WHERE SALARY > 12000 SELECT FirstName,Lastname FROM STUDENT
WHERE LastName LIKE ‘S%’ SELECT * FROM STUDENT
WHERE year <> 2 SELECT * FROM STUDENT WHERE year=3
ORDER BY LastName, FirstName SELECT Name FROM EMPLOYEE ORDER BY Salary
![Page 13: Databases MIS 21. Some database terminology Database: integrated collection of data Database Management System (DBMS): environment that provides mechanisms](https://reader036.vdocument.in/reader036/viewer/2022082820/56649f075503460f94c1cd28/html5/thumbnails/13.jpg)
SELECT on multiple tables FROM clause can contain multiple tables Use when processing relationships Tables are joined; indicate join condition in WHERE clause Example:
SELECT Name, DeptName FROM EMPLOYEE, DEPARTMENT WHERE EMPLOYEE.DeptCode = DEPARTMENT.DeptCode
AND Salary >10000
returns all names of employees (and the name of the departments they belong to) who make more than 10000
![Page 14: Databases MIS 21. Some database terminology Database: integrated collection of data Database Management System (DBMS): environment that provides mechanisms](https://reader036.vdocument.in/reader036/viewer/2022082820/56649f075503460f94c1cd28/html5/thumbnails/14.jpg)
The INSERT Statement Inserts a record into a table Syntax:
INSERT INTO table VALUES(val1,val2,…) INSERT INTO table(col1,col2,…)
VALUES(val1,val2,…) Examples:
INSERT INTO DEPARTMENTVALUES(“CS”, “COMPUTER SCIENCE”)
INSERT INTO EMPLOYEE(EmpID, Salary)VALUES(143,10000.00)
![Page 15: Databases MIS 21. Some database terminology Database: integrated collection of data Database Management System (DBMS): environment that provides mechanisms](https://reader036.vdocument.in/reader036/viewer/2022082820/56649f075503460f94c1cd28/html5/thumbnails/15.jpg)
The UPDATE Statement Updates an existing record Syntax:
UPDATE table SET col1=expr1,col2=expr2,… UPDATE table SET col1=expr1,col2=expr2,…
WHERE criteria Examples
(updates all records)UPDATE EMPLOYEE SET Salary=Salary+100
(updates some record/s)UPDATE STUDENT SET QPI = 4.0 WHERE FirstName = “Matalino”
![Page 16: Databases MIS 21. Some database terminology Database: integrated collection of data Database Management System (DBMS): environment that provides mechanisms](https://reader036.vdocument.in/reader036/viewer/2022082820/56649f075503460f94c1cd28/html5/thumbnails/16.jpg)
The DELETE Statement Deletes records from a table Syntax:
DELETE FROM table WHERE criteria(warning: without a WHERE clause, all records are deleted)
Example DELETE FROM EMPLOYEE WHERE
DeptCode=“CS”
![Page 17: Databases MIS 21. Some database terminology Database: integrated collection of data Database Management System (DBMS): environment that provides mechanisms](https://reader036.vdocument.in/reader036/viewer/2022082820/56649f075503460f94c1cd28/html5/thumbnails/17.jpg)
Summary A relational database consists of tables
that store records of a system The database is manipulated through SQL,
the underlying query and manipulation language of relational databases
SELECT statements carry out queries INSERT, UPDATE, and DELETE statements
affect the database