I was looking at learning SQL
here, however, the tutorials are referencing these tables, now I'm wondering: where the hell did these tables come from? Is there a better tutorial someone can link me to, or possibly explain what they are trying to do? By the way, I realize I sound like I'm an idiot
Tables are fields insde your MySql Database, you can have unlimited amount of Databases and Tables are what those DBs hold.
Let's say you have a Emplyee database called "emplyee", that database would have tables like, workers and times
A structure would be for example,
DB Emplyee
TBL workers
- FIELD full_name
- FIELD age
...
TBL times
- FIELD user_id
- FIELD work_time
The Tables would then hold their own fields, like usr_id, user_avatar, etc...
(12-21-2009, 01:10 PM)Master of The Universe Wrote: [ -> ]Tables are fields insde your MySql Database, you can have unlimited amount of Databases and Tables are what those DBs hold.
Let's say you have a Emplyee database called "emplyee", that database would have tables like, workers and times
A structure would be for example,
DB Emplyee
TBL workers
- FIELD full_name
- FIELD age
...
TBL times
- FIELD user_id
- FIELD work_time
The Tables would then hold their own fields, like usr_id, user_avatar, etc...
I found this kind of confusing - it would make more sense to have a table called Employees, and a database called workplace.
Other tables in the workplace database could include things such as inventory and sales.
The employees table would look something like
Code:
| user_id | salary | work_time | full_name | age |
A sample sql query to grab a certain employees age would look something like:
Code:
SELECT salary FROM Employees WHERE user_id = 1234
Note: My sql is rusty as balls, it's possible I'm not entirely correct, but I'm sure I"ll be corrected if I'm not.
Anyways, that would return the salary of whichever worker had an id of 1234.
Ohh yeah your're right about the Database, and there isn't anything wrong with SQL.
But it seems you did explained my fail well....
I was typing fast and thinking faster, happens
(12-21-2009, 01:21 PM)Master of The Universe Wrote: [ -> ]Ohh yeah your're right about the Database, and there isn't anything wrong with SQL.
hehe, awesome. I've only worked with sql once, this summer, while reading a php book
Quote:But it seems you did explained my fail well....
I was typing fast and thinking faster, happens
That's okay, mistakes happen. You still gave a good explanation.
This makes no sence to me O.o. Im not really sure why. is
| user_id | salary | work_time | full_name | age |
actual syntax?
(12-21-2009, 03:56 PM)nevets04 Wrote: [ -> ]This makes no sence to me O.o. Im not really sure why. is
| user_id | salary | work_time | full_name | age |
actual syntax?
No, you have to think of it in a less practical sense. Imagine creating a table in a word document. At the top you have a title. user_id, salary, work_time, full_name, and age are your titles.
From here, each row contains information about the same person. For example, take a look at the following:
Code:
| user_id | salary | work_time | full_name | age |
| 1232 | $10h | 3 weeks | Martin smith | 20 |
That row contains information about a man named Martin Smith. Let's say you knew his name, but you wanted to find out what his salary is.
Your query would look something like
Code:
SELECT salary FROM Employees WHERE full_name = "Martin Smith"
SQL queries sort of make sense as you read them. This is selecting the salary column from the employees gable where the name is "Martin Smith". This will return $10h. Make sense?
I understand the query, but how do you make the table?
(12-21-2009, 07:44 PM)nevets04 Wrote: [ -> ]I understand the query, but how do you make the table?
there's a mysql command line for making tables, but there's an easier way to do it.
It's a super-slick webapp called phpmyadmin. It's in apt-get's repo's (I believe), and should be in yum's, too.
Here's their website,
http://www.phpmyadmin.net/home_page/index.php.
Not only do they help you make tables, it also (among other things) lets you see an aesthetically pleasing visual representation of your tables. ;).