Answer the question
In order to leave comments, you need to log in
What is the correct way to store "read" marks for feeds?
Hello!
When I found out that Google Reader was closing down, I came up with the idea to write my own reader in Java + GWT + Hibernate + Postgres + a number of smaller technologies (Horrorss for working with RSS / Atom, GWT-Bootstrap for application design, gwt -p to work with MVP, spring + spring data JPA to tie the whole thing together).
If anyone is interested, here is the project on github: github.com/asm0dey/jReader
And so, at a fairly early stage of development - changes are still very easy to make now - I thought about the question - how, in fact, to store “read” marks for feeds? After all, a user can view hundreds of feeds a day. Well, the second question, related to this - how to show only unread feeds? If you make a request like feed_item_id not in (listing all viewed here) - how crazy it will turn out, the request is something like this ... And if there are thousands or tens of thousands of users, then how can all this work.
Now all this works (should work) on postgres, but if there are more correct solutions, I will be happy to hear your ideas on this matter.
And here I thought that I probably did not understand something very much. Do you have any ideas on how the "read" marking system for feeds should work?
PS: If someone wants to participate in the development - I will be very, very happy!
PPS: The main idea of my implementation is not to store a unique set of feeds for each person, but to store only unique feeds, each of which can belong to several people.
Dump of what is now:
CREATE TABLE author (
id bigint NOT NULL,
consistencyversion smallint,
email character varying(255),
link character varying(255),
name character varying(255) NOT NULL
);
ALTER TABLE public.author OWNER TO postgres;
--
-- Name: feed; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE feed (
id bigint NOT NULL,
consistencyversion smallint,
charset character varying(255),
imageurl character varying(255),
lastupdatedate timestamp without time zone,
title character varying(255),
url character varying(255) NOT NULL
);
ALTER TABLE public.feed OWNER TO postgres;
--
-- Name: feedgroup; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE feedgroup (
id bigint NOT NULL,
consistencyversion smallint,
name character varying(255) NOT NULL
);
ALTER TABLE public.feedgroup OWNER TO postgres;
--
-- Name: feedgroup_feed; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE feedgroup_feed (
feedgroup_id bigint NOT NULL,
feeds_id bigint NOT NULL
);
ALTER TABLE public.feedgroup_feed OWNER TO postgres;
--
-- Name: feeditem; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE feeditem (
id bigint NOT NULL,
consistencyversion smallint,
author character varying(255),
createdon timestamp without time zone,
text character varying(32000),
title character varying(2000),
url character varying(255),
feed_id bigint NOT NULL
);
ALTER TABLE public.feeditem OWNER TO postgres;
--
-- Name: human; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE human (
id bigint NOT NULL,
consistencyversion smallint,
email character varying(255) NOT NULL,
isactive boolean NOT NULL,
loginattempts integer NOT NULL,
passwordhash character varying(255) NOT NULL
);
ALTER TABLE public.human OWNER TO postgres;
--
-- Name: human_feedgroup; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE human_feedgroup (
human_id bigint NOT NULL,
subscribedfeeds_id bigint NOT NULL
);
ALTER TABLE public.human_feedgroup OWNER TO postgres;
--
-- Name: author_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY author
ADD CONSTRAINT author_pkey PRIMARY KEY (id);
--
-- Name: feed_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY feed
ADD CONSTRAINT feed_pkey PRIMARY KEY (id);
--
-- Name: feedgroup_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY feedgroup
ADD CONSTRAINT feedgroup_pkey PRIMARY KEY (id);
--
-- Name: feeditem_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY feeditem
ADD CONSTRAINT feeditem_pkey PRIMARY KEY (id);
--
-- Name: human_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY human
ADD CONSTRAINT human_pkey PRIMARY KEY (id);
--
-- Name: uk_add752afd96c715f; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY human_feedgroup
ADD CONSTRAINT uk_add752afd96c715f UNIQUE (subscribedfeeds_id);
--
-- Name: uk_feed_1; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY feed
ADD CONSTRAINT uk_feed_1 UNIQUE (url);
--
-- Name: uk_human_1; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY human
ADD CONSTRAINT uk_human_1 UNIQUE (email);
--
-- Name: authot_email_index; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX authot_email_index ON author USING btree (email);
--
-- Name: item_date_index; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX item_date_index ON feeditem USING btree (createdon);
--
-- Name: item_title_index; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX item_title_index ON feeditem USING btree (title);
--
-- Name: item_url; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX item_url ON feeditem USING btree (url);
--
-- Name: fkadd752afc01fb76; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY human_feedgroup
ADD CONSTRAINT fkadd752afc01fb76 FOREIGN KEY (subscribedfeeds_id) REFERENCES feedgroup(id);
--
-- Name: fkadd752affedf9830; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY human_feedgroup
ADD CONSTRAINT fkadd752affedf9830 FOREIGN KEY (human_id) REFERENCES human(id);
--
-- Name: fkd1f0f3dc6b7b6890; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY feedgroup_feed
ADD CONSTRAINT fkd1f0f3dc6b7b6890 FOREIGN KEY (feedgroup_id) REFERENCES feedgroup(id);
--
-- Name: fkd1f0f3dcd280a84d; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY feedgroup_feed
ADD CONSTRAINT fkd1f0f3dcd280a84d FOREIGN KEY (feeds_id) REFERENCES feed(id);
--
-- Name: fkf86539f1a3b648a4; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY feeditem
ADD CONSTRAINT fkf86539f1a3b648a4 FOREIGN KEY (feed_id) REFERENCES feed(id);
Answer the question
In order to leave comments, you need to log in
table post_user(userid, postid, isread)
select
post_content
from post_user
inner join posts
where userid = :userid
and isread = False
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question