710 likes | 822 Views
Microsoft VB 2005: Reloaded, Advanced. Chapter 7 Relational Databases and SQL. Objectives. Discuss the structure of a client/server system Explain how data are stored in a relational database Create queries using the structured query language (SQL)
E N D
Microsoft VB 2005: Reloaded, Advanced Chapter 7 Relational Databases and SQL
Objectives • Discuss the structure of a client/server system • Explain how data are stored in a relational database • Create queries using the structured query language (SQL) • Execute queries on a database using Microsoft Access and Microsoft SQL Server • Create a database using Microsoft SQL Server Microsoft VB 2005: Reloaded, Advanced
Overview of Data, Systems, and ADO.NET • Objective • Understand how data are usually organized and how information systems interact with data Microsoft VB 2005: Reloaded, Advanced
Data • Data • Plural of the word “datum” • Single item of factual knowledge obtained from measurement or observation • An entire collection of factual knowledge • Data can be stored in a computer file for use by a computer-based application Microsoft VB 2005: Reloaded, Advanced
Data (continued) Microsoft VB 2005: Reloaded, Advanced
Data (continued) Microsoft VB 2005: Reloaded, Advanced
Information • Information • Represents knowledge obtained by processing data Microsoft VB 2005: Reloaded, Advanced
Information (continued) Microsoft VB 2005: Reloaded, Advanced
Data Files • Record • A complete set of data • Field • A space reserved for a datum • Flat files • Contain only simple records and fields • That could be written on a flat (two-dimensional) piece of paper Microsoft VB 2005: Reloaded, Advanced
Data Files (continued) Microsoft VB 2005: Reloaded, Advanced
Databases and Database Management Systems • Data store • Any organized collection of data • Database • Data store that has a special structure for facilitating storage, retrieval, and manipulation of the data • Database management system (DBMS) • The software used to create and access a database • Relational database • Database that follows the relational model • Most popular type of database in use today Microsoft VB 2005: Reloaded, Advanced
Databases and Database Management Systems (continued) • Relational model • A way of organizing data in related tables based on strict mathematical principles • Relational database management system • Creates and manages a relational database • Client/server system • System in which software is distributed across networked hardware components consisting of: • Clients that send requests for services • A server that provides responses to the requests Microsoft VB 2005: Reloaded, Advanced
Databases and Database Management Systems (continued) Microsoft VB 2005: Reloaded, Advanced
Databases and Database Management Systems (continued) • Client/server system (continued) • Clients store the application and the server stores the database • Database server • Server that stores the database and DBMS • Server software components • Network operating system • The DBMS • Client software components • Application software • Data access API Microsoft VB 2005: Reloaded, Advanced
Databases and Database Management Systems (continued) Microsoft VB 2005: Reloaded, Advanced
Databases and Database Management Systems (continued) • Client/server system (continued) • Data access application programming interface (API) • Software that provides an interface between the application and the database • ADO and ADO.NET • ADO.NET • A data access API • Part of the .NET Framework • Before ADO.NET existed, there was ADO Microsoft VB 2005: Reloaded, Advanced
Databases and Database Management Systems (continued) • ADO and ADO.NET (continued) • ADO.NET advantages • Ability to work with data represented in XML • Integration with the rest of the Microsoft .NET Framework • Increased control and flexibility in working with all types of data sources • ActiveX Data Objects (ADO) • Microsoft technology for accessing data from a wide variety of data stores • In both Windows applications and Web applications Microsoft VB 2005: Reloaded, Advanced
The Relational Database Model Microsoft VB 2005: Reloaded, Advanced
The Relational Database Model (continued) Microsoft VB 2005: Reloaded, Advanced
Tables • Data in a relational database are stored in tables • A table is a structure consisting of rows and columns • Each individual data item is placed in one cell • An intersection of a row and a column • Each row in a table represents a data record • Each column in a table represents a data field Microsoft VB 2005: Reloaded, Advanced
Tables (continued) Microsoft VB 2005: Reloaded, Advanced
Primary Keys • Each record in a table must be uniquely identified • Primary key • One or more fields in a database table that, taken in combination, form a unique value • Uniquely identify a record Microsoft VB 2005: Reloaded, Advanced
Relationships • The power of a relational database lies in the relationships between tables • Each table in a relational database should represent only one kind of entity • Should contain only the fields that are absolutely essential for describing that entity • Entity-relationship diagram • Pictorial representation of the entities (tables), the entity attributes (fields), and the relationships between the entities in a relational database Microsoft VB 2005: Reloaded, Advanced
Relationships (continued) Microsoft VB 2005: Reloaded, Advanced
Relationships (continued) • Foreign key • A primary key of one table included as a field of another table • Cardinality of a relationship between Tables A and B • Number of rows in Table B that can be associated with each row in Table A • Symbol “1” represents one element • Symbol “∞” represents many elements Microsoft VB 2005: Reloaded, Advanced
Relationships (continued) Microsoft VB 2005: Reloaded, Advanced
Structured Query Language • Structured query language (SQL) • Standard language used to store, retrieve, and manipulate data within a relational database Microsoft VB 2005: Reloaded, Advanced
The SELECT Statement • Query • Set of instructions for extracting data from a database Microsoft VB 2005: Reloaded, Advanced
The SELECT Statement (continued) Microsoft VB 2005: Reloaded, Advanced
The SELECT Statement (continued) Microsoft VB 2005: Reloaded, Advanced
The WHERE Clause Microsoft VB 2005: Reloaded, Advanced
The WHERE Clause (continued) Microsoft VB 2005: Reloaded, Advanced
The ORDER BY Clause Microsoft VB 2005: Reloaded, Advanced
The ORDER BY Clause (continued) Microsoft VB 2005: Reloaded, Advanced
Merging Data with INNER JOIN • Inner join • Derives information from two or more tables Microsoft VB 2005: Reloaded, Advanced
Merging Data with INNER JOIN (continued) Microsoft VB 2005: Reloaded, Advanced
Merging Data with INNER JOIN (continued) Microsoft VB 2005: Reloaded, Advanced
Merging Data with INNER JOIN (continued) Microsoft VB 2005: Reloaded, Advanced
Merging Data with INNER JOIN (continued) Microsoft VB 2005: Reloaded, Advanced
Merging Data with INNER JOIN (continued) Microsoft VB 2005: Reloaded, Advanced
The INSERT Statement • Adds data into a database Microsoft VB 2005: Reloaded, Advanced
The INSERT Statement (continued) Microsoft VB 2005: Reloaded, Advanced
The INSERT Statement (continued) Microsoft VB 2005: Reloaded, Advanced
The UPDATE Statement • Changes the contents of existing records Microsoft VB 2005: Reloaded, Advanced
The UPDATE Statement (continued) Microsoft VB 2005: Reloaded, Advanced
The DELETE Statement • Deletes rows from a table Microsoft VB 2005: Reloaded, Advanced
The DELETE Statement (continued) Microsoft VB 2005: Reloaded, Advanced
Executing SQL Statements in Microsoft Access Microsoft VB 2005: Reloaded, Advanced
Using Microsoft SQL Server 2005 • SQL Server • Relational database management system (RDBMS) • Microsoft SQL Server 2005 Express Edition • Available for free at: http://msdn.microsoft.com/vstudio/express/sql/ Microsoft VB 2005: Reloaded, Advanced
Using Microsoft SQL Server 2005 (continued) Microsoft VB 2005: Reloaded, Advanced