Re: Arrays ... need clarification....
От | Joe Conway |
---|---|
Тема | Re: Arrays ... need clarification.... |
Дата | |
Msg-id | 3E9225FD.1050705@joeconway.com обсуждение исходный текст |
Ответ на | Arrays ... need clarification.... (Medi Montaseri <medi.montaseri@intransa.com>) |
Список | pgsql-general |
Medi Montaseri wrote: > I can use some clarification on Array usage.... > > Given the following definition.... > > create table test ( name varchar(20) , grades integer[]); > > How do I insert a new record, I see multiple ways of doing it but if one > does > not do this right, then updates will fail.... I think this is probably a misuse of arrays. You might better model this as something like: create table student ( student_id serial primary key, name text ); create table test ( test_id serial primary key, date_taken timestamp, description text ); create table grade ( grade_id serial primary key, test_id int references test, student_id int references student, test_grade int ); Now you can do something like: select s.name, avg(g.test_grade), stddev(g.test_grade) as average from student s, test t, grade g where s.student_id = g.student_id and g.test_id = t.test_id and t.date_taken between '01-01-2003' and '03-31-2003' group by s.name; But in any case, see: http://www.postgresql.org/docs/view.php?version=7.3&idoc=1&file=arrays.html for more information on use of arrays. Joe
В списке pgsql-general по дате отправления: