Skip to content

Instantly share code, notes, and snippets.

@laurenhavertz
Last active December 21, 2015 09:19
Show Gist options
  • Save laurenhavertz/6284434 to your computer and use it in GitHub Desktop.
Save laurenhavertz/6284434 to your computer and use it in GitHub Desktop.
Schema Design
<group label="Character" color="rgb(255,200,200)">
	<type label="Char" length="1" sql="CHAR" quote="'"/>
	<type label="Varchar" length="1" sql="VARCHAR" quote="'"/>
	<type label="Text" length="0" sql="MEDIUMTEXT" re="TEXT" quote="'"/>
	<type label="Binary" length="1" sql="BINARY" quote="'"/>
	<type label="Varbinary" length="1" sql="VARBINARY" quote="'"/>
	<type label="BLOB" length="0" sql="BLOB" re="BLOB" quote="'"/>
</group>

<group label="Date &amp; Time" color="rgb(200,255,200)">
	<type label="Date" length="0" sql="DATE" quote="'"/>
	<type label="Time" length="0" sql="TIME" quote="'"/>
	<type label="Datetime" length="0" sql="DATETIME" quote="'"/>
	<type label="Year" length="0" sql="YEAR" quote=""/>
	<type label="Timestamp" length="0" sql="TIMESTAMP" quote="'"/>
</group>

<group label="Miscellaneous" color="rgb(200,200,255)">
	<type label="ENUM" length="1" sql="ENUM" quote=""/>
	<type label="SET" length="1" sql="SET" quote=""/>
	<type label="Bit" length="0" sql="bit" quote=""/>
</group>

TINYINT NULL INTEGER NULL id

TINYINT NULL VARCHAR NULL TINYINT NULL id
TINYINT NULL VARCHAR NULL id
<group label="Character" color="rgb(255,200,200)">
	<type label="Char" length="1" sql="CHAR" quote="'"/>
	<type label="Varchar" length="1" sql="VARCHAR" quote="'"/>
	<type label="Text" length="0" sql="MEDIUMTEXT" re="TEXT" quote="'"/>
	<type label="Binary" length="1" sql="BINARY" quote="'"/>
	<type label="Varbinary" length="1" sql="VARBINARY" quote="'"/>
	<type label="BLOB" length="0" sql="BLOB" re="BLOB" quote="'"/>
</group>

<group label="Date &amp; Time" color="rgb(200,255,200)">
	<type label="Date" length="0" sql="DATE" quote="'"/>
	<type label="Time" length="0" sql="TIME" quote="'"/>
	<type label="Datetime" length="0" sql="DATETIME" quote="'"/>
	<type label="Year" length="0" sql="YEAR" quote=""/>
	<type label="Timestamp" length="0" sql="TIMESTAMP" quote="'"/>
</group>

<group label="Miscellaneous" color="rgb(200,200,255)">
	<type label="ENUM" length="1" sql="ENUM" quote=""/>
	<type label="SET" length="1" sql="SET" quote=""/>
	<type label="Bit" length="0" sql="bit" quote=""/>
</group>

TINYINT NULL INTEGER NULL id

TINYINT NULL VARCHAR NULL TINYINT NULL id
TINYINT NULL VARCHAR NULL id
<group label="Character" color="rgb(255,200,200)">
	<type label="Char" length="1" sql="CHAR" quote="'"/>
	<type label="Varchar" length="1" sql="VARCHAR" quote="'"/>
	<type label="Text" length="0" sql="MEDIUMTEXT" re="TEXT" quote="'"/>
	<type label="Binary" length="1" sql="BINARY" quote="'"/>
	<type label="Varbinary" length="1" sql="VARBINARY" quote="'"/>
	<type label="BLOB" length="0" sql="BLOB" re="BLOB" quote="'"/>
</group>

<group label="Date &amp; Time" color="rgb(200,255,200)">
	<type label="Date" length="0" sql="DATE" quote="'"/>
	<type label="Time" length="0" sql="TIME" quote="'"/>
	<type label="Datetime" length="0" sql="DATETIME" quote="'"/>
	<type label="Year" length="0" sql="YEAR" quote=""/>
	<type label="Timestamp" length="0" sql="TIMESTAMP" quote="'"/>
</group>

<group label="Miscellaneous" color="rgb(200,200,255)">
	<type label="ENUM" length="1" sql="ENUM" quote=""/>
	<type label="SET" length="1" sql="SET" quote=""/>
	<type label="Bit" length="0" sql="bit" quote=""/>
</group>

TINYINT NULL TINYINT NULL TINYINT NULL id

TINYINT NULL VARCHAR NULL id
TINYINT NULL VARCHAR NULL id
TINYINT NULL TINYINT NULL INTEGER NULL id
<group label="Character" color="rgb(255,200,200)">
	<type label="Char" length="1" sql="CHAR" quote="'"/>
	<type label="Varchar" length="1" sql="VARCHAR" quote="'"/>
	<type label="Text" length="0" sql="MEDIUMTEXT" re="TEXT" quote="'"/>
	<type label="Binary" length="1" sql="BINARY" quote="'"/>
	<type label="Varbinary" length="1" sql="VARBINARY" quote="'"/>
	<type label="BLOB" length="0" sql="BLOB" re="BLOB" quote="'"/>
</group>

<group label="Date &amp; Time" color="rgb(200,255,200)">
	<type label="Date" length="0" sql="DATE" quote="'"/>
	<type label="Time" length="0" sql="TIME" quote="'"/>
	<type label="Datetime" length="0" sql="DATETIME" quote="'"/>
	<type label="Year" length="0" sql="YEAR" quote=""/>
	<type label="Timestamp" length="0" sql="TIMESTAMP" quote="'"/>
</group>

<group label="Miscellaneous" color="rgb(200,200,255)">
	<type label="ENUM" length="1" sql="ENUM" quote=""/>
	<type label="SET" length="1" sql="SET" quote=""/>
	<type label="Bit" length="0" sql="bit" quote=""/>
</group>

TINYINT NULL id

TINYINT NULL TINYINT NULL id
TINYINT NULL INTEGER NULL id
TINYINT NULL INTEGER NULL id
TINYINT NULL INTEGER NULL TINYINT NULL id
TINYINT NULL INTEGER NULL INTEGER NULL id
@laurenhavertz
Copy link
Author

Users:: has_many :lists
Lists:: has_many :items, belongs_to :users
Items:: belongs_to :lists

@laurenhavertz
Copy link
Author

User::has_many :posts
Post:: has_many :comments, :votes, :tags belongs_to :user
Comments:: has_many :votes, :tags belongs_to :user through :posts
Votes:: belongs_to :post, :comment
Tags::belongs_to :user through :post, :comment

@laurenhavertz
Copy link
Author

User::has_many :contacts, :groups
Contact:: belongs_to :user, has_many :groups
Group::belongs_to :user, has many :contacts

@laurenhavertz
Copy link
Author

User:: has_many :surveys,
Survey:: has_many :questions / belongs_to :user
Questions:: has_many :answers/ belongs_to : survey
Answer:: has_many :responses/ belongs_to :questions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment