TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Super-Structured Data: Rethinking the Schema

108 点作者 mccanne将近 3 年前

16 条评论

simonw将近 3 年前
&gt; The idea here is that instead of manually creating schemas, what if the schemas were automatically created for you? When something doesn’t fit in a table, how about automatically adding columns for the missing fields?<p>I&#x27;ve been experimenting with this approach against SQLite for a few years now, and I really like it.<p>My sqlite-utils package does exactly this. Try running this on the command line:<p><pre><code> brew install sqlite-utils echo &#x27;[ {&quot;id&quot;: 1, &quot;name&quot;: &quot;Cleo&quot;}, {&quot;id&quot;: 2, &quot;name&quot;: &quot;Azy&quot;, &quot;age&quot;: 1.5} ]&#x27; | sqlite-utils insert &#x2F;tmp&#x2F;demo.db creatures - --pk id sqlite-utils schema &#x2F;tmp&#x2F;demo.db </code></pre> It outputs the generated schema:<p><pre><code> CREATE TABLE [creatures] ( [id] INTEGER PRIMARY KEY, [name] TEXT, [age] FLOAT ); </code></pre> When you insert more data you can use the --alter flag to have it automatically create any missing columns.<p>Full documentation here: <a href="https:&#x2F;&#x2F;sqlite-utils.datasette.io&#x2F;en&#x2F;stable&#x2F;cli.html#inserting-json-data" rel="nofollow">https:&#x2F;&#x2F;sqlite-utils.datasette.io&#x2F;en&#x2F;stable&#x2F;cli.html#inserti...</a><p>It&#x27;s also available as a Python library: <a href="https:&#x2F;&#x2F;sqlite-utils.datasette.io&#x2F;en&#x2F;stable&#x2F;python-api.html" rel="nofollow">https:&#x2F;&#x2F;sqlite-utils.datasette.io&#x2F;en&#x2F;stable&#x2F;python-api.html</a>
评论 #31417550 未加载
mamcx将近 3 年前
Note: The relational model (even SQL) is THIS.<p>Despite the claims, SQL is NOT &quot;schema-fixed&quot;.<p>You can 100% create new schemas, alter them and modify them.<p>What actual happens is that if you have a CENTRAL repository of data (aka &quot;source of truth&quot;), then you bet you wanna &quot;freeze&quot; your schemas (because is like a API, where you need to fulfill contracts).<p>--<p>SQL have limitations in lack of composability, the biggest reason &quot;NoSQL&quot; work is this: A JSON is composable. A &quot;stringy&quot; SQL is not. If SQL were really around &quot;relations, tupes&quot; like (stealing from my project, TablaM):<p><pre><code> [Customer id:i32, name:Str; 1, &quot;Jhon&quot;] </code></pre> then developers will have less reason to go elsewhere.
评论 #31413366 未加载
评论 #31412759 未加载
评论 #31415056 未加载
CharlesW将近 3 年前
The words &quot;anarchy&quot; and &quot;authoritarianism&quot; seem unnecessarily emotional and pejorative, and because of their semantic baggage I personally wouldn&#x27;t use them in a professional situation. The author counts on the emotional color of those words to attempt an argument that both are somehow bad.<p>Instead of those words I&#x27;d suggest something like &quot;schema on write&quot; vs. &quot;schema on read&quot;, or &quot;persisted structured&quot; vs. &quot;persisted unstructured&quot;. &quot;Document&quot; vs. &quot;relational&quot; doesn&#x27;t quite capture it, since unstructured data can have late-binding relations applied at read time, and structured data doesn&#x27;t have to be relational.<p>And of course, modern relational databases can store unstructured data as easily as structured data.
anentropic将近 3 年前
The first few sections of this post nearly lost me, waffling on about NoSQL vs whatever.<p>Eventually we get to the meat:<p>&gt; <i>For example, the JSON value</i><p><pre><code> {&quot;s&quot;:&quot;foo&quot;,&quot;a&quot;:[1,&quot;bar&quot;]} </code></pre> &gt; <i>would traditionally be called “schema-less” and in fact is said have the vague type “object” in the world of JavaScript or “dict” in the world of Python. However, the super-structured interpretation of this value’s type is instead:</i><p>&gt; <i>type record with field s of type string and field a of type array of type union of types integer and string</i><p>&gt; <i>We call the former style of typing a “shallow” type system and the latter style of typing a “deep” type system. The hierarchy of a shallow-typed value must be traversed to determine its structure whereas the structure of a deeply-typed value is determined directly from its type.</i><p>This is a bit confusing, since JSON data commonly has an implicit schema, or &quot;deep type system&quot; as this post calls it, and if you consume data in any statically-typed language you will materialise the implicit &quot;deep&quot; types in your host language.<p>So it seems that ZSON is sort of like a TypeScript-ified version of JSON, where the implicit types are made explicit.<p>It seems the point is not to have an external schema that documents must comply to, so I guess at the end of the day has similar aim to other &quot;self-describing&quot; message formats like <a href="https:&#x2F;&#x2F;amzn.github.io&#x2F;ion-docs&#x2F;" rel="nofollow">https:&#x2F;&#x2F;amzn.github.io&#x2F;ion-docs&#x2F;</a> ? i.e. each message has its own schema<p>So the interesting part is perhaps the new data tools to work with large collections of self-describing messages?
评论 #31415028 未加载
评论 #31418720 未加载
troelsSteegin将近 3 年前
It looks like the use case is specifying types for dataflow operators (aka endpoints for dataflow pipes) [0] and I surmise composition should be super easy. I was surprised not to see any mention of XML or XML Schema as prior art, especially with their discussion of schema registries. Edit: Oh, the point of reference is Kafka [1]<p>[0] <a href="https:&#x2F;&#x2F;zed.brimdata.io&#x2F;docs&#x2F;language&#x2F;overview&#x2F;" rel="nofollow">https:&#x2F;&#x2F;zed.brimdata.io&#x2F;docs&#x2F;language&#x2F;overview&#x2F;</a> [1] <a href="https:&#x2F;&#x2F;docs.confluent.io&#x2F;platform&#x2F;current&#x2F;schema-registry&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;docs.confluent.io&#x2F;platform&#x2F;current&#x2F;schema-registry&#x2F;i...</a>
评论 #31411995 未加载
kmerroll将近 3 年前
Interesting discussion, but buried in a lot of legacy thinking about schemas and personally, I don&#x27;t find Yet-Another-Schema-Abstraction (YASA)™ layer very compelling when better solutions in functional programming and semantic ontologies are far ahead in this area.<p>Suggest looking into JSON-LD which was intended to solve many of the type and validation use-cases related to type and schema.
评论 #31416103 未加载
评论 #31416517 未加载
评论 #31416111 未加载
difflens将近 3 年前
Perhaps I don&#x27;t understand their use case fully, but it seems to me that every schema can be defined as a child protobuf message, and each child can then be added to a oneof field of a parent protobuf message. This way, you get the strict&#x2F;optional type checks that are required, and the efficiency and ecosystem around protobufs.
评论 #31412281 未加载
tabtab将近 3 年前
&quot;Dynamic Relational&quot; needs to be implemented. Columns and (optionally) tables are &quot;create on write&quot;. If you issue &quot;SELECT nonExistingColumn FROM myTable&quot; you get nulls (if rows exist), not an error. One can incrementally &quot;lock down&quot; the schema as a project matures by adding constraints. Unlike the &quot;NoSql&quot; movement, it does <i>not</i> throw out most of RDBMS concepts, just tweaks them only enough to be dynamic-friendly. This reduces the learning curve.
natemcintosh将近 3 年前
So it sounds like one of the advantages of the Zed ecosystem is that its data can go into three file formats (zson, zng, zst), each designed for a specific use case, and convert between them easily and without loss.<p>And it seems like the newer &quot;zed lake&quot; format is like a large blob managed by a server. Can you also convert data to and from and the file formats to the lake format? What is the lake&#x27;s main use case?
评论 #31441626 未加载
bthomas将近 3 年前
I didn&#x27;t follow this part:<p>&gt; EdgeDB is essentially a new data silo whose type system cannot be used to serialize data external to the system.<p>I think this implies that serializing external data to zson is easier than writing an INSERT into edgedb, but not sure why that would be.
munro将近 3 年前
I love the idea of getting rid of tables, when developing application code I&#x27;m often thinking in terms of Maps&#x2F;Sets&#x2F;Lists--I wish I could just take that code and make it persistent. PRIMARY KEY is really like a map. Also I wish I had transactional memory in my application. Not sure what the future looks like, but I am loving all this development in the database space.
thinkharderdev将近 3 年前
Arrow has union types (as well as structs and dictionary types). Parquet doesn&#x27;t but I think it has an intentionally shallow types system to allow flexibility in encoding. Basically everything is either a numeric or binary and the logical type for binary columns is defined in metadata. So you can use, for instance, Arrow as the encoding.
评论 #31417317 未加载
SPBS将近 3 年前
This is a data serialization format, not a replacement for storing your business data. Your business data <i>needs</i> to have the same schema enforced everywhere, otherwise how are you going to reconcile your user data now and your user data 5 months ago if their schemas are radically different?
ccleve将近 3 年前
tldr; Don&#x27;t use relational tables or unstructured document databases. Instead use structured types. The &quot;schema&quot; here is ultimately a collection of independent objects &#x2F; classes with well-defined fields.<p>Ok, fine. But I&#x27;m not sure how this helps if you have six different systems with six different definitions of a customer, and more importantly, different relationships between customers and other objects like orders or transactions or locations or communications.<p>I don&#x27;t see their approach as ground-breaking, but it is definitely worthy of discussion.
评论 #31416144 未加载
评论 #31412165 未加载
loquisgon将近 3 年前
I got interested when the different spectrum points of json and relational were contrasted. So I read the whole thing. I got lost and disheartened when the new terminology, starting with the super-structured name was introduced and completely went downhill with the other z names. Maybe it&#x27;s just me and maybe it is like quantum mechanics and any other innovation where new names don&#x27;t make sense and feel ugly.
feoren将近 3 年前
Wow, what a waste of time. I&#x27;ve been doing it correctly for so long that I forget that virtually everyone else on the planet has no idea how to build a good data model. What pisses me off is that I actually have the right answer on how to avoid all of this pain, but if I typed it out here I&#x27;d either waste my time and get ignored or (much, much less likely) get my idea poached. It takes hours to fully communicate anyway. What do you do when you know you&#x27;re sitting on an approach &amp; tech that could revolutionize the X-hundred-billion-dollar data management industry but you can barely even get your own fucking employer to take you seriously?<p>Anyway this article is crap and gets everything wrong, just like all of you do. Whatever, nothing to see here I guess.