示例#1
0
文件: darwen.py 项目: bnmnetp/dee
                                  ('S4', 'C1', 93),
                                 ]
                                )

    def _vinit(self):
        """Define virtual relvars/relconsts
           (Called repeatedly, e.g. after database load from disk or commit)
        """
        Database._vinit(self)

        if 'C_ER' not in self:
            print "Defining C_ER..."
            #this will always be the case, even when re-loading: we don't store relations with callable bodies
            self.C_ER = Relation(['CourseId', 'Exam_Result'],
                                           self.vC_ER,
                                           {'pk':(Key,['CourseId'])})

    def vC_ER(self):
        return self.COURSE.extend(['Exam_Result'], lambda t:{'Exam_Result':
                                                             (self.EXAM_MARK & GENERATE({'CourseId':t.CourseId})
                                                             )(['StudentId', 'Mark'])}
                                 )(['CourseId', 'Exam_Result']) #fixed


#Load or create the database
darwen = Database.open(darwen_Database, "darwen")

###################################
if __name__=="__main__":
    print darwen.relations
示例#2
0
文件: date.py 项目: bnmnetp/dee
                          ('S1', 'P6', 100),
                          ('S2', 'P1', 300),
                          ('S2', 'P2', 400),
                          ('S3', 'P2', 200),
                          ('S4', 'P2', 200),
                          ('S4', 'P4', 300),
                          ('S4', 'P5', 400),
                         ],
                         {'pk':(Key,['S#', 'P#']),
                          'fkS':(ForeignKey, ('S', {'S#':'S#'})),
                          'fkP':(ForeignKey, ('P', {'P#':'P#'})),
                          }
                        )



    def _vinit(self):
        """Define virtual relvars/relconsts
           (Called repeatedly, e.g. after database load from disk or commit)
        """
        Database._vinit(self)



#Load or create the database
date = Database.open(date_Database, "date")

###################################
if __name__=="__main__":
    print date.relations
示例#3
0
文件: date.py 项目: bnmnetp/dee
                    ('S1', 'P6', 100),
                    ('S2', 'P1', 300),
                    ('S2', 'P2', 400),
                    ('S3', 'P2', 200),
                    ('S4', 'P2', 200),
                    ('S4', 'P4', 300),
                    ('S4', 'P5', 400),
                ], {
                    'pk': (Key, ['S#', 'P#']),
                    'fkS': (ForeignKey, ('S', {
                        'S#': 'S#'
                    })),
                    'fkP': (ForeignKey, ('P', {
                        'P#': 'P#'
                    })),
                })

    def _vinit(self):
        """Define virtual relvars/relconsts
           (Called repeatedly, e.g. after database load from disk or commit)
        """
        Database._vinit(self)


#Load or create the database
date = Database.open(date_Database, "date")

###################################
if __name__ == "__main__":
    print date.relations
示例#4
0
文件: darwen.py 项目: bnmnetp/dee
                ('S4', 'C1', 93),
            ])

    def _vinit(self):
        """Define virtual relvars/relconsts
           (Called repeatedly, e.g. after database load from disk or commit)
        """
        Database._vinit(self)

        if 'C_ER' not in self:
            print "Defining C_ER..."
            #this will always be the case, even when re-loading: we don't store relations with callable bodies
            self.C_ER = Relation(['CourseId', 'Exam_Result'], self.vC_ER,
                                 {'pk': (Key, ['CourseId'])})

    def vC_ER(self):
        return self.COURSE.extend(
            ['Exam_Result'], lambda t: {
                'Exam_Result':
                (self.EXAM_MARK & GENERATE({'CourseId': t.CourseId}))
                (['StudentId', 'Mark'])
            })(['CourseId', 'Exam_Result'])  #fixed


#Load or create the database
darwen = Database.open(darwen_Database, "darwen")

###################################
if __name__ == "__main__":
    print darwen.relations
                     'PK': (Key, ["cid"]),
                     'FKS': (ForeignKey, ('DEPARTMENT', {
                         "did": "did"
                     }))
                 })
        if 'ENROLLED_IN' not in self:
            self.ENROLLED_IN = Relation(
                ["eid", "sid", 'cid'], [(1, 1, 1), (2, 1, 3), (3, 1, 9),
                                        (4, 1, 4), (5, 2, 1), (6, 2, 2),
                                        (7, 2, 3), (8, 2, 4), (9, 3, 1),
                                        (10, 3, 3), (11, 3, 4), (12, 3, 9),
                                        (13, 4, 2), (14, 4, 3), (15, 4, 5),
                                        (16, 4, 10), (17, 5, 5), (18, 5, 3),
                                        (19, 5, 7), (20, 6, 5), (21, 6, 6),
                                        (22, 6, 7), (23, 7, 3), (24, 7, 6),
                                        (25, 7, 9), (26, 8, 8), (27, 8, 9),
                                        (28, 8, 10), (29, 9, 3), (30, 9, 9),
                                        (31, 9, 10), (32, 10, 8), (33, 10, 9),
                                        (34, 10, 10)], {
                                            'PK': (Key, ["eid"]),
                                            'FKS': (ForeignKey, ('STUDENT', {
                                                "sid": "sid"
                                            })),
                                            'FKC': (ForeignKey, ('COURSE', {
                                                "cid": "cid"
                                            }))
                                        })


DeeDB = Database.open(CourseEnrollment_Database, "DeeDB")