Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 CPE 332 Introduction DBMS: Relational Database Managment Systems Instructor:Suthep Madarasmi, Ph.D. ดร. สุเทพ มาดารัศมี

Similar presentations


Presentation on theme: "1 CPE 332 Introduction DBMS: Relational Database Managment Systems Instructor:Suthep Madarasmi, Ph.D. ดร. สุเทพ มาดารัศมี"— Presentation transcript:

1 1 CPE 332 Introduction DBMS: Relational Database Managment Systems Instructor:Suthep Madarasmi, Ph.D. ดร. สุเทพ มาดารัศมี Email:suthep@kmutt.ac.th

2 2 Relational Databases 1.A database is a collection of related tables 2.Each table can be viewed as having many Fields (Columns) and many Records (Rows) 3.Examples of 2 tables are shown below.

3 3 Components of A Database System

4 4 Product Code Example in Application

5 5 Invoice Example in Application

6 6 Our Invoice Form Design

7 7 Invoice No. INV100/06

8 8 Invoice No. INV101/06

9 9 Examples of Data in 2 Invoices

10 10 Example of Microsoft Access

11 11 Creating a Table in MS Access 1.File  New 2.New Blank Database 3.Name the database file to Product (for example) 4.Create a new table by “New”, Choose Design View

12 12 Creating a Table in MS Access 5. Enter field names & type 6. Right click on one field to make it the primary key. 7. File  Save. Enter Name.

13 13 Create table Invoice The primary key can also be set by File  New, then enter the Index Name as PrimaryKey, Select Field Name (s). In the bottom of screen Primary Key should be “Yes”.

14 14 Create Table InvoiceLineItem The primary key in this table is made of 2 fields InvoiceNo and ProductCode.

15 15 Our Product Form Design

16 16 Data Examples for 5 Entered Products Choose Table, Click Open Enter Data Into Tables:

17 17 Examples of RDBMS Oracle Microsoft SQL (M-SQL) DB2 MS Access MySQL Each product has its own connection rules and management methods.

18 18 Role of ADO A standard is needed to allow a single application to connect to any database: -ODBC -ADO All use SQL (Structured Query Language) to communication with the RDBMS.

19 19 Examples of SQL Language List invoices in Month of August, 2006 that have more sales than 350 baht. Select InvoiceNo as No, InvoiceDate as [Date], AmountDue as Total from Invoice where InvoiceDate >= #08/01/2006# and InvoiceDate 350; RESULT:

20 20 Examples of SQL Language List number of items in each invoice sold in August 2006. Select Invoice.InvoiceNo as No, Count(*) as [Number Items] from Invoice INNER JOIN InvoiceLineItem on Invoice.InvoiceNo = InvoiceLineItem.InvoiceNo where month(InvoiceDate) = 8 and year(InvoiceDate) = 2006 group by Invoice.InvoiceNo ; RESULT:

21 21 Result of Selecting from 2 Tables Select * from Invoice, InvoiceLineItem THE RESULT IS A CROSS PRODUCT – ALL PAIRINGS in 2 Tables RESULT:

22 22 Result of JOIN RESULT OF JOIN:


Download ppt "1 CPE 332 Introduction DBMS: Relational Database Managment Systems Instructor:Suthep Madarasmi, Ph.D. ดร. สุเทพ มาดารัศมี"

Similar presentations


Ads by Google