C H A P T E R 4 Designing Database E-Commerce Hassanin M. Al-Barhamtoshy

Slides:



Advertisements
Similar presentations
Information Systems Today: Managing in the Digital World
Advertisements

Access - Project 1 l What Is a Database? –A Collection of Data –Organized in a manner to allow: »Access »Retrieval »Use of That Data.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
CSE 190: Internet E-Commerce Lecture 10: Data Tier.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
DT211 Stage 2 Databases Lab 1. Get to know SQL Server SQL server has 2 parts: –A client, running on your machine, in the lab. You access the database.
Concepts of Database Management Sixth Edition
Chapter 4: Database Management. Databases Before the Use of Computers Data kept in books, ledgers, card files, folders, and file cabinets Long response.
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
Data Model Examples USER SPECIFICATIONS.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
Structured Query Language SQL: An Introduction. SQL (Pronounced S.Q.L) The standard user and application program interface to a relational database is.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
CIS 270—App Dev II Big Java Chapter 22 Relational Databases.
CSCI 6962: Server-side Design and Programming
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Creating databases for web applications
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
Food Recall System Pre Code System Design Layout Version 1.0.
WNS1.com Online Training How to use the Western Nevada Supply online store and tools.
Access 2007 Database Application Managing Business Information Effectively BCIS 1 and 2.
ASP.NET Programming with C# and SQL Server First Edition
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
SQL in Action Amit Bhawnani & Nimesh Shah. Basic Structure SQL is based on set and relational operations with certain modifications and enhancements A.
Creating databases for web applications SQL. Systems design. ER diagrams. Data flow diagrams. Storyboards. Homework: Plan database and applications for.
Concepts of Database Management, Fifth Edition Chapter 4: The Relational Model 3: Advanced Topics.
Chapter 4 The Relational Model 3: Advanced Topics Concepts of Database Management Seventh Edition.
Databases in Visual Studio. Database in VisualStudio An MS SQL database are built in Visual studio The Name can be something like ”(localdb)\Projects”
Creating a Web Site to Gather Data and Conduct Research.
Your Name Here See Page Notes for Info about Hyperlinks.
SHOPPING CARTS CHAPTER 19. E-COMMERCE Typically, an e-commerce site will have public pages and admin pages.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
Installing and Using MySQL and phpMyAdmin. Last Time... Installing Apache server Installing PHP Running basic PHP scripts on the server Not necessary.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
What is a Database? A Database is…  an organized set of stored information usually on one topic  a collection of records  a way to organize information.
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
Microsoft Access 2000 Presentation 1 The Basics of Access.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting MySQL – Inserting Data.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
Database Basics BCIS 3680 Enterprise Programming.
Information Systems Today: Managing in the Digital World TB3-1 3 Technology Briefing Database Management “Modern organizations are said to be drowning.
Chapter 10 Database Management. Data and Information How are data and information related? p Fig Next processing data stored on disk Step.
Connecting (relating) Data Tables to get Custom Records (Queries) Database Basics.
1 Introduction to Database Systems CSE 444 Lecture 04: SQL April 7, 2008.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
Introduction to MySQL Ullman Chapter 4. Introduction MySQL most popular open-source database application Is commonly used with PHP We will learn basics.
IMS 4212: Constraints & Triggers 1 Dr. Lawrence West, Management Dept., University of Central Florida Stored Procedures in SQL Server.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
Notes: **A Row is considered one Record. **A Column is a Field. A Database is…  an organized set of stored information usually on one topic  a collection.
Database (Microsoft Access). Database A database is an organized collection of related data about a specific topic or purpose. Examples of databases include:
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
DAY 20: ACCESS CHAPTERS 5, 6, 7 Larry Reaves October 28,
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.
Databases.
Chapter 5 Introduction to SQL.
SQL and SQL*Plus Interaction
Information Systems Today: Managing in the Digital World
Current outstanding balance
Review of Main Database Features
CIS 336 str Competitive Success/snaptutorial.com
CIS 336 str Education for Service- -snaptutorial.com.
CIS 336 str Teaching Effectively-- snaptutorial.com.
Chapter 8 Working with Databases and MySQL
Presentation transcript:

C H A P T E R 4 Designing Database E-Commerce Hassanin M. Al-Barhamtoshy

How This Chapter Is Structured The main topics we’ll touch on in this chapter are: 1.Analyzing the requirement of the database and the functionality it should support 2.Creating the database structures for the application 3.Implementing the business tier objects required to make the system run, and putting a basic but functional error-handling strategy in place 4.Implementing a functional UI for the system

What Does a Product Catalog Look Like?  We need the following file entities:  Products  Categories  Customers  Orders

Database Designing The major tables in e-Commerce database, as the following: 1- Products Table Name Category Name Description Vendor name Vendor address Vendor phone number Price Image file name

Database Designing 2- Category Name 3- Customers Last Name First Name Address City State Zip Code Phone Number Credit Card Number

Database Designing 4- Order Order number Date Customer Product Quantity Price Subtotal Shipping Tax Total

After the key columns have been added, the list looks like this: Products Product ID (primary key) Name Category ID (foreign key) Category Name Description Price Image file name Vendor ID (foreign key) Vendor Vendor ID (primary key) Name Address City State Zip Code Phone Number

Category Category ID (primary key) Name Customers Last Name First Name Address City State Zip Code Phone Number (primary key) Credit Card Number Order Order number (primary key) Date

Order Order number (primary key) Date Customer ID (foreign key) Product ID (foreign key) Quantity Price Subtotal Shipping Tax Total

Entity Relation Database

Building a Product Catalog Application This application’s user interface has just three pages: 1.Default.aspx displays a list of products for a category selected by the user. 2.Product.aspx displays details about a specific product selected by the user. 3.Cart.aspx is displayed when the user chooses to purchase a product.

The user interface for the Product Catalog application.

The Product List page.

The Product Detail page.

The Cart page

Designing the Product Database It consists of three tables: Categories Products FeaturedProducts

The Categories table

The Products table

The Featured Products table

Creating the database sqlcmd -S localhost\SQLExpress -i CreateProducts.sql The CreateProducts.sql script USE master GO IF EXISTS(SELECT * FROM sysdatabases WHERE name=’Products’) DROP DATABASE Products GO CREATE DATABASE Products ➝ 3 ON (NAME= Product, FILENAME= ‘C:\APPS\Products.mdf’, SIZE=10 ) GO

Creating the database USE Products GO CREATE TABLE Categories ( catid VARCHAR(10) NOT NULL, name VARCHAR(50) NOT NULL, [desc] VARCHAR(MAX) NOT NULL, PRIMARY KEY(catid) ) GO CREATE TABLE Products (productid VARCHAR(10) NOT NULL, catid VARCHAR(10) NOT NULL, name VARCHAR(50) NOT NULL, shorttext VARCHAR(MAX) NOT NULL, longtext VARCHAR(MAX) NOT NULL, price MONEY NOT NULL, thumbnail VARCHAR(40) NOT NULL, image VARCHAR(40) NOT NULL, PRIMARY KEY(productid), FOREIGN KEY(catid) REFERENCES Categories(catid) ) GO

Creating the database CREATE TABLE FeaturedProducts ( productid VARCHAR(10) NOT NULL, featuretext VARCHAR(MAX) NOT NULL, saleprice MONEY NOT NULL, PRIMARY KEY(productid), FOREIGN KEY(productid) REFERENCES Products(productid) ) GO

Adding Logic to the Site The following paragraphs describe the highlights of this script: 1.Sets the database context to master. This is usually the default context, but it’s a good idea to set it just in case. 2.Deletes the existing Products database if it exists. 3.Creates a database named Products. The database file will be created in the C:\Apps directory. You should change this location if you want to place the database file in a different folder. 4.Creates the Categories table. 5.Note that the column name desc is a SQL keyword, so it must be enclosed in brackets. 6.Creates the Products table. 7.Creates the FeaturedProducts table.

sqlcmd -S localhost\SQLExpress -i InsertProducts.sql Once again, you’ll need to change the server name if you’re not running SQL Server Express on your own computer. You’ll know the script works if you see a series of messages like this one: (1 rows affected) Adding some test data

The application must perform the following queries: 1.Retrieve all rows from the Categories table to fill the drop-down list on the Default.aspx page so the user can select a product. 2.Retrieve all rows from the FeaturedProducts table to display at the top of the Default.aspx page. Note that some data is also required from the Products table, so this query requires a join. 3.Retrieve all products for a given category, including the sale price indicated in the FeaturedProducts table. 4.Retrieve all data for a specified product to display on the Product.aspx page. Note that this query must also retrieve the sale price from the FeaturedProducts table. Querying the database

The query to retrieve all rows from the Categories table uses this SQL statement: SELECT catid, name, [desc] FROM Categories ORDER BY name Querying the database

The query to retrieve the featured product rows requires a join to retrieve data from the FeaturedProducts table as well as the Products table: SELECT FeaturedProducts.productid, FeaturedProducts.featuretext, FeaturedProducts.saleprice, Products.name, Products.price FROM FeaturedProducts INNER JOIN Products ON FeaturedProducts.productid = Products.productid Querying the database

The query to retrieve the products for a given category also requires a join: SELECT Products.productid, Products.catid, Products.name, Products.shorttext, Products.longtext, Products.price, Products.image, Products.thumbnail, FeaturedProducts.saleprice FROM Products LEFT OUTER JOIN FeaturedProducts ON Products.productid = FeaturedProducts.productid WHERE (Products.catid Querying the database

The last query used by the program retrieves the data for a specific product: SELECT Products.productid, Products.catid, Products.name, Products.shorttext, Products.longtext, Products.price, Products.image, FeaturedProducts.saleprice, FeaturedProducts.featuretext FROM Products LEFT OUTER JOIN FeaturedProducts ON Products.productid = FeaturedProducts.productid WHERE (Products.productid Querying the database

The connection string used to access the Products database is stored in the application’s web.config file, like this: <add name=”ConnectionString” connectionString=”Data Source=localhost\SQLExpress; Initial Catalog=Products;Integrated Security=True”/> Connecting to the database

The last query used by the program retrieves the data for a specific product: SELECT Products.productid, Products.catid, Products.name, Products.shorttext, Products.longtext, Products.price, Products.image, FeaturedProducts.saleprice, FeaturedProducts.featuretext FROM Products LEFT OUTER JOIN FeaturedProducts ON Products.productid = FeaturedProducts.productid WHERE (Products.productid Querying the database

Downloading the Code Once you download the code, just decompress it with your favorite compression tool. Alternately, you can go to the main Wrox code download page at: to see the code available for this book and all other Wrox books. You can also download the examples from the Wrox Books Web site at: WileyCDA/WileyTitle/productCd html

Quiz # 2 Design an ERD (Entity Relation Database) for e-Learning Application), includes the following: E-Learning Table names. Tables Structure. Tables Relation.