Software Engineering for Internet Applications
create table content_raw ( -- the combination of these two is the key content_id integer primary key, version_number integer, content_type varchar(100) not null, refers_to references content_raw, creation_user not null references users, creation_date not null date, release_time date, expiration_time date, -- some of our content is geographically specific zip_code varchar(5), -- a lot of our readers will appreciate Spanish versions language char(2) references language_codes, mime_type varchar(100) not null, one_line_summary varchar(200) not null, -- let's use BLOB in case this is a Microsoft Word doc or JPEG -- a BLOB can also hold HTML or plain text body blob, editorial_status varchar(30) check (editorial_status in ('submitted','rejected','approved','expired')) primary key (content_id, version_number) );
-- note the use of MAX on VARCHAR column; this works just fine select content_id, max(zip_code) from content_raw where content_id = 5657 group by content_id
15 of 30