Chapter 12 Introducing Databases. Objectives What a database is and which databases are typically used with ASP.NET pages What SQL is, how it looks, and.

Slides:



Advertisements
Similar presentations
Chapter 4 Joining Multiple Tables
Advertisements

Introduction to Structured Query Language (SQL)
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Introduction to Structured Query Language (SQL)
30-Jun-15 SQL A Brief Introduction. SQL SQL is Structured Query Language Some people pronounce SQL as “sequel” Other people insist that only “ess-cue-ell”
Introduction to Structured Query Language (SQL)
Concepts of Database Management Sixth Edition
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ 1 Xiang Lian The University of Texas – Pan American Edinburg, TX 78539
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
CSCI 6962: Server-side Design and Programming
Session 5: Working with MySQL iNET Academy Open Source Web Development.
ASP.NET Programming with C# and SQL Server First Edition
Advanced Database Management System Lab no. 11. SQL Commands (for MySQL) –Update –Replace –Delete.
CHAPTER 7 Database: SQL, MySQL. Topics  Introduction  Relational Database Model  Relational Database Overview: Books.mdb Database  SQL (Structured.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Chapter 15: Using LINQ to Access Data in C# Programs.
Web Services Week 8 Aims: –Using web services as front ends to databases Objectives: –Review of relational databases –Connecting to and querying databases.
Introduction to databases and SQL. What is a database?  A database is an organized way of holding together pieces of information  A database refers.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
SQL 101 for Web Developers 14 November What is a database and why have one? Tables, relationships, normalization SQL – What SQL is and isn’t – CRUD:
Chapter 11 – Introduction to Databases Dr. Stephanos Mavromoustakos.
Relational Databases Database Driven Applications Retrieving Data Changing Data Analysing Data What is a DBMS An application that holds the data manages.
Structure Query Language SQL. Database Terminology Employee ID 3 3 Last name Small First name Tony 5 5 Smith James
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
Database Connectivity with ASP.NET. 2 Introduction Web pages commonly used to: –Gather information stored on a Web server database Most server-side scripting.
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
1 Working with MS SQL Server Beginning ASP.NET in C# and VB Chapter 12.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
Introduction to Database Programming with Python Gary Stewart
2 Copyright © 2008, Oracle. All rights reserved. Building the Physical Layer of a Repository.
 MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications.
ASP.NET Programming with C# and SQL Server First Edition
INTRODUCTION TO DATABASES (MICROSOFT ACCESS)
Fundamentals of DBMS Notes-1.
Web Systems & Technologies
Visual Basic 2010 How to Program
© 2016, Mike Murach & Associates, Inc.
 2012 Pearson Education, Inc. All rights reserved.
JDBC.
Database Management  .
ISC440: Web Programming 2 Server-side Scripting PHP 3
SQL 101.
Structured Query Language (SQL) William Klingelsmith
Chapter 7 Working with Databases and MySQL
Chapter 8 Working with Databases and MySQL
CIS16 Application Programming with Visual Basic
Chapter 22 - SQL, MySQL, DBI and ADO
Chapter # 7 Introduction to Structured Query Language (SQL) Part II.
Access: SQL Participation Project
Data Management Innovations 2017 High level overview of DB
Introduction To Structured Query Language (SQL)
Presentation transcript:

Chapter 12 Introducing Databases

Objectives What a database is and which databases are typically used with ASP.NET pages What SQL is, how it looks, and how you use it to manipulate data What database relationships are and why they are important Which tools you have available to manage database objects (such as tables) and how to use them

Databases A database is a collection of data that can usually by accessed and queried. The most popular databases are relational databases, in which data is arranged in tables which store rows of data across columns. You can query the data using SQL (Structured Query Language) statements. Other types exist, including flat-file, NoSQL, object-relational, and object- oriented databases, but these are less common in Internet applications.

Relational Databases Information is stored across tables, which are composed of columns.

Relational Databases You can use many different kinds of databases in your ASP.NET projects, including Microsoft Access, SQL Server, Oracle, SQLite, and MySQL. However, the most commonly used database in ASP.NET websites is probably Microsoft SQL Server. ASP.NET can directly plug into a database to be able to save your data from your web forms.

SQL Express SQL Express is Microsoft’s free version of the database that can be installed locally. SQL Server 2016 link After you install the database, you can connect to the DB server with your windows account

SQL Express Once you have logged in, create a database by right clicking on the Databases tab and choose “New Database”.

SQL Express Change the Database name to whatever you want to call your database.

SQL Express You can now expand the Databases tab and you should see your new database created. You can click on File -> New Query and a Query Window will open

Retrieving and Manipulating Data with SQL Most of the Data operation performed by the website are known as C.R.U.D. Create Read Update Delete To Select data, you use the select statement to retrieve a rowset (rows) SELECT ColumnName [, OtherColumnNames] FROM TableName You can filter your data by using the WHERE clause SELECT Id FROM Genre WHERE Name = 'Grunge'

Retrieving and Manipulating Data with SQL WHERE clause operators

Retrieving and Manipulating Data with SQL You can ORDER your result set by using ORDER BY SELECT Id, Name FROM Genre ORDER BY Name Because ascending is the default order, you don’t need to specify the ASC keyword explicitly, although you could if you wanted to. The next example is functionally equivalent to the preceding example: SELECT Id, Name FROM Genre ORDER BY Name ASC If you wanted to return the same rows but sort them in reverse order on their Name column, you use this syntax: SELECT Id, Name FROM Genre ORDER BY Name DESC

Joining Data To bring in data from two tables, you need to join them by a particular column. The basic syntax for a JOIN looks like the following bolded code: SELECT SomeColumn FROM LeftTable INNER JOIN RightTable ON LeftTable.SomeColumn = RightTable.SomeColumn An inner join will bring in the records that can join by the join columns. Anything that doesn’t join by that column would be discarded.

Joining Data: Outer Join The OUTER JOIN enables you to retrieve rows from one table regardless of whether they have a matching row in another table. The following example returns a list with all the genres in the system together with the reviews in each genre: SELECT Genre.Id, Genre.Name, Review.Title FROM Genre LEFT OUTER JOIN Review ON Genre.Id = Review.GenreId

Creating Data To create data, first you must create a table to hold the data. You msut specify the columns and the data types. To insert data into the table, you use the Insert statement. INSERT INTO TableName (Column1 [, Column2]) VALUES (Value1 [, Value2]) If we wanted to insert data into the Genre table, the command would be as follows: INSERT INTO Genre (Name, SortOrder) VALUES ('Tribal House', 20)

Updating Data To update data in a table, you use the UPDATE statement: UPDATE TableName SET Column1 = NewValue1 [, Column2 = NewValue2] WHERE Column3 = Value3 With the UPDATE statement, you use Column = Value constructs to indicate the new value of the specified column. You can have as many of these constructs as you want, with a maximum of one per column in the table. To limit the number of items that get updated, you use the WHERE clause, just as with selecting data as you saw earlier. Without a WHERE clause, all rows will be affected which is usually not what you want. UPDATE Genre SET Name = 'Trance', SortOrder = 5 WHERE Id = 13

Delete Data To Delete Data, use the Delete statement DELETE FROM Genre WHERE Id = 13 This statement delete rows of information. There is no need to choose columns. Leaving out the WHERE clause will delete all the rows.

Creating Tables Your can create tables using the Table Designer. In management studio, you can click on the Tables folder in your database and choose “New Table” You can fill out the table and specify Each column’s name, data type and if It allows null.

Creating Tables Create a table with the designer.

Data Types for Columns

Primary Keys and Identities A primary key is a column that uniquely identifies the row. An identity column is a numeric column whose sequential values are generated automatically whenever a new row is inserted. They are often used as the primary key for a table.

Creating Relationships between tables You can create relationships between the primary key of one table and a column in another table. This relationship, known as a foreign key, This will protect records from being deleted if they are related to existing records in the referring table. On the table designer, you can go to relationships and click Add.

Creating Relationships between tables You can specify the table that form the Foreign Key relationship here.

Creating Relationships between tables When you create a relationship between two tables, the database will enforce this relationship when you try to insert, update, or delete data. For example: rows in the Review table have a genre that exists in the Genre table. When you try to delete a row from the Genre table, the database sees that the genre is used by a row in the Review table and cancels the delete operation.

Summary In this chapter we covered: Learned what a database is and which databases are typically used with ASP.NET pages Learned SQL is, how it looks, and how you use it to manipulate data Learned what database relationships are and why they are important Which tools you have available to manage database objects (such as tables) and how to use them