Computer Science Projects Database Theory / Prototypes

Slides:



Advertisements
Similar presentations
Organisation Of Data (1) Database Theory
Advertisements

The Ribbon Standard to all Office 2007 applications Organized by feature and functionality Navigation Pane Access to all objects in the current database.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
1 Pertemuan 09 Database Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
Microsoft Access Database software. What is a database? … a database is an organized collection of data. A collection of data of similar information compiled.
From VS C# 2010 Programming, John Allwork 1 VS2010 C# Programming - DB intro 1 Topics – Database Relational - linked tables SQL ADO.NET objects Referencing.
ACCESS CHAPTER 1. OBJECTIVES Tables Queries Forms Reports Primary and Foreign Keys Relationship.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Unit J: Creating a Database Microsoft Office Illustrated Fundamentals.
ASP.NET Programming with C# and SQL Server First Edition
Concepts of Database Management Seventh Edition
Web Services Week 8 Aims: –Using web services as front ends to databases Objectives: –Review of relational databases –Connecting to and querying databases.
Chapter 17 Creating a Database.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
® Microsoft Office 2013 Access Creating a Database.
ITGS Databases.
Microsoft Access. Microsoft access is a database programs that allows you to store retrieve, analyze and print information. Companies use databases for.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
Advanced Web 2012 Lecture 3 Sean Costain What is a Database? Sean Costain 2012 A database is a structured way of dealing with structured information.
1 Chapter 20 – Data sources and datasets Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
Introduction to ADO.Net and VS Database Tools and Data Binding ISYS 350.
DataSet Your Database student test score Database Connection Your program needs to establish a connection to the database. Click on “Add New Data Source.”
Designing a Relational Database 13.4 Page A database should be created based on a design  Three steps Determine what information should be stored.
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 1 ® Database & Table.
Relational Database Management System(RDBMS) Structured Query Language(SQL)
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
1 A Very Brief Introduction to Relational Databases.
Understanding Core Database Concepts Lesson 1. Objectives.
N5 Databases Notes Information Systems Design & Development: Structures and links.
Databases: What they are and how they work
Access Tutorial 2 Building a Database and Defining Table Relationships
Fundamentals of DBMS Notes-1.
Microsoft Visual Basic 2010: Reloaded Fourth Edition
IST 220 – Intro to Databases
VB 2010 Pertemuan 10.
Working in the Forms Developer Environment
Task oriented processing
GO! with Microsoft Office 2016
Practical Office 2007 Chapter 10
SQL MODELER - OPEN There are Three Ways to open the SQL Modeler
Database application MySQL Database and PhpMyAdmin
CIS 155 Table Relationship
GO! with Microsoft Access 2016
Access Creating a Database
Database Management System
Access Creating a Database
Microsoft Access 2003 Illustrated Complete
Access Lesson 1 Understanding Access Fundamentals
ISC440: Web Programming 2 Server-side Scripting PHP 3
SQL 101.
STRUCTURED QUERY LANGUAGE
Basic Concepts in Data Management
Chapter 2 Database Environment.
MODULE 7 Microsoft Access 2010
Database Fundamentals
Teaching slides Chapter 8.
Database Management Concepts
CIS16 Application Programming with Visual Basic
Flat Files & Relational Databases
Spreadsheets, Modelling & Databases
Relational Database Design
Universe Design Jack Fritz CTFL.
Understanding Core Database Concepts
Unit J: Creating a Database
BTEC ICT – Unit 18 With Mr Griffiths.
Presentation transcript:

Computer Science Projects Database Theory / Prototypes

Including a Database What You Need Simple? Creating an ERD (entity relationship diagram) should help you identify your level of complexity. Including a database in your project will help you identify a specific level of complexity. The more of the A2 syllabus that you use in your data processing, the easier it is to meet the highest level of complexity. The following slides will show you how to create a proof of concept that will meet the various levels of complexity. people inventions Many to Many One to Many One to One

Including a Database 0NF Simple Creating an ERD (entity relationship diagram) should help you identify your level of complexity. It’s not enough to just include a database. By including a flat file or a number of unrelated tables, or tables that have a many to many relationship, you remain at limited complexity. In this example, we have included a table called people and their inventions. One person can have many inventions, but more than one person can work on an invention. people inventions This Database can be said to be in 0NF Or O Normal Form

Rules of 1NF Limited All records have a Primary Key There is no duplication of data fields Data is atomic Each field has a unique name Atomic data cannot be divided any more. Eg. My full name is broken down into Title, FirstName, MiddleName & Surname fields

Including a Database 1NF Limited Creating an ERD (entity relationship diagram) should help you identify your level of complexity. In 1NF a database will consist of a number of tables which are related and each will have a primary key. Your SQL queries will be basic, such as SELECT statements to bring data to the screen & some INSERT statements to add new data. subject question users This Database can be said to be in 1NF Or 1st Normal Form

Rules of 2NF Adequate The database is already in 1NF AND All Data depends on the Primary key A simple way to remember this is that the data for that table must be relevant only to that table. Eg. A table called student which held course details wouldn’t be in 2NF

Including a Database 2NF Adequate Creating an ERD (entity relationship diagram) should help you identify your level of complexity. In 2NF a database will consist of a number of tables which are related and each will have a primary key. All data will be specifically related to the table that holds it. Your SQL queries will be dynamic, allowing users to select, insert & update data based upon their user input (eg. Completing a form) Your database will have the potential to store significant volumes of data. subject test users question This Database can be said to be in 2NF Or 2nd Normal Form

Rules of 3NF Complex The database is already in 2NF AND All Data links are fully dependant on the keys Data should not be duplicated across the database, instead it is linked via primary & foreign keys. To avoid many to many relationships, a database in 3NF will employ ‘link tables’ to create effective relationships between the records.

Including a Database 3NF Complex In 3NF a database will consist of a number of tables which are related purely through the use of unique keys (both foreign & primary). No data will be duplicated and there will be no m-2-m relationships Your SQL queries will be dynamic, allowing users to select, insert, update & delete data based upon their user input (eg. Completing a form). Queries may include data from several tables. Your database may be hosted remotely or make use of connection strings. Data extracted from the database may be used in your program to calculate outputs. Creating an ERD (entity relationship diagram) should help you identify your level of complexity. subject test class question student This Database can be said to be in 3NF Or 3rd Normal Form

Creating Your Local DB (Pascal - SQLite) Adequate To create a local Database for your Pascal Application, download the SQLite binary and SQLite DLL files to your P Drive. You will use the SQLite application to create your database structure via the command line interface. Using the .open command will create the database if it doesn’t already exist. To check that your database has been created, use the .databases command

Setting Up Tables in Your Local DB (Pascal - SQLite) Adequate To create your database, you will need to understand some basic DDL (data description language). These are the commands used to define the database structure, aka schema. Try entering the following statement into the SQLite application to create a table. Database Data Types: integer varchar (length) char (length) real text

Setting Up Tables in Your Local DB (Pascal - SQLite) Adequate Once you have created a table, it is useful to add some data into it for testing purposes. Although you will be adding data from inside your program later, this is a good chance to practice forming DML (data modelling language) statements. DML is the statements used to manipulate the data in your database. Try adding some data to your database table by using this INSERT statement.

Setting Up Tables in Your Local DB (Pascal - SQLite) Limited Now you have a database, you need to connect it to an application. Create a new Application in Lazarus and save this into a folder called ‘PoC’. Add a SQLite Connection and a button to the form. Rename your connection: dbConnection

Setting Up Tables in Your Local DB (Pascal - SQLite) Limited In order for the objects you have added to connect to the database, you need to add some code to the FormCreate procedure. This is the first thing that is run when the application starts. This line tells the dbConnection object to open a connection to the database.

Connecting to Tables in Your Local DB (Pascal - SQLite) Limited To create a full proof of concept, set up a form with the following objects: SQLite connection SQL Query Object SQL Transaction SQL Datasource TLabel Datagrid Navigator Pane Buttons

Connecting to Tables in Your Local DB (Pascal - SQLite) Limited Double click on the form and set up your database connection & first SQL Query: ExtractFilePath is a neat little function which will set your database path to the same directory as your application.

Connecting to Tables in Your Local DB (Pascal - SQLite) Limited Double click on the Commitinator button and add the following code: The purpose of the Transaction is to actually run the queries that you are creating. Next, double click on the Make it so… button and add the following code:

Connecting to Tables in Your Local DB (Pascal - SQLite) Limited The two buttons both refresh the database query: Commitinator updates the data, whilst Make it so… just resets any changes you made. Test your application by changing item 1 to Barney Rubble, and adding a new item with Fred Flintstone.

Connecting to Tables in Your Local DB (Pascal - SQLite) Adequate To increase the complexity of your data processing application, you will need to dynamically assign the parameters to your SQL queries. To do this, you will need to add three DBedit boxes (not standard edit boxes). The difference between an Edit box and a DBEdit is that you can connect your Database fields to each of the Edit Boxes.

Connecting to Tables in Your Local DB (Pascal - SQLite) Adequate To show the data in the edit boxes, you will need to assign the DataSource to each field and then explicitly tell the program which field to assign to each edit box. To do this, add the following code to the end of the FormCreate procedure: If your database fields are different, you will need to adjust these. These fields relate directly to the SELECT query at the start of the procedure.

Connecting to Tables in Your Local DB (Pascal - SQLite) Adequate Test your dynamic code by scrolling through the records using the Navigator arrows. Try changing some of the data and committing your changes – what happens to the data grid? If you add a new record to the dataset, you can now type in the details into the Dbedit boxes.

Connecting to Tables in Your Local DB (Pascal - SQLite) Complex To further increase the complexity of the project, we should make our SQL statements include data from multiple tables. To do this, we will need to create a second table within the 3NF rules. Note that this time, rather than having a key that we need to type in, auto_increment has been used. This will automatically create a numeric ID for each record.

Connecting to Tables in Your Local DB (Pascal - SQLite) Complex Once the second table has been created, we can add some data to it. The tables are linked through the use of the foreign key ‘inventor’ which holds the primary key from the people table. Looking at your original data, who do you think invented the shrinkinator? Clue: who’s id is 2?

Connecting to Tables in Your Local DB (Pascal - SQLite) Complex To link tables in an SQL statement, we use a JOIN. In the SQLQuery code, update your SELECT statement to bring back a list of all people and their linked invention. When writing longer SQL statements, it is often easier to write these in a string variable, then pass them by reference when setting up the Query object.

Connecting to Tables in Your Local DB (Pascal - SQLite) Complex The end result of this is to have a datagrid which shows data from both the people and the inventions table.