greenelab / greenelab/tribe

Generalized database schema

Open
#57 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
3
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Here is a generalized DB schema that takes advantage of registries in `identifiers.org`. I added some comments to explain the purpose.

```python
from django.db import models

# Registry in identifiers.org
class Registry(models.Model):
name = models.CharField()
prefix = models.CharField()
description = models.CharField()
# and other attributes of a registry ...

# Entity includes common attributes of any entity (such as gene,
# publication, disease, tissue, etc)
class Entity(models.Model):
accession = models.CharField(null=True) # accession in identifiers.org
registry = models.ForeignKey(Registry, null=True)
# and other attributes shared by all entities ...

# "Gene" is one kind of entity
class Gene(models.Model):
entity = models.OneToOneField(
Entity,
on_delete=models.CASCADE,
primary_key=True,
)
# specific attributes for a gene
scientific_name = models.CharField(max_length=32)
systematic_name = models.CharField(max_length=32)
organism = models.ForeignKey(Organism, ...)

# "Publication" is another kind of entity
class Publication(models.Model):
entity = models.OneToOneField(
Entity,
on_delete=models.CASCADE,
primary_key=True,
)
# specific attributes for a publication
pmid = models.IntegerField(null=True, unique=True, db_index=True)
title = models.TextField()
authors = models.TextField()
date = models.DateField()
journal = models.TextField()
volume = models.TextField(blank=True, null=True)
pages = models.TextField(blank=True, null=True)
issue = models.TextField(blank=True, null=True)

# "Disease" is another kind of entity
class Disease(models.Model):
entity = models.OneToOneField(
Entity,
on_delete=models.CASCADE,
primary_key=True,
)
# and specific attributes for a disease ...

# "Entityset" includes common attributes for any kind of entity set.
# It may include different types of entities.
class Entityset(models.Model):
creator = models.ForeignKey(User)
title = models.TextField()
abstract = models.TextField(null=True)
slug = models.SlugField(help_text="Slugified title field", max_length=75)
public = models.BooleanField(default=False)
deleted = models.BooleanField(default=False)
fork_of = models.ForeignKey('self', editable=False, null=True)
tip_item_count = models.IntegerField(null=True)

# "Geneset" is one kind of "Entityset"
class Geneset(models.Model):
entityset = models.OneToOneField(
Entityset,
on_delete=models.CASCADE,
primary_key=True,
)
organism = models.ForeignKey(Organism)
# and other attributes for a geneset

# Similar models can be defined for "Publicationset" or "Diseaseset" ...

# Version of an Entityset
class Version(models.Model):
entityset = models.ForeignKey(entityset)
creator = models.ForeignKey(User)
ver_hash = models.CharField(db_index=True, max_length=40)
description = models.TextField(null=True)
commit_date = models.DateTimeField(auto_now_add=True)
parent = models.ForeignKey('self', null=True)

# Annotations of entities
class Annotation(models.Model):
version = models.ForeignKey(Version)
primary_entity = models.ForeignKey(Entity) # entity that is being annotated
annotator_entity = models.ForeignKey(Entity) # entity that is the annotation
```

Contributor guide

No contributing guide indexed for this repository

Research direction

No repository files or tests are named. Start by reviewing the proposed Django models and the identifiers.org registry relationships; completion would require an agreed schema design and an explicitly defined implementation scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.