cis 451: asp.net & databases dr. ralph d. westfall february, 2009
TRANSCRIPT
![Page 1: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/1.jpg)
CIS 451: ASP.NET & Databases
Dr. Ralph D. WestfallFebruary, 2009
![Page 2: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/2.jpg)
What Is a Database? "shared collection of logically
related data" "designed to meet needs of
multiple users" McFadden & Hofer, 1994
![Page 3: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/3.jpg)
Database Advantages less redundant than separate
application files consistency of data integration of data data sharing easier application development scalability e.g., Oracle product line
![Page 4: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/4.jpg)
Databases Advantages - 2 better security, privacy, integrity
controls standardization e.g., field names data accessibility and
responsiveness data independence reduced program maintenance
e.g., centralized validation
![Page 5: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/5.jpg)
Database Advantages - 3 more efficient technology than most
"third generation" application programs powerful code to access items, search
and sort data storage optimization (disk,
memory) efficient updating: add, change, delete
![Page 6: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/6.jpg)
Databases - Disadvantages use more resources than file-based
systems hardware, software
require specialized personnel potential data access conflicts
operations vs. data mining potential organizational conflicts incompatibilities between
database systems
![Page 7: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/7.jpg)
Universal Data Access ODBC: open database connectivity
standard API for accessing relational databases
API = application programming interface
"drivers" for Access, dBase, DB2, Excel, text, etc.
Microsoft is a leading ODBC backer and ships its own version with Windows
![Page 8: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/8.jpg)
Universal Data Access - 2 OLE-DB: DB object linking &
embedding accesses relational databases through
ODBC accesses other data also
files, spreadsheets, e-mail, video, voice, images, web pages, object databases, etc.
data is accessed "in place" (no need to load into a database)
![Page 9: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/9.jpg)
OLE-DB Concepts data store = "persistent" collection
of data data provider = gets data from data
store OLE-DB "driver" for database, email
data, etc. data consumer = application that
uses data ADO.NET (ActiveX Data Object)
interfaces to data store through OLE-DB
![Page 10: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/10.jpg)
ADO.NET ADO stands for ActiveX Data
Objects part of Microsoft's OLEDB strategy to
enable programs to almost any kind of data on a computer
provides objects to easily connect to a variety of data sources
databases, mail servers, http servers, Excel documents, etc.
![Page 11: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/11.jpg)
Using Databases with Internet web browser interface very easy to use
compatible with all kinds of hardware Internet is global low cost delivery to large # of users multimedia capabilities ASP.NET can access data through ADO
and OLE-DB for web applications
![Page 12: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/12.jpg)
ADO.NET Model Objects Connection: to a specific file or
server Command: holds/runs SQL/other
text to query/update data, call stored procedures, etc.
DataReader: high-speed, limited function interface between database and application
![Page 13: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/13.jpg)
ADO.NET Model Objects - 2 Data Adapter
uses SQL commands to transfer data back and forth between the application and the database
DataSet not connected to database
but data can be changed and uploaded
contains one or more DataTables can "join" multiple tables in DataSet
![Page 14: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/14.jpg)
ADO.NET Model Objects - 3 DataTables have the following:
DataRowCollection - rows DataColumnCollection - fields DataView - use this if need to sort
data that is used as a datasource for an object e.g., a datagrid
![Page 15: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/15.jpg)
Database Design determine functional requirements identify data required for
applications organize the data
tables (usually normalized) relationships between tables
identify business rules (middle tier) design queries and applications
![Page 16: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/16.jpg)
Key Fields each row in a table is uniquely
identified by one or more key field(s)ID# Name City322 Karim Pomona
Dr# Patient# Appointment397 0246875 10/24/00 2 PM 'key field(s) underlined
![Page 17: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/17.jpg)
Rules for Tables in a Database all items in each table should relate to one
main topic or subject, on a one-to-one basis employees: SS#, Name, Address, Hourly Pay paychecks: SS#, Date, Pay Amount
tables should be "normalized" (2NF or more) no repeated information no fields that may be intentionally empty no fields with data that can be calculated
(derived) from other fields
![Page 18: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/18.jpg)
Normalization splitting tables to avoid problems
avoid duplicated data and empty cells avoid problems: add, change or delete
dataSID Name GWE Class Quarter Grade
322 Ana No C101 F99 pass
322 Ana No C234 S00 A use 2 tables instead
1-SID, Name, GWE; 2-SID, Class, Quarter, Grade
![Page 19: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/19.jpg)
Normalization - 2 library has borrowers, books, circulation
put circulation in borrowers file? repeating patron data for every checked out
bookBorrower#, Name, Address, Book# or repeating (often empty) columnsBorrower#, Name, Address, Bk#1, Bk#2, etc.
normalize: separate borrowers, circulationBook #, Title, Author, Year, etc.
Patron#, Name, Address, etc.
Patron#, Book#, Due Date
![Page 20: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/20.jpg)
Specialized Normalized Tables "parent-child tables"
building: name, address, land area floor: #, common (non-rentable) area
room: #, square feet parent table has family name, address
family member table has first names, DOB, gender
"lookup table" zip, city, state
zip code "determines" city and state data storage only needs zip
Cerritos mail used to be addressed to Artesia
![Page 21: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/21.jpg)
Denormalization sometimes more efficient to not
completely normalize all tables less normalization can increase
efficiency and possibly reduce number of tables
e.g., 1 customer table with fields for 2 voice phone numbers
only need to update 1 table don't need to do a join to get all phone
#s
![Page 22: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/22.jpg)
Denormalization - 2 "do not store data in a table if it can
be calculated from other data" e.g., total field (in a separate table) but with a total field don't need to total
a large # of records every time need a total
but do need extra code to update totals when records are added, changed or deleted (as in a "getter" in OO code)
![Page 23: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/23.jpg)
Indexes data is added to database in random order more efficient processing for searches and
sorting (less efficient for adding data) index table has sort order (stores position)
Data File Order Index/OrderJose (1) 1 (4)Phuong (2) 2 (3)Gunther(3) 3 (1)Ahmed (4) 4 (2)
![Page 24: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/24.jpg)
Creating a Database or Table using SQL commands with ADO in
VB.NET using VB.NET Server Explorer using SQL Server Management
Studio using "3rd party" programs
similar to Server Explorer approach or more sophisticated
![Page 25: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/25.jpg)
Creating a Database in Access Access 2003 new database options
Design View user needs to type in Field Name,
select Data Type, input Field Size and other properties
wizard that provides common templates entering data manually
uses default settings (like a spreadsheet)
![Page 26: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/26.jpg)
Create Database in Access - 2 could use File>Get External
Data>Import to pull in data from a file, other databases, spreadsheets, etc. could go into a new table, or be added
to an existing table need to set field properties when
bringing in data to a new table e.g., Field Name, Data Type, etc.
![Page 27: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/27.jpg)
SQL Server and Express Microsoft's SQL Server is designed to
handle very large scale applications more security, transaction logging , stored
procedures, very many users, etc. MSDE (Microsoft Data Engine) is the
software that runs SQL Server database the "engine" in Access is Jet 4.0 (currently) but Access can read/write MSDE databases
![Page 28: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/28.jpg)
Create SQL Server Express DB install SSE 2008 load external data as with SQL
Server Management Studio
![Page 29: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/29.jpg)
Using Server Explorer with SSE
View>Server Explorer in VB.NET click Servers>SQL Servers right click server that ends with \
NETSDK click (expand) new database right click Tables>New Table
![Page 30: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/30.jpg)
Using Server Explorer to Create SQL Server Express Database
add fields to master type in Column Name type/select Type, Length, etc. File>Close or right click tab>Close
after enter last field File>Save Table1 and replace name
in Choose Name input box
![Page 31: CIS 451: ASP.NET & Databases Dr. Ralph D. Westfall February, 2009](https://reader034.vdocuments.site/reader034/viewer/2022051316/56649e9e5503460f94b9fb2b/html5/thumbnails/31.jpg)
Stored Procedures code to manipulate database (retrieve data,
add, change, delete) stored in database like subroutine, can use in multiple
programs (but not with Access database) less storage: once instead of multiple
copies easier to update than multiple copies stored queries run faster inside database easier to migrate to other platforms or
scale up to larger volumes