BlackSourceLabs / BlackNectar-Service

REST API for BlackNectar
Apache License 2.0
5 stars 1 forks source link

Design Images Table #18

Closed SirWellington closed 7 years ago

SirWellington commented 7 years ago

Now that we have stores persisted in Postgres, we need design a way to remember and persist images associated with a Store.

Remembering images will greatly improve performance.

cordhernandez commented 7 years ago

Does this mean creating an algorithm that will detect images associated with a store and save them in a sub database? can you briefly explain the process for this?

SirWellington commented 7 years ago

@cordhernandez Great questions! I can explain when we meet in person.

IMG_3478.JPG

SirWellington commented 7 years ago

@cordhernandez Great questions! I can explain when we meet in person.

SirWellington commented 7 years ago

So what I'm thinking is to store images in their own table, called Images with no foreign keys, and to then store the relationships between images and stores in their own table, Store_Images.

SirWellington commented 7 years ago
CREATE TABLE IF NOT EXISTS Images_External
(
        image_id text PRIMARY KEY,
        -- This is otherwise known as the image blob
        binary BYTEA,
        height INT,
        width INT,
        size_in_bytes INT,
        file_type TEXT,
        source TEXT
);
SirWellington commented 7 years ago

Images

Field Type Description
Image_ID String (Primary Key) Unique Image ID
binary ByteA (Byte Array/Binary) The Binary Blob of the image
Height Integer Height of image
Width Integer Width of image
Size In Bytes Integer How many bytes the image takes up
File Type String The type of file [PNG, JPG, BMP, RAW, etc]
Source String Where did the image come from? [Google, Yelp, etc]
SirWellington commented 7 years ago

PR