Giter Site home page Giter Site logo

friendlywager's People

Contributors

awdriggs avatar

Stargazers

 avatar

Watchers

 avatar  avatar

friendlywager's Issues

Can't DELETE a topic from my table

Can't delete a topic because it violates foreign key requirements.

This is what I have in my schema. Do I need to add something inside the drop table to to delete dependents?

DROP TABLE IF EXISTS topics CASCADE;
DROP TABLE IF EXISTS wagers;
DROP TABLE IF EXISTS users CASCADE;
DROP TABLE IF EXISTS comments;
DROP TABLE IF EXISTS tags CASCADE;
DROP TABLE IF EXISTS tags_topics;

CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    username VARCHAR(255),
    first VARCHAR(255),
    last VARCHAR(255),
    password VARCHAR(255),
    img_url TEXT,
    points INTEGER DEFAULT(0) NOT NULL
);

CREATE TABLE tags (
    id SERIAL PRIMARY KEY,
    keyword VARCHAR(25)
);

CREATE TABLE topics (
    id SERIAL PRIMARY KEY,
    title VARCHAR(255),
    description TEXT,
    creation_date TIMESTAMP without time zone DEFAULT now() NOT NULL,
    active BOOLEAN DEFAULT true,
    complete_date TIMESTAMP without time zone,
    winner_id INTEGER references users,
    owner_id INTEGER references users,
    geo_id VARCHAR(255),
    city VARCHAR(255),
    region VARCHAR(255),
    country VARCHAR(255)
);

CREATE TABLE wagers (
    id SERIAL PRIMARY KEY,
    topic_id INTEGER references topics,
    user_id INTEGER references users,
    creation_date TIMESTAMP without time zone DEFAULT now() NOT NULL,
    wager TIMESTAMP NOT NULL,
    geo_id VARCHAR(255),
    city VARCHAR(255),
    region VARCHAR(255),
    country VARCHAR(255)
);

CREATE TABLE comments (
    id SERIAL PRIMARY KEY,
    topic_id INTEGER references topics,
    user_id INTEGER references users,
    creation_date TIMESTAMP without time zone DEFAULT now() NOT NULL,
    geo_id VARCHAR(255),
    city VARCHAR(255),
    region VARCHAR(255),
    country VARCHAR(255),
    comment TEXT
);

CREATE TABLE tags_topics (
    tag_id INTEGER references tags,
    topic_id INTEGER references topics
);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.