5,196 karma · joined Dec 8, 2012 (13y ago) · 1,580 submissions
Twitter: @eksith
Email: reksith at google's email thingy.
Web: eksith.com | eksith.neocities.org
When engaging in a pointless argument on HN, please heed the following advice: https://news.ycombinator.com/item?id=5976026
comment 12y ago · link · parent
I.E. Things categorized by tags or groups where 1-to-n relationships are necessary. Of course, the extreme of this is EAV (Entity Attribute Value) which I would limit to meta/taxonomy data for performance reasons.
But for information where the labels (or quantity) aren't known before input are easier to deal with in normalized databases.
E.G. Getting metadata on a specific entry with no prior knowlege of said data except parent id:
SELECT id, label, content FROM meta WHERE id IN (
SELECT meta_id FROM posts_meta WHERE post_id = :id
);
Or if you're using Postgres, you can return the metadata as an associative array. E.G. http://stackoverflow.com/a/11942726The following is an excerpt from the actual schema I used on a very simple forum that ran on SQLite for years before switching to Postgres fairly recently. The normalization (varying forms) afforded a lot of flexibility. Maybe someone will find it useful.
CREATE TABLE posts (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT NULL,
title VARCHAR NULL,
summary TEXT NOT NULL,
body TEXT NOT NULL,
plain TEXT NOT NULL,
quality FLOAT NOT NULL DEFAULT 0,
status INTEGER NOT NULL DEFAULT 0,
reply_count INTEGER NOT NULL DEFAULT 0,
auth_key VARCHAR NOT NULL
);
CREATE INDEX idx_posts_on_status ON posts ( status );
CREATE INDEX idx_posts_on_created_at ON posts ( created_at );
CREATE VIRTUAL TABLE posts_search USING fts4 ( search_data );
CREATE TABLE posts_family (
parent_id INTEGER NOT NULL,
child_id INTEGER NOT NULL,
PRIMARY KEY ( child_id, parent_id )
);
CREATE TABLE taxonomy (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
label VARCHAR NOT NULL,
term VARCHAR NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT NULL,
status INTEGER NOT NULL DEFAULT 0
);
CREATE TABLE posts_taxonomy (
post_id INTEGER NOT NULL,
taxonomy_id INTEGER NOT NULL,
PRIMARY KEY ( post_id, taxonomy_id )
);
CREATE TABLE taxonomy_family (
parent_id INTEGER NOT NULL,
child_id INTEGER NOT NULL,
PRIMARY KEY ( child_id, parent_id )
);
CREATE TABLE meta (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
label VARCHAR NOT NULL,
parse_as VARCHAR NOT NULL DEFAULT "text",
content TEXT NOT NULL
);
CREATE TABLE posts_meta (
post_id INTEGER NOT NULL,
meta_id INTEGER NOT NULL,
PRIMARY KEY ( post_id, meta_id )
);
CREATE UNIQUE INDEX idx_taxonomy_on_terms ON taxonomy ( label ASC, term ASC );
CREATE INDEX idx_taxonomy_on_status ON taxonomy ( status );
-- Triggers
-- Post create procedures
CREATE TRIGGER post_after_insert AFTER INSERT ON posts FOR EACH ROW
BEGIN
INSERT INTO posts_search ( docid, search_data )
VALUES ( NEW.rowid, NEW.plain );
UPDATE posts SET updated_at = CURRENT_TIMESTAMP WHERE id = NEW.rowid;
END;
-- Post update procedures
CREATE TRIGGER post_before_update BEFORE UPDATE ON posts FOR EACH ROW
BEGIN
DELETE FROM posts_search WHERE docid = OLD.rowid;
END;
CREATE TRIGGER post_after_update AFTER UPDATE ON posts FOR EACH ROW
BEGIN
INSERT INTO posts_search ( docid, search_data )
VALUES ( NEW.rowid, NEW.plain );
UPDATE posts SET updated_at = CURRENT_TIMESTAMP WHERE id = NEW.rowid;
END;
-- Post deletion procedure
CREATE TRIGGER post_before_delete BEFORE DELETE ON posts FOR EACH ROW
BEGIN
UPDATE posts SET reply_count = ( reply_count - 1 )
WHERE id != OLD.rowid AND id IN (
SELECT parent_id FROM posts_family WHERE child_id = OLD.rowid
);
DELETE FROM posts_family WHERE parent_id = OLD.rowid OR child_id = OLD.rowid;
DELETE FROM posts_search WHERE docid = OLD.rowid;
DELETE FROM posts_taxonomy WHERE post_id = OLD.rowid;
DELETE FROM meta WHERE id IN (
SELECT meta_id FROM posts_meta WHERE post_id = OLD.rowid
);
DELETE FROM posts_meta WHERE post_id = OLD.rowid;
END;
-- Post parent insert procedures
CREATE TRIGGER posts_family_after_insert AFTER INSERT ON posts_family FOR EACH ROW
BEGIN
UPDATE posts SET reply_count = ( reply_count + 1 ) WHERE id IN (
SELECT parent_id FROM posts_family WHERE child_id = NEW.rowid
);
END;
-- Taxonomy procedures
CREATE TRIGGER taxonomy_after_insert AFTER INSERT ON taxonomy FOR EACH ROW
BEGIN
UPDATE taxonomy SET updated_at = CURRENT_TIMESTAMP WHERE id = NEW.rowid;
END;
CREATE TRIGGER taxonomy_after_update AFTER UPDATE ON taxonomy FOR EACH ROW
BEGIN
UPDATE taxonomy SET updated_at = CURRENT_TIMESTAMP WHERE id = NEW.rowid;
END;
CREATE TRIGGER taxonomy_before_delete BEFORE DELETE ON taxonomy FOR EACH ROW
BEGIN
DELETE FROM posts_taxonomy WHERE taxonomy_id = OLD.rowid;
DELETE FROM taxonomy_family WHERE parent_id = OLD.rowid OR child_id = OLD.rowid;
END;comment 12y ago · link · parent
Although that was for a ground-effect craft[2], the long flat deck seemed perfect to mount solar panels. I'm not well versed in hydrodynamics, but I imagine the smaller contact area with the water would reduce drag for the initial launch phase as well.
123.
iOS8 will predict your passwords(qz.com ↗)
4 points · by eksith · 12y ago · discuss
comment 12y ago · link · parent
But just like with MySQL, I imagine those who can migrate to another DB would do so at the first opportunity or wait for the equivalent of MariaDB to make a "drop-in replacement" in lieu of messing with their application code.
125.
Fake fingerprint fools iPhone 6 Touch ID(arstechnica.com ↗)
2 points · by eksith · 12y ago · discuss
comment 12y ago · link · parent
Mallach agreed with Surfrider that closing the gate amounted to “a change
in intensity of use,” That change, she said, could be considered development
under the law. As a result, she said in her ruling, Khosla must apply
for a coastal development permit if he wants to close the gate or make other
changes to the property.
Removing public access means he intends to use the land privately. While what constitutes "use" is debatable, these are moot points considering the laws passed in 1972 and 1976: prohibit homes or developments from blocking access to beaches. They essentially
make the entire coast, including all beach property below the mean high tide line,
public property.comment 12y ago · link · parent
Access was in the law books before his purchase and claiming the 1848 Treaty of Guadalupe Hidalgo as being present before the 1972 Coastal Zone law is ridiculous in the extreme. There were many other things legal in 1848 that aren't today for very good reasons.
"The judge could have fined Khosla $15,000 a day for every day the gates were shut,
but she waived all fines."
Why?comment 12y ago · link · parent
There are erroneous deductions that can happen if you don't keep an eye on automatic payments and there are horror stories of overbillings, overdrafts etc... so that scares away some people too.
comment 12y ago · link · parent
comment 12y ago · link · parent
132.
Ashkenazi Jewish population has distinctive, yet similar genomes(arstechnica.com ↗)
2 points · by eksith · 12y ago · discuss
134.
Musings on Deep Learning(medium.com ↗)
2 points · by eksith · 12y ago · discuss
135.
End User Devices Security and Configuration Guidance(gov.uk ↗)
1 points · by eksith · 12y ago · discuss
137.
An Efficient and Provable Secure Revocable Identity-Based Encryption Scheme(plosone.org ↗)
6 points · by eksith · 12y ago · discuss
comment 12y ago · link · parent
While it's true our lives are better than in the Middle Ages, stories like this and the myriad of misconceptions and outright lies that follow cannabis really demonstrate, superstition still rules law. We've clothed ourselves in technology, but not wisdom.
comment 12y ago · link · parent
Why couldn't Apple have designed it to remove itself from the burden of having to play fisherman? While it's true that there may have been moral drivers in this design decision, it makes sound business sense as well.
You can't betray what you don't know. Which is the ultimate position to take in order to be competitive in a privacy conscious world. Besides, warrants are rubber stamps now (as pointed out here and many places elsewhere) and are by no means the carefully measured moderator of state influence they may have once been.
140.
Joan Pujol Garcia(en.wikipedia.org ↗)
1 points · by eksith · 12y ago · discuss
comment 12y ago · link · parent
comment 12y ago · link · parent
I do agree that the FDA is largely ineffective at preventing people from doing things to their bodies.
Ironically, the FDA would probably be able to better serve the public if it switches roles from enforcement to advisement. Keeping food, medication/devices and production methods to FDA standard, I believe, should get a UL type verification for things we use every day. Having that stamp brings trust that the FDA has verified the efficacy of whatever it is you put into your system, however there's nothing preventing you from going non UL if you're aware of the risks.
edit_ To the folks downvoting your post, I disagree with them as well!
comment 12y ago · link · parent
If anyone is interested in another tiny Linux version, not necessarily for education, but personal use, I'd recommend CrunchBang (based on Debian). If you have an old laptop you want to give someone or a new netbook that doesn't have a CD drive, it's very easy to install via USB.
Edit: I just realized, "tiny" doesn't quit fit CB. So let's call it efficient and simple instead.
149.
One man’s journey to restore Star Trek’s bridge(arstechnica.com ↗)
6 points · by eksith · 12y ago · discuss