How should I implement this schema in MongoDB?

OK, I think you need to break this out into the basic “varieties”. You have two “entity”-style objects: User Campaign You have one “mapping”-style object: UserCampaign You have one “transactional”-style object: Click Step 1: entity Let’s start with the easy ones: User & Campaign. These are truly two separate objects, neither one really depends on … Read more

Database table design for scheduling tasks

This is the table structure i came up with; Schedule – ScheduleName – ScheduleTypeId (Daily, Weekly, Monthly, Yearly, Specific) – StartDate – IntervalInDays – Frequency – FrequencyCounter ScheduleDaily – ScheduleDailyId – ScheduleId – TimeOfDay – StartDate – EndDate ScheduleMonthly – ScheduleMonthlyId – ScheduleId – DayOfMonth – StartDate – EndDate ScheduleSpecific – ScheduleSpecificId – ScheduleId – … Read more

mongodb schema design for blogs

Article { “_id” : “A”, “title” : “Hello World”, “user_id” : 12345, “text” : ‘My test article’, “comments” : [ { ‘text’ : ‘blah’, ‘user_id’ : 654321, ‘votes’ : [987654]}, { ‘text’ : ‘foo’, ‘user_id’ : 987654, ‘votes’ : [12345, 654321] }, … ] } The basic premise here is that I’ve nested the Comments … Read more

Database design – articles, blog posts, photos, stories

Here’s one way to implement supertype/subtype tables for your app. First, the supertype table. It contains all the columns common to all subtypes. CREATE TABLE publications ( pub_id INTEGER NOT NULL PRIMARY KEY, pub_type CHAR(1) CHECK (pub_type IN (‘A’, ‘B’, ‘P’, ‘S’)), pub_url VARCHAR(64) NOT NULL UNIQUE, CONSTRAINT publications_superkey UNIQUE (pub_id, pub_type) ); Next, a … Read more

How do you store a trie in a relational database?

How about the Materialized Path design? CREATE TABLE trie ( path VARCHAR(<maxdepth>) PRIMARY KEY, …other attributes of a tree node… ); To store a word like “stackoverflow”: INSERT INTO trie (path) VALUES (‘s’), (‘st’), (‘sta’), (‘stac’), (‘stack’), (‘stacko’), (‘stackov’), (‘stackove’), (‘stackover’), (‘stackover’), (‘stackoverf’), (‘stackoverflo’), (‘stackoverflow’); The materialized path in the tree is the prefixed sequence … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)