You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Core types provide **portability** — the same table definition works on both MySQL and PostgreSQL. For example, `bytes` maps to `LONGBLOB` on MySQL but `BYTEA` on PostgreSQL; `uuid` maps to `BINARY(16)` on MySQL but native `UUID` on PostgreSQL. Native types can be used directly but sacrifice cross-backend compatibility.
59
+
48
60
## Layer 1: Native Database Types
49
61
50
-
Backend-specific types (MySQL, PostgreSQL). **Discouraged for direct use.**
62
+
Backend-specific types. **Can be used directly at the cost of portability.**
51
63
52
64
```python
53
-
# Native types (avoid)
54
-
column : TINYINTUNSIGNED
55
-
column : MEDIUMBLOB
65
+
# Native types — work but not portable
66
+
column : TINYINTUNSIGNED# MySQL only
67
+
column : MEDIUMBLOB# MySQL only (use BYTEA on PostgreSQL)
68
+
column : SERIAL# PostgreSQL only
56
69
```
57
70
71
+
| MySQL | PostgreSQL | Portable Alternative |
72
+
|-------|------------|---------------------|
73
+
|`LONGBLOB`|`BYTEA`|`bytes`|
74
+
|`BINARY(16)`|`UUID`|`uuid`|
75
+
|`SMALLINT`|`SMALLINT`|`int16`|
76
+
|`DOUBLE`|`DOUBLE PRECISION`|`float64`|
77
+
58
78
## Layer 2: Core DataJoint Types
59
79
60
80
Standardized, scientist-friendly types that work identically across backends.
@@ -106,24 +126,24 @@ Codec types use angle bracket notation:
106
126
107
127
### Built-in Codecs
108
128
109
-
| Codec | Database | Object Store | Returns |
110
-
|-------|----------|--------------|---------|
111
-
|`<blob>`| ✅ | ✅ `<blob@>`| Python object |
112
-
|`<attach>`| ✅ | ✅ `<attach@>`| Local file path |
113
-
|`<npy@>`| ❌ | ✅ | NpyRef (lazy) |
114
-
|`<object@>`| ❌ | ✅ | ObjectRef |
115
-
|`<hash@>`| ❌ | ✅ | bytes |
116
-
|`<filepath@>`| ❌ | ✅ | ObjectRef |
129
+
| Codec | Database | Object Store |Addressing |Returns |
Additional codecs are available as separately installed packages. This ecosystem is actively expanding—new codecs are added as community needs arise.
140
+
Additional schema-addressed codecs are available as separately installed packages. This ecosystem is actively expanding—new codecs are added as community needs arise.
121
141
122
142
| Package | Codec | Description | Repository |
123
143
|---------|-------|-------------|------------|
124
-
|`dj-zarr-codecs`|`<zarr@>`| Zarr arrays with lazy chunked access |[datajoint/dj-zarr-codecs](https://github.com/datajoint/dj-zarr-codecs)|
|`dj-photon-codecs`|`<photon@>`|Schema-addressed photon imaging data formats |[datajoint/dj-photon-codecs](https://github.com/datajoint/dj-photon-codecs)|
127
147
128
148
**Installation and discovery:**
129
149
@@ -208,7 +228,7 @@ class Config(dj.Manual):
208
228
209
229
### `<npy@>` — NumPy Arrays as .npy Files
210
230
211
-
Stores NumPy arrays as standard `.npy` files with lazy loading. Returns `NpyRef` which provides metadata access (shape, dtype) without downloading.
231
+
Schema-addressed storage for NumPy arrays as standard `.npy` files. Returns `NpyRef` which provides metadata access (shape, dtype) without downloading.
212
232
213
233
```python
214
234
classRecording(dj.Computed):
@@ -241,19 +261,21 @@ result = np.mean(ref) # Downloads automatically
241
261
-**Safe bulk fetch**: Fetching many rows doesn't download until needed
242
262
-**Memory mapping**: `ref.load(mmap_mode='r')` for random access to large arrays
243
263
244
-
### `<object@>` — Path-Addressed Storage
264
+
### `<object@>` — Schema-Addressed Storage
245
265
246
-
For large/complex file structures (Zarr, HDF5). Path derived from primary key.
266
+
Schema-addressed storage for files and folders. Path mirrors the database structure: `{schema}/{table}/{pk}/{attribute}`.
247
267
248
268
```python
249
269
classProcessedData(dj.Computed):
250
270
definition ="""
251
271
-> Recording
252
272
---
253
-
zarr_data : <object@> # Stored at {schema}/{table}/{pk}/
273
+
results : <object@> # Stored at {schema}/{table}/{pk}/results/
254
274
"""
255
275
```
256
276
277
+
Accepts files, folders, or bytes. Returns `ObjectRef` for lazy access.
278
+
257
279
### `<filepath@store>` — Portable References
258
280
259
281
References to independently-managed files with portable paths.
@@ -269,11 +291,17 @@ class RawData(dj.Manual):
269
291
270
292
## Storage Modes
271
293
272
-
| Mode | Database | Object Store | Use Case |
273
-
|------|----------|--------------|----------|
274
-
| Database | Data | — | Small data |
275
-
| Hash-addressed | Metadata | Deduplicated | Large/repeated data |
Object store codecs use one of two addressing schemes:
295
+
296
+
**Hash-addressed** — Path derived from content hash (e.g., `_hash/ab/cd/abcd1234...`). Provides automatic deduplication—identical content stored once. Used by `<blob@>`, `<attach@>`, `<hash@>`.
297
+
298
+
**Schema-addressed** — Path mirrors database structure: `{schema}/{table}/{pk}/{attribute}`. Human-readable, browsable paths that reflect your data organization. No deduplication. Used by `<object@>`, `<npy@>`, and plugin codecs (`<zarr@>`, `<figpack@>`, `<photon@>`).
299
+
300
+
| Mode | Database | Object Store | Deduplication | Use Case |
0 commit comments