Skip to content

Commit 8c06e88

Browse files
committed
updated sql schema
1 parent e130617 commit 8c06e88

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

lib/databases/base_sql.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import sqlalchemy
22
from sqlalchemy import Column, Integer, Text, String, Enum, DateTime, ForeignKey, relationship
3-
from sqlalchemy.dialects import ARRAY
43
from sqlalchemy.orm import sessionmaker
54
from sqlalchemy.ext.declarative import declarative_base
65

@@ -29,6 +28,7 @@ class UserNode(Base):
2928
parent = Column(Integer, ForeignKey('id'))
3029
owner = Column(Integer, ForeignKey("users.id"))
3130
created_on = Column(DateTime)
31+
last_modified = Column(DateTime)
3232
base_node = Column(Integer, ForeignKey("id"))
3333
children = relationship("UserNodeChild", backref='usernode')
3434

@@ -39,25 +39,44 @@ class User(Base):
3939
type = Column(Enum(['admin', 'teacher', 'student']))
4040
user_nodes = relationship("UserNode")
4141
completed_content = relationship("ContentNode")
42-
#owned_material = ...
42+
owned_material = relationship("Material")
4343

4444
class ContentNode(Base):
4545
__tablename__ = "contentnode"
4646
id = Column(Integer, primary_key=True)
4747
title = Column(String(512))
4848
description = Column(Text)
49+
created_on = Column(DateTime)
50+
last_modified = Column(DateTime)
4951
creator = Column(ForeignKey('user.id'))
5052
knowledge_graph = None
5153
base_node = Column(ForeignKey('id'))
5254
grade_level = Column(Integer)
5355
recommended_time = Column(Integer)
54-
#materials = ...
55-
standards = Column(ARRAY(String))
56+
materials = relationship("Material", backref='contentnode')
57+
standards = relationship("Standard")
58+
59+
class Standard(Base):
60+
__tablename__ = 'standards'
61+
id = Column(Integer, primary_key=True)
62+
name = Column(String(64))
63+
description = Column(Text)
64+
grade = Column(Integer)
65+
66+
class Material(Base):
67+
id = Column(Integer, primary_key=True)
68+
name = Column(String(64))
69+
description = Column(Text)
70+
url = Column(Text)
71+
related_material = relationship("Material")
72+
5673

5774
_class_lookup = {
5875
"usernode" : UserNode,
5976
"user" : User,
6077
"contentnode" : ContentNode,
78+
"standard" : Standard,
79+
"material" : Material,
6180
}
6281

6382
# TODO: write save/update/get/exists for base_sql

0 commit comments

Comments
 (0)