Re: Arrays ... need clarification....
| От | Medi Montaseri |
|---|---|
| Тема | Re: Arrays ... need clarification.... |
| Дата | |
| Msg-id | 3E9230AD.3070508@intransa.com обсуждение исходный текст |
| Ответ на | Arrays ... need clarification.... (Medi Montaseri <medi.montaseri@intransa.com>) |
| Ответы |
Re: Arrays ... need clarification....
|
| Список | pgsql-general |
Yes....your proposed method is indeed the traditional approach....but since PG provides Arrays, I figured "How Nice".... Thank anyways though... And the link does not provide much, I stopped by there first, before asking.... All the examples on the link are using insert into table values ( x, x, x , ...) instead of insert into table (col, col, ...) values ( val, val, ...) Joe Conway wrote: > 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 по дате отправления: