1
\$\begingroup\$

As an exercise in learning, I'm creating a bugs/issues tracking and "aggregator" web application. A simple app consisting of products, issues, reviews and links related to it. The links will be urls pointing to issues/reviews already created on external sites (bugzillas, stackoverflow, etc). Here is my initial effort towards creating the database schema of the app:

CREATE TABLE PRODUCT (
    ID INTEGER PRIMARY KEY,
    NAME VARCHAR(255), --Samsung Galaxy, Apple iphone, Dell Inspiron, GNOME Desktop, etc.
    VERSION VARCHAR(255), --S5, v3.14, etc.
    IMAGE VARCHAR(255), --PATH TO UPLOADED IMAGE FILE
    CATEGORIES VARCHAR(255),
    TAGS VARCHAR(255),
    CREATOR VARCHAR(255) --EMAIL ADDRESS OF PRODUCT UPLOADER
);

CREATE TABLE REVIEWS (
    ID INTEGER PRIMARY KEY,
    PRODUCT_ID INTEGER,
    CREATOR VARCHAR(255), --EMAIL ADD. OF REVIEWER
);

CREATE TABLE ISSUES(
    ID INTEGER PRIMARY KEY,
    PRODUCT_ID INTE GER,
    CREATOR VARCHAR(255), --EMAIL ADDRESS
    DESCN VARCHAR(255), --DESCRIPTION
    LINKS VARCHAR(255)
);

CREATE TABLE LINKS(
    ID INTEGER PRIMARY KEY,
    PRODUCT_ID INTEGER,
    LINK_TYPE VARCHAR(255), --ISSUE OR REVIEW OR OTHER (STACKOVERFLOW/REDDIT/HN CONTENT)
    DESCN VARCHAR(255), --A SHORT PREVIEW OF LINKED CONTENT
    URL VARCHAR(255),
    LAST_UPDATED DATETIME, --CRAWLER TIMESTAMP
);

CREATE TABLE LINK_VOTES(
    ID INTEGER PRIMARY KEY,
    LINK_ID INTEGER,
    VOTER VARCHAR(255), --EMAIL ADD. OF THE VOTER
    VOTE INTEGER, --1==UP, 0==DOWN
);  

Appreciate if you can provide me suggestions, improvements, etc.

\$\endgroup\$
2
  • \$\begingroup\$ Is this for mysql? Please tag accordingly. \$\endgroup\$ Commented Feb 28, 2016 at 17:07
  • \$\begingroup\$ @200_success Yes. Though my original idea is database agnostic, this particular prototype implementation is in mysql. \$\endgroup\$ Commented Mar 3, 2016 at 15:11

1 Answer 1

2
\$\begingroup\$
CATEGORIES VARCHAR(255),
TAGS VARCHAR(255),

Take care with plural named fields. It's very, very likely that any plural field is secretly a multi-valued field. You might want to extract a "Category" and "Tag" table out of this, so searching for them is easier.

PRODUCT_ID INTE GER,

You've got a space there. Not sure if SQL is okay with that.

Lastly, I think you should put some NOT NULL in there - are you sure every field except the primaries can be NULL? You also seem to be missing foreign keys from one table to another.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.