Creating a view

Before we finish our database design, we're going to create a view that will simplify access to our data. A view behaves like a table in most respects, but contains no actual data; it's really just a stored SELECT query. Our view will format our data for easier interaction with the GUI.

Views are created using the CREATE VIEW command as follows:

CREATE VIEW data_record_view AS (

Inside the parentheses, we put the SELECT query that will return the table data for our view:

SELECT pc.date AS "Date", to_char(pc.time, 'FMHH24:MI') AS "Time", lt.name AS "Technician", pc.lab_id AS "Lab", pc.plot AS "Plot", pc.seed_sample AS "Seed sample", pc.humidity AS "Humidity", pc.light AS "Light", pc.temperature AS "Temperature", pc.plants AS ...

Get Python GUI Programming with Tkinter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.