Question:
Some info on SQL and where I can learn it question type.?
Nameo 0
2012-12-13 15:01:36 UTC
I am new to the web-page development community but I heard that I need sql for a website that is supposed to have profiles, videos, and images.

I already know RoR and I was wondering how does SQL link into RoR, where can I learn SQL (good books and/or interactive websites perferred), and do I really need SQL for the website?
Four answers:
Joey
2012-12-14 07:54:47 UTC
You could probably get away with not knowing SQL, but it would limit your development capabilities.



Websites that have users login, post videos, and images store that information in a database. SQL allows RoR, PHP, and Asp.Net to put that information in and take that information out of the database.



I would recommend you start picking up SQL for the long-term.



There are many good websites and books you can read, just pick one that looks interesting and start reading and trying things out.
Chris
2012-12-13 16:43:03 UTC
SQL is just a language used to query databases. Your hypothetical website will need some sort of storage for - as you put it - profiles, videos and images, but a database is only one type of persistent storage you could use. If you do use an RDBMS (Relational DataBase Management System) like MySQL or SQL Server or Oracle or PostgreSQL, etc., you will use SQL to write the queries, but you will also have to learn whatever API is supported by both the RDBMS and your programming language.



You stated that you know Ruby on Rails. I have not used RoR, but I suspect it exposes some sort of data access API that should allow you to connect to whatever RDBMS you end up using. Search google for "ruby on rails database" and you'll probably get thousands of links to tutorials, reference pages and user forums.



Same with SQL (Structured Query Language), search google for "SQL tutorial".



The basics of SQL are very simple. Data in a database is stored in tables. A table has one or more named columns where the name of the column identifies what is stored in that column. A column also has other characteristics like the data type and a size. The rows (or records) in the table store the information about a single instance of the thing that the table stores.



For example, a table named People will store information about people and the information about a single person will be in a single row. The columns identify what information is stored for each person.



So a People table might have columns like Name, Birthdate, Address, PhoneNumber, etc.



There are many "rules" about how to properly design your tables and it's worth learning them. These rules are called database normalization rules (again, google it). For most databases, you'll be fine if you learn and use the first three normalization rules. When a table follows rule one, it is said to be "in the first normal form." When it follows rules one and two it is in the second normal form and when it follows the first three rules, it is in the third normal form. So as long as you design your tables to be in the third normal form, it will be easy to access the data - i.e. easy to write the queries.



So, if you had the table named People with columns Name, Birthdate, Address, City, State, Zip & Phone, you could, for example, get all the rows (and remember that each row represents a person) for people who live in Texas, but not in Dallas by using the following SQL query:



Select Name

From People

Where State = 'TX' and City != 'Dallas'



This is your basic Select command. A Select command is used to return rows from a table (or a combination of tables and other more esoteric data sources). After the word "Select" you list the comma-separated columns you want returned or use * (an asterisk) to return all the columns in the table.



The From clause tells the database engine where it should find these columns. In this example, we tell it to return the Name column from the People table. The From clause can get much more complicated - usually by using one or more Joins. Joins are ways of combining data from multiple, related tabled (this is where the word Relational in Relational Database comes from).



Finally, the Where clause is where you define the criteria that the database engine will use when picking which rows to include. In our example, we simple tell the database engine to include all rows where the state column is equal to the string 'TX' and the city column is not equal to 'Dallas'.



There are many other clauses, but this is your basic query.



Eventually, you will probably want to buy some books - they are a lot easier to use and learn from than online sources.
TheMadProfessor
2012-12-17 08:24:55 UTC
A good spot to start learning basic SQL is w3schools. While you might get by without knowing it, you'd be far better off it you at least know simple query, insert, update and delete syntax. I haven't worked with Ruby, but this site looks like it would be very relevant: http://ruby.bastardsbook.com/chapters/sql/
Serge M
2012-12-13 19:19:47 UTC
Try SQL Exercises: http://www.sql-ex.ru/


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...