+ = – PostgreSql – Questions?



+ = – PostgreSql – Questions?

0 0


postresql-9.4-rails-4.2-presentation


On Github bloomrain / postresql-9.4-rails-4.2-presentation

+ =

http://facts.randomhistory.com/2009/08/04_love.html

Created by Povilas Jurčys / @PovilasJurcys

PostgreSql

Postresql already becomes rails developer top choise. Let's talk why

Remoe and Juliet effect

Sometimes called the “Romeo and Juliet effect,” a situation with challenges or obstructions is likely to intensify one’s passion for a loved one Postresql already becomes rails developer top choise. Let's talk why

What is good about Postgresql

  • Datatypes
  • Foreign key support
  • Full text search
Postresql already becomes rails developer top choise. Let's talk why

Remoe and Juliet effect

A study conducted in 1989 assures that simple eye contact could make a person fall in love with you (Kellerman, Lewis, and Laird). The Power of Eye Contact - Make Someone Fall in Love With You! In this study two opposite sex strangers were asked to gaze into each other’s eyes for two minutes, which in some cases, was enough to produce passionate feelings for each other Postresql already becomes rails developer top choise. Let's talk why

Datatype: citext

								enable_extension 'citext'

								create_table :users do |t|
								  t.citext :username, null: false
								end

								add_index :users, :username, unique: true
						
							User.create(username: 'BloomRain') # ok
							User.create(username: 'bloomrain') # fail
							User.find_by(username: 'BlooMrAiN')
						

Datatype: Array

							create_table :books do |t|
							  t.string 'title'
							  t.string 'tags', array: true
							  t.integer 'ratings', array: true
							end
							add_index :books, :tags, using: 'gin'
							add_index :books, :ratings, using: 'gin'
						
	Book.create(tags: ['fantasy', 'fiction], ratings: [4, 5])
	Book.where("'fantasy' = ANY (tags)")
	Book.where("tags @> ARRAY[?]::varchar[]", ["fantasy", "fiction"])
	Book.where("array_length(ratings, 1) >= 3")
						

Datatype: JSON(B)

							create_table :product do |t|
								t.sort :string
							  t.jsonb 'details', array: true
							end
							add_index :books, :info, using: 'gin'
						
							Product.create(sort: 'Book', details: {'ISBN': '047X', lang: 'en'})
							# has key?
							Product.where('details ? "ISBN"')
							# has key/val pair?
							Product.where('details @> {"ISBN": "047X" }')
						

PostgreSql

http://edgeguides.rubyonrails.org/active_record_postgresql.html
  • Complex data types
    • Array
    • JSON, JSONB
    • XML, date ranges, custom types...
  • Foreign key constraints
  • Full text search support
    • http://simononsoftware.com/great-presentation-postgresql-and-rails/

Rails 4.2 and Postgres 9.4

Foreign Key Support (PostgeSql, MySql)

JSONB format (PostgeSql)

Citext format (PostgeSql)

Foreign key constraints

https://robots.thoughtbot.com/referential-integrity-with-foreign-keys

https://robots.thoughtbot.com/referential-integrity-with-foreign-keys

http://adamsanderson.github.io/railsconf_2013/?full#49

Hstore stores all values as text :(

Questions?

Thanks!