Giter Site home page Giter Site logo

nycda-db-relationships's Introduction

Database Relations Example

This is a simple news site that's meant to show database relations. It has 3 main entities that are examples of one-to-many and many-to-many relationships.

Getting Started

  1. Run npm install to install dependencies
  2. Create a new database for this project
  3. Create an .env file that has the following keys:
DATABASE_NAME=[db name]
DATABASE_USER=[db user name]
DATABASE_PASSWORD=[db user password]

# Optional
PORT=[web app port]           # Default: 7000
DATABASE_HOST=[db host]       # Default: localhost
DATABASE_PORT=[db port]       # Default: 5432
DATABASE_URL=[postgres://...] # Default: Nothing, uses other DATABASE values
  1. Run npm start to start it up!

Schema

The models that inform this schema are all defined in models/*.js. All tables have the default Sequelize createdAt and updatedAt columns, in addition to what's defined below.

Articles

column type
id SERIAL PRIMARY KEY
title VARCHAR(200) NOT NULL
body TEXT NOT NULL

Comments

column type
id SERIAL PRIMARY KEY
name VARCHAR(64) NOT NULL
body VARCHAR(200) NOT NULL
articleId INTEGER REFERENCES articles

Tags

column type
id SERIAL PRIMARY KEY
name VARCHAR(64) NOT NULL
body VARCHAR(200) NOT NULL

Article / Tag xref

column type
tagId INTEGER REFERENCES tags
articleId INTEGER REFERENCES articles

nycda-db-relationships's People

Contributors

wbobeirne avatar

Watchers

 avatar James Cloos avatar  avatar

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.