Download Presentation title text

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Information Architecture & Design II
Web Databases
David Kim
David Kim
April 28 2005
1
Index











What is a Database?
File System vs. DBMS
Database Models
Database Modeling
Databases
SQL
DBC
Choosing a database
IA & DB
Conclusion
References
David Kim
April 28, 2005
2
What is a Database ?

A very large, integrated collection of data

A collection of information stored in a
computer in a systematic way

DBMS (= Database Management System)
- A software used to manage and query a
database
David Kim
April 28, 2005
3
Index











What is a Database?
File System vs. DBMS
Database Models
Database Modeling
Databases
SQL
DBC
Choosing a database
IA & DB
Conclusion
References
David Kim
April 28, 2005
4
FMS vs. DBMS
advantages
FMS
disadvantages
•
•
Simpler to use
• Less expensive
Typically no multi-user access
• Limited to smaller databases
• Limited functionality
• Decentralization of data
• Redundancy and integrity issues
DBMS
•
Greater flexibility
• Greater processing power
• Ensures data integrity
• Supports simultaneous
access
• Provides backup and
recovery controls
• Advanced security
David Kim
•
Difficult to learn
• Packaged separately from the
OS
• Slower processing speeds
• Requires skilled administrators
• Expensive
April 28, 2005
5
Index











What is a Database?
File System vs. DBMS
Database Models
Database Modeling
Databases
SQL
DBC
Choosing a database
IA & DB
Conclusion
References
David Kim
April 28, 2005
6
Database Models 1
data
modeling
capacity
Object-oriented
model (mid ’90s)
Object-relational
model (late ’90s)
Relational model
(late ’80s)
Hybrid model
(mid ’80s)
File System
(before ’70s)
data
management
facilities
* adapted from the material in http://www.ktdata.co.kr/ktdata/kthome7/zeus_5.htm
David Kim
April 28, 2005
7
Database Models 2
Database Model: a collection of logical constructs
 flat (or table) model ☞
 hierarchical model ☞
 network model ☞
 relational model ☞
 object-oriented model ☞
 object/relational (= post-relational) model ☞
David Kim
April 28, 2005
8
Index











What is a Database?
File System vs. DBMS
Database Models
Database Modeling
Databases
SQL
DBC
Choosing a database
IA & DB
Conclusion
References
David Kim
April 28, 2005
9
DB Modeling 1
ER Model
ID
Name
Is for
Order date
ORDER
Initiate
CUSTOMER
Order type
SSN
Quantity
Discount
Phone #
Birthday
has
Is included
ID
ID
Description
Is part of
ITEM
consist of
PRODUCT
Description
Type
Price
*source: www.fkii.or.kr/data/seminar/uploaded_files/ 유해진%20부장%20(액센츄어).ppt
David Kim
April 28, 2005
10
DB Modeling 2
Relational Model
ORDER
ID
Order_date (M)
Order_type (M)
ITEM
ID
Description (M)
Price (M)
PRT_ID
CUSTOMER
ORDER_ITEM
SSN
Name (M)
Phone #
Birthday
Order_ID
Item_ID
Quantity (M)
Discount
PRODUCT
ID
Description (M)
Type
*source: www.fkii.or.kr/data/seminar/uploaded_files/ 유해진%20부장%20(액센츄어).ppt
David Kim
April 28, 2005
11
Normalization 1

1st Normal Form : (No Repeating Groups)
Customer_ID
Child
Customer_ID
Children1
Comment1
….
ChildrenX
CommentX

Comment
2nd Normal Form : ( Non-key Attribute depend
on the whole primary key)
Supplier_ID
Part_No
City_Name
Supplier_Name
Part_color
Contact_Name
Contact_Phone
Part_Price
Supplier_ID
Supplier_Name
Part_No
Supplier_ID
Part_No
City_Name
Contact_Name
Contact_Phone
Part_Color
Part_Price
*adpated from www.fkii.or.kr/data/seminar/uploaded_files/ 유해진%20부장%20(액센츄어).ppt
David Kim
April 28, 2005
12
Normalization 2

3rd Normal Form : (Non-Key Attributes depend
only and fully on primary key)
Part_No
Supplier_Name
Part_color
Contact_Name
Contact_Phone
Part_Price
Part_No
Part_Color
Part_Price
Supplier_Name
Contact_Name
Supplier_Name
Contact_Name
Contact_Phone

Boyce-Codd Normal Form(BCNF)
 4NF
 5NF
*adpated from www.fkii.or.kr/data/seminar/uploaded_files/ 유해진%20부장%20(액센츄어).ppt
David Kim
April 28, 2005
13
Index











What is a Database?
File System vs. DBMS
Database Models
Database Modeling
Databases
SQL
DBC
Choosing a database
IA & DB
Conclusion
References
David Kim
April 28, 2005
14
Databases
Open source Databases
 MySQL
 PostgreSQL
Commercial Databases
 MS SQL Server
 ORACLE
 DB2
 Informix
David Kim
April 28, 2005
15
Index











What is a Database?
File System vs. DBMS
Database Models
Database Modeling
Databases
SQL
DBC
Choosing a database
IA & DB
Conclusion
References
David Kim
April 28, 2005
16
SQL
Structured Query Language: an ANSI standard computer
language for accessing and manipulating databases
 ANSI SQL: SQL Standard (SQL-92) ☞
 MySQL: MySQL Server
 Jet SQL: MS Access ☞
 T-SQL (Transact-SQL) : SQL Server ☞
 SQL*Plus, PL/SQL (Procedural Language/SQL) :
Oracle ☞
David Kim
April 28, 2005
17
Index











What is a Database?
File System vs. DBMS
Database Models
Database Modeling
Databases
SQL
DBC
Choosing a Database
IA & DB
Conclusion
References
David Kim
April 28, 2005
18
Database Providers
Data Consumer
Data Provider
ASP.NET
ADO.NET
Data Store
SQL Server
ODBC (Open Database Connectivity) ☞
 OLEDB(Object Linking and Embedding DB) ☞
 ADO.NET (ActiveX Data Objects for .NET) ☞
 JDBC (Java Database Connectivity) ☞

David Kim
April 28, 2005
19
Index











What is a Database?
File System vs. DBMS
Database Models
Database Modeling
Databases
SQL
DBC
Choosing a Database
IA & DB
Conclusion
References
David Kim
April 28, 2005
20
Choosing a Database 1






Desktop or Server Database
OS Environment
Size of the project
Flexibility
Portability
Cost/Budget
What else?
David Kim
April 28, 2005
21
Choosing a Database 2
POSTGRESQL
MYSQL
ANSI SQL compliance
Closer to ANSI SQL standard
Follows some of the ANSI SQL
standards
Performance
Slower
Faster
Sub-selects
Yes
No
Transactions
Yes
Yes, however InnoDB table
type must be used
Database replication
Yes
Yes
Foreign key support
Yes
No
Views
Yes
No
Stored procedures
Yes
No
Triggers
Yes
No
Unions
Yes
No
Full joins
Yes
No
Constraints
Yes
No
Windows support
Yes
Yes
Vacuum (cleanup)
Yes
No
ODBC
Yes
Yes
JDBC
Yes
Yes
Different table types
No
Yes
* source : www.sraapowergres.com/en/ whitepapers/postgres%20vs%20mysql.pdf
David Kim
April 28, 2005
22
Index











What is a Database?
File System vs. DBMS
Database Models
Database Modeling
Databases
SQL
DBC
Choosing a database
IA & DB
Conclusion
References
David Kim
April 28, 2005
23
IA & DB
Database Modeler - Coder - Information
Architect

IA on the whole project

Front-end UI based on the DB Modeling

Your opinion…
David Kim
April 28, 2005
24
Index











What is a Database?
File System vs. DBMS
Database Models
Database Modeling
Databases
SQL
DBC
Choosing a database
IA & DB
Conclusion
References
David Kim
April 28, 2005
25
Conclusion
DBMS is now essential:
“Information Architects should know about it!”
David Kim
April 28, 2005
26
Index











What is a Database?
File System vs. DBMS
Database Models
Database Modeling
Databases
SQL
DBC
Choosing a database
IA & DB
Conclusion
References
David Kim
April 28, 2005
27
References













Database Models: Hierarcical, Network, Relational, Object-Oriented, Semistructured,
Associative and Context.
Database Models
Normalization
eXtropia | Tutorials | Introduction to Databases for the Web | Database Models
Data Modeling: Overview of the Relational Model
DBMS - April 1998 - Modeling Object/Relational Databases
Object-Relational Model
Object-relational database articles and products
Java Database
Overview of ADO.NET
Welcome to FKII
PowerGres
ZEUS/UniSQL - Korea Telecom Data,Inc
David Kim
April 28, 2005
28
Appendix
David Kim
April 28, 2005
29
Flat Model

Spreadsheet (e.g. Excel) ☝
David Kim
April 28, 2005
30
Hierarchical Model
☝
A
B
D
D1
David Kim
C
E
F
F1
C1
C2
F2
April 28, 2005
31
Network Model
☝
Company
Customer
1
1
M
M
Product
Invoice
1
M
Payment
1
1
M
M
InvoiceLine
David Kim
April 28, 2005
32
Relational Model 1
Class ID
Class Name
Student
ID
Name
Address
1
IA&D2
1
John
Far West
2
ClassA
2
Tom
Riverside
3
ClassB
3
David
Lake Austin
David Kim
Student
ID
Class
ID
Name
Address
1
2
John
Far West
2
3
Tom
Riverside
3
1
David
Lake
Austin
April 28, 2005
33
Relational Model 2
Class ID
Class
Name
Student
ID
Name
Address
1
IA&D2
1
John
Far West
2
ClassA
2
Tom
Riverside
3
ClassB
3
David
Lake Austin
David Kim
Class ID
Student ID
1
3
2
1
3
2
April 28, 2005
☝
34
Object-Oriented Model
Class
Student
Department
studentsInDept()
studentsInClass()
printTranscript()
profInThisDept()
inherit
Grad
Student
☝
David Kim
April 28, 2005
35
Object/Relational Model
Relational
Model
Object-oriented
Model
Object-relational
Model
☝
* material from: http://www.ktdata.co.kr/ktdata/kthome7/zeus_5.htm
David Kim
April 28, 2005
36
ANSI SQL
SQL Data Manipulation Language (DML)




SELECT - extracts data from a database table
UPDATE - updates data in a database table
DELETE - deletes data from a database table
INSERT INTO - inserts new data into a database table
SQL Data Definition Language (DDL)





CREATE TABLE - creates a new database table
ALTER TABLE - alters (changes) a database table
DROP TABLE - deletes a database table
CREATE INDEX - creates an index (search key)
DROP INDEX - deletes an index
☝
David Kim
April 28, 2005
37
Jet SQL
IIF(InStr(si.GEOG_UNIT,',')<>0,MID([si.GEOG_UNIT],1,InStr([si.GE
OG_UNIT],',')-1))
$query0 .= ($state && $state != 'state_undet') ? "AND
((si.GEOG_RANK='county' AND
IIF(InStr(si.GEOG_UNIT,',')<>0,MID([si.GEOG_UNIT],1,InStr([si.GE
OG_UNIT],',')-1)) $sql_op '$state') OR (si.GEOG_RANK='province'
AND
IIF(InStr(si.GEOG_UNIT,',')<>0,MID([si.GEOG_UNIT],InStr([si.GEO
G_UNIT],',')+1)) $sql_op ' $state') OR (si.GEOG_RANK='province'
AND
IIF(InStr(si.GEOG_UNIT,',')=0,MID([si.GEOG_UNIT],InStr([si.GEOG
_UNIT],',')+1)) $sql_op '$state'))":"";
☝
David Kim
April 28, 2005
38
Stored Procedure
CREATE PROCEDURE prGet_CustomerRowSet
@sCustomerID NCHAR(5)
AS
SELECT CompanyName, ContactName, City
FROM Customers
WHERE CustomerID = @sCustomerID
GO
David Kim
☝
April 28, 2005
39
PL/SQL
DECLARE
qty_on_hand NUMBER(5);
BEGIN
SELECT quantity INTO qty_on_hand FROM inventory
WHERE product = 'TENNIS RACKET'
FOR UPDATE OF quantity;
IF qty_on_hand > 0 THEN -- check quantity
UPDATE inventory SET quantity = quantity - 1
WHERE product = 'TENNIS RACKET';
ELSE
INSERT INTO purchase_record
VALUES ('Out of tennis rackets', SYSDATE);
END IF;
COMMIT;
END;
David Kim
☝
April 28, 2005
40
ADO
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customers", conn
do until rs.EOF
for each x in rs.Fields
Response.Write(x.name)
Response.Write(" = ")
Response.Write(x.value & "<br />")
next
Response.Write("<br />")
rs.MoveNext
loop
rs.close
conn.close
%>
David Kim
☝
April 28, 2005
41
ADO.NET

Visual Basic
Dim nwindConn As SqlConnection = New
SqlConnection("Data Source=localhost;" & _ "Integrated
Security=SSPI;Initial Catalog=northwind")

C#
SqlConnection nwindConn = new SqlConnection("Data
Source=localhost;Integrated Security=SSPI;Initial
Catalog=northwind");
☝
David Kim
April 28, 2005
42
ODBC

VB
Dim nwindConn As OdbcConnection = New
OdbcConnection("Driver={SQL
Server};Server=localhost;" & _
"Trusted_Connection=yes;Database=northwind")

C#
OdbcConnection nwindConn = new
OdbcConnection("Driver={SQL
Server};Server=localhost;" +
"Trusted_Connection=yes;Database=northwind");
☝
David Kim
April 28, 2005
43
OLEDB

VB
Dim nwindConn As OleDbConnection = New
OleDbConnection("Provider=SQLOLEDB;Data
Source=localhost;" & _ "Integrated Security=SSPI;Initial
Catalog=northwind")

C#
OleDbConnection nwindConn = new
OleDbConnection("Provider=SQLOLEDB;Data
Source=localhost;Integrated Security=SSPI;Initial
Catalog=northwind");
David Kim
April 28, 2005
☝
44
JDBC
Class.forName("oracle.jdbc.driver.OracleDriver")
Connection con = DriverManager.getConnection(
"jdbc:oracle:thin:@dbaprod1:1521:SHR1_PRD",
username, passwd);
☝
David Kim
April 28, 2005
45
Related documents