Yes, you can definitely normalise further, like with the nutrients approach @diafol suggests, but you need to know the data before making a judgement on whether it's worth it.

There are advantages and disadvantages in cases like that.

Votes + Comments
Thanks for the advise!

Should I turn those into an extra column or should they become seperate tables?

They should definitely be stored in a separate table (say, food_category) and you should add an appropriately-named foreign key to the table you posted (let's called that food).

In SQL, you'd use a statement like this to create the tables with the foreign-key relationship in place, note the references line:

create table food_category (
        id     serial primary key,
        name   varchar(32) not null unique

create table food (
        id          serial primary key,
        category_id int references food_category(id) not null,
        name        varchar(32) not null unique,
        calories    numeric,
        cholesterol numeric,
        sugar       numeric

I'd start by learning Java. Then SQL. When you've learned Java and SQL, then learn HTML. Now you've mastered those relatively simple subjects, just learn all of the glue that connects them together. Once you've done that, it's quite simple:

Your attendence is probably represented by a join table; a student attends a lesson. so your attendance table will contain student_id and lesson_id.

Now, on your HTML form you should generate a list of checkboxes for every student who might attend the class (probably based on their subject and grade, or whatever). The checkbox's value should equal the student's ID:

<input type="checkbox" name="attendance" value="2345"/>

When the form is submitted, only the checked checkboxes that are checked (i.e. those who have attended the lesson) will be included in the form data. Save each of the IDs you recieve as a row in the attendance table. Easy.


True, and if she wants to continue and learn then fair play, and I hope she manages to build something great.

However, she's using a discontinued tool that outputs unmaintainable HTML, and developing her site clearly isn't her goal; letting people know about her jewelry (which looks fantastic, by the way Sanda) is.

Plus, as there's a products tab on her site, one would expect that some kind of 'web shop' is on the radar. That won't be doable in Webplus, and it's not the easiest thing to implement from scratch at the best of times.


I'd suggest using something like SquareSpace for this kind of site, rather than attempting to build it yourself. It has an e-commerce module built-in and plenty of easy templates to choose from.

A note unrelated to the original question, when at 100% zoom, I can only see 2/3 of the page, I need to scroll right to see the whole thing (or zoom out to about 80%).


I doubt it's your query that's slow. What happens if you simply run the query select * from Doopgegevens; in a shell? For ~10k rows, providing your table is holding 'normal' data (and not base64 encoded movie files or something) it should be fast. If it is fast, try changing your data list to only use a subset of your table's columns, which will indicate if that's where your performance problem is.


[QUOTE=red_ruewei;1694533]thanks for reply.
I try something like this to read record with range month and year.
Example from June, 2011 to June 2012
Select * from table where (YEAR(date1)>='$year1' AND MONTH(date1)>='$mon1') and (YEAR(TKH_date1)<='$year2' AND MONTH(TKH_date1)<='$month2')

i had test this. And run separately.
(YEAR(date1)>='$year1' AND MONTH(date1)>='$mon1')
For above code it run smoothly

(YEAR(TKH_date1)<='$year2' AND MONTH(TKH_date1)<='$month2')
But for this code, it fail....


Fails why? What error? What variables? Also, by calling YEAR(blah) you're going to bypass your indices and your query will be slow. Something like this is better and will work.

SELECT * FROM table WHERE date_data >= '2011-06-01' AND date_data < '2011-07-01';


[QUOTE=Xessa;884086]I want to get the row number of a specific row in the table.

Also is this legal?


INSERT INTO (SELECT * FROM myTable WHERE mynumber=2) VALUES ........


Getting the row number depends on the DB you're using; Oracle supports this (via [icode]ROWNUM[/icode]) but MySQL for example does not.

Your statement is invalid; if you want to update a row you should be doing:

update myTable set foo = 'bar' where mynumber = 2;


[QUOTE=Jx_Man;584701]i already installed ruby and in ruby directory contain fxri and Scite.
well, i m do small ex in fxri...
what is Scite for? what different about fxri and Scite? why i can't compile code in Scite?
i find compile in tools of Scite but it was disable.
example i write code in Scite :
[code=ruby]5.times { print "Odelay!" }[/code]
when i tried to compiled i can't do this perform. there are compile, Build,Go etc in tools option that i cannot perform to click, it was disable. i m confused.
But this code running great in fxri. so why i can't do compiled in Scite?
please help

Thank you.[/QUOTE]

Did your source file definitely have a .rb extension? Did anything at all appear in the output window?

Votes + Comments
Thank You For Directing friend :)

[QUOTE=eruder;501855]pty's improvement is a good one!

The only nit I have with it is that I wouldn't put the [ICODE]banner[/ICODE] method in the controller, since it has nothing to do with the "traffic cop" jobs that controllers normally do. I would put it in a helper file, either this controller's helper file or the [ICODE]application_helper.rb[/ICODE] file (if it's a method you'd want to use in other controllers).


Thanks Ed :)


[QUOTE=tefflox;498336]My solution ---

[code] <%=
def banner
i, n, span, str = 0, 0, String.new, "listenlightpoetryjournal"
until i == str.length do
span << "<span id=\"n" << n.to_s << "\" style=\"top: "
<< (rand(36) - 18).to_s << "px;\">" << str[i] << "</span>"
i, n = i + 1, n + 1
return span

No more PHP for this one.[/QUOTE]

Although your solution is fine it can be a little more readable (and re-usable) in rails.

In the controller:

def banner(text)
span = String.new
text.split(//).each_with_index do |c, i|
span += "<span id='#{i}' style='top:#{(rand(36)-18)}px;'>#{c}</span>\n"

Then in the view

<%= banner("listenlightpoetryjournal") %>


I find it easier to specify the join as follows and seperate the where clause; if your data is correct the following query should work:

table1 ap
table2 p on p.projID = ap.projID
and ap.userId = p.userId
p.projectID = 'test1'


[QUOTE=pmhayden;427657]I have a Database which is dealing with a book library system. I have a table which has a has a field dealing with the ReturnDate of a book. I was wondering if it is possible to do a SELECT statement that would return the the fines due on an overdrawn book at the database level instead of me having to do it in a Java environment.

In words what I want done:
IF (ReturnDate > CURDATE())
(ReturnDate - CURDATE()) * Fine

Thanks in advance

select id,
( cast(current_timestamp as date) - cast(return_date as date) ) * 3 as fine
from books
return_date > current_timestamp

This is how to do the select in postgresql however the syntax is going to be slightly different in MySQL (i think you should use now() instead of current_timestamp but I can't remember)