Blog Post Published on:   | 26th October 2022 |
Title:   | Photo Database Schema (2018-06-12) |
Lead Author:   | Fred M. Beshears |
Type of Blog Post:   | mycirclepines_website |
These notes on a photo database schema were written back on 12 June 2018. My thinking on the schema for the photo database has evolved considerably over the years, but I started writing down my thoughts back in 2018.
As an example of how things have changed since 2018, I’ve learned since then that one can use hash coding to easily find duplicate image files. Also, I’ve decided that it would be good to combine two functionalities into one web-app: 1) a photo sharing system that lets end-users upload and tag their own photos and 2) a photo-archive system that is managed by one or more system administrators. The photo records in the latter are supposed to be better organized and more consistently tagged. Finally, I’ve learned that tags can be used to informally express relationships such as one-to-many and many-to-many.
Anyway, here is what I was thinking back in 2018.
Recently, I’ve been working on a database schema for a photo database project for an organization known as Circle Pines Center.
For those of you who may not know, a schema is a description of the tables in a database and the relationships between these table.
If you are interested in how one might set up such a database, then read on.
To get us started, here is my very professional schema drawing.
The basic tables in this schema are as follow:
Intersect tables – these tables are used to show the relationships between the tables listed above.
Finally, here’s the schema in JSON, a form that the computer likes.
table_definitions_list_of_dict = [
{
'table_name' : 'photos',
'field_names_types' : [
('id', 'integer primary key autoincrement not null'),
('file_number_str', 'text unique'),
('extension', 'text'),
('size_in_bytes', 'integer'),
('date_taken', 'text'),
('description', 'text')
]
},
{
'table_name' : 'tags',
'field_names_types' : [
('id', 'integer primary key autoincrement not null'),
('kw_name', 'text unique')
]
},
{
'table_name' : 'folders',
'field_names_types' : [
('id', 'integer primary key autoincrement not null'),
('submitting_party_id','integer'),
('kw_name', 'text unique'),
('description', 'text')
]
},
{
'table_name' : 'albums',
'field_names_types' : [
('id', 'integer primary key autoincrement not null'),
('kw_name', 'text unique'),
('title', 'text'),
('description', 'text')
]
},
{
'table_name' : 'parties',
'field_names_types' : [
('id', 'integer primary key autoincrement not null'),
('first_name', 'text'),
('middle_name', 'text'),
('last_name', 'text'),
('other_name', 'text'),
('photo_tag_name', 'text'),
('last_name_sort_str', 'text'),
('description', 'text'),
('phone_number', 'text'),
('email', 'text'),
]
},
{
'table_name' : 'locations',
'field_names_types' : [
('id', 'integer primary key autoincrement not null'),
('kw_name', 'text unique'),
('description', 'text')
]
},
{
'table_name' : 'events',
'field_names_types' : [
('id', 'integer primary key autoincrement not null'),
('kw_name', 'text unique'),
('title', 'text'),
('description', 'text'),
('date', 'text'),
('start_isodate', 'text'),
('end_isodate', 'text')
]
},
{
'table_name' : 'photo_tag',
'field_names_types' : [
('id', 'integer primary key autoincrement not null'),
('photo_id', 'integer'),
('tag_id', 'integer'),
('tag_value', 'text')
]
},
{
'table_name' : 'photo_party',
'field_names_types' : [
('id', 'integer primary key autoincrement not null'),
('photo_id', 'integer'),
('party_id', 'integer'),
('role_type', 'text')
]
},
{
'table_name' : 'photo_folder',
'field_names_types' : [
('id', 'integer primary key autoincrement not null'),
('photo_id', 'integer'),
('folder_id', 'interger'),
('role_type', 'text'),
('order_numstr', 'text'),
]
},
{
'table_name' : 'photo_album',
'field_names_types' : [
('id', 'integer primary key autoincrement not null'),
('photo_id', 'integer'),
('album_id', 'integer'),
('role_type', 'text'),
('order_numstr', 'text'),
]
},
{
'table_name' : 'photo_location',
'field_names_types' : [
('id', 'integer primary key autoincrement not null'),
('photo_id', 'integer'),
('location_id', 'integer'),
('role_type', 'text')
]
},
{
'table_name' : 'photo_event',
'field_names_types' : [
('id', 'integer primary key autoincrement not null'),
('photo_id', 'integer'),
('event_id', 'integer'),
('role_type', 'text')
]
}
]