示例#1
0
文件: date.py 项目: bnmnetp/dee
    def __init__(self, name):
        """Define initial relvars and their initial values here
           (Called once on database creation)"""
        Database.__init__(self, name)

        if 'S' not in self:
            print "Adding S..."
            self.S = Relation(['S#', 'SNAME', 'STATUS', 'CITY'], [
                ('S1', 'Smith', 20, 'London'),
                ('S2', 'Jones', 10, 'Paris'),
                ('S3', 'Blake', 30, 'Paris'),
                ('S4', 'Clark', 20, 'London'),
                ('S5', 'Adams', 30, 'Athens'),
            ], {'pk': (Key, ['S#'])})

        if 'P' not in self:
            print "Adding P..."
            self.P = Relation(['P#', 'PNAME', 'COLOR', 'WEIGHT', 'CITY'], [
                ('P1', 'Nut', 'Red', 12, 'London'),
                ('P2', 'Bolt', 'Green', 17, 'Paris'),
                ('P3', 'Screw', 'Blue', 17, 'Rome'),
                ('P4', 'Screw', 'Red', 14, 'London'),
                ('P5', 'Cam', 'Blue', 12, 'Paris'),
                ('P6', 'Cog', 'Red', 19, 'London'),
            ], {'pk': (Key, ['P#'])})

        if 'SP' not in self:
            print "Adding SP..."
            self.SP = Relation(
                ['S#', 'P#', 'QTY'], [
                    ('S1', 'P1', 300),
                    ('S1', 'P2', 200),
                    ('S1', 'P3', 400),
                    ('S1', 'P4', 200),
                    ('S1', 'P5', 100),
                    ('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#'
                    })),
                })
示例#2
0
文件: date.py 项目: bnmnetp/dee
    def __init__(self, name):
        """Define initial relvars and their initial values here
           (Called once on database creation)"""
        Database.__init__(self, name)

        if 'S' not in self:
            print "Adding S..."
            self.S = Relation(['S#', 'SNAME',    'STATUS', 'CITY'],
                        [('S1', 'Smith',    20,     'London'),
                         ('S2', 'Jones',    10,     'Paris'),
                         ('S3', 'Blake',    30,     'Paris'),
                         ('S4', 'Clark',    20,     'London'),
                         ('S5', 'Adams',    30,     'Athens'),
                        ],
                        {'pk':(Key,['S#'])})

        if 'P' not in self:
            print "Adding P..."
            self.P = Relation(['P#', 'PNAME',    'COLOR',    'WEIGHT', 'CITY'],
                        [('P1', 'Nut',      'Red',      12,     'London'),
                         ('P2', 'Bolt',     'Green',    17,     'Paris'),
                         ('P3', 'Screw',    'Blue',     17,     'Rome'),
                         ('P4', 'Screw',    'Red',      14,     'London'),
                         ('P5', 'Cam',      'Blue',     12,     'Paris'),
                         ('P6', 'Cog',      'Red',      19,     'London'),
                        ],
                        {'pk':(Key,['P#'])})

        if 'SP' not in self:
            print "Adding SP..."
            self.SP = Relation(['S#', 'P#', 'QTY'],
                         [('S1', 'P1', 300),
                          ('S1', 'P2', 200),
                          ('S1', 'P3', 400),
                          ('S1', 'P4', 200),
                          ('S1', 'P5', 100),
                          ('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#'})),
                          }
                        )
示例#3
0
文件: darwen.py 项目: bnmnetp/dee
    def __init__(self, name):
        """Define initial relvars and their initial values here
           (Called once on database creation)"""
        Database.__init__(self, name)

        if 'IS_CALLED' not in self:
            print "Adding IS_CALLED..."
            self.IS_CALLED = Relation(['StudentId', 'Name'],
                                 [('S1', 'Anne'),
                                  ('S2', 'Boris'),
                                  ('S3', 'Cindy'),
                                  ('S4', 'Devinder'),
                                  ('S5', 'Boris'),
                                 ]
                                )

        if 'IS_ENROLLED_ON' not in self:
            print "Adding IS_ENROLLED_ON..."
            self.IS_ENROLLED_ON = Relation(['StudentId', 'CourseId'],
                                     [('S1', 'C1'),
                                      ('S1', 'C2'),
                                      ('S2', 'C1'),
                                      ('S3', 'C3'),
                                      ('S4', 'C1'),
                                     ]
                                    )

        if 'COURSE' not in self:
            print "Adding COURSE..."
            self.COURSE = Relation(['CourseId', 'Title'],
                              [('C1', 'Database'),
                               ('C2', 'HCI'),
                               ('C3', 'Op Systems'),
                               ('C4', 'Programming'),
                              ]
                             )

        if 'EXAM_MARK' not in self:
            print "Adding EXAM_MARK..."
            self.EXAM_MARK = Relation(['StudentId', 'CourseId', 'Mark'],
                                 [('S1', 'C1', 85),
                                  ('S1', 'C2', 49),
                                  ('S2', 'C1', 49),
                                  ('S3', 'C3', 66),
                                  ('S4', 'C1', 93),
                                 ]
                                )
示例#4
0
文件: darwen.py 项目: bnmnetp/dee
    def __init__(self, name):
        """Define initial relvars and their initial values here
           (Called once on database creation)"""
        Database.__init__(self, name)

        if 'IS_CALLED' not in self:
            print "Adding IS_CALLED..."
            self.IS_CALLED = Relation(['StudentId', 'Name'], [
                ('S1', 'Anne'),
                ('S2', 'Boris'),
                ('S3', 'Cindy'),
                ('S4', 'Devinder'),
                ('S5', 'Boris'),
            ])

        if 'IS_ENROLLED_ON' not in self:
            print "Adding IS_ENROLLED_ON..."
            self.IS_ENROLLED_ON = Relation(['StudentId', 'CourseId'], [
                ('S1', 'C1'),
                ('S1', 'C2'),
                ('S2', 'C1'),
                ('S3', 'C3'),
                ('S4', 'C1'),
            ])

        if 'COURSE' not in self:
            print "Adding COURSE..."
            self.COURSE = Relation(['CourseId', 'Title'], [
                ('C1', 'Database'),
                ('C2', 'HCI'),
                ('C3', 'Op Systems'),
                ('C4', 'Programming'),
            ])

        if 'EXAM_MARK' not in self:
            print "Adding EXAM_MARK..."
            self.EXAM_MARK = Relation(['StudentId', 'CourseId', 'Mark'], [
                ('S1', 'C1', 85),
                ('S1', 'C2', 49),
                ('S2', 'C1', 49),
                ('S3', 'C3', 66),
                ('S4', 'C1', 93),
            ])
    def __init__(self, name):
        Database.__init__(self, name)

        if 'DEPARTMENT' not in self:
            self.DEPARTMENT = Relation(["did", "name"], [(1, 'COMP'),
                                                         (2, 'MATH'),
                                                         (3, 'ANTH')],
                                       {'PK': (Key, ["did"])})
        if 'STUDENT' not in self:
            self.STUDENT = Relation(
                ["sid", "did", 'fname', 'lname'],
                [(1, 1, 'MARY', 'Smith'), (2, 1, 'PATRICIA', 'Johnson'),
                 (3, 1, 'JAMES', 'Williams'), (4, 1, 'ROBERT', 'Jones'),
                 (5, 2, 'MICHAEL', 'Brown'), (6, 2, 'WILLIAM', 'Davis'),
                 (7, 2, 'LINDA', 'Miller'), (8, 3, 'BARBARA', 'Wilson'),
                 (9, 3, 'DAVID', 'Moore'), (10, 3, 'RICHARD', 'Taylor'),
                 (11, 3, 'MICHAEL', 'Jordan')], {
                     'PK': (Key, ["sid"]),
                     'FKS': (ForeignKey, ('DEPARTMENT', {
                         "did": "did"
                     }))
                 })
        if 'COURSE' not in self:
            self.COURSE = Relation(
                ["cid", "did", 'name', 'num', 'creditHours'],
                [(1, 1, 'Data Structures', 410, 3),
                 (2, 1, 'Computer Organization', 411, 3),
                 (3, 1, 'Files and Databases', 521, 3),
                 (4, 1, 'Software Engineering Laboratory', 523, 4),
                 (5, 2, 'Discrete Mathematics', 381, 3),
                 (6, 2, 'First Course in Differential Equations', 383, 3),
                 (7, 2, 'Advanced Calculus I', 521, 3),
                 (8, 3, 'The Past in the Present', 452, 3),
                 (9, 3, 'Anthropology of the Body and the Subject', 473, 4),
                 (10, 3, 'Visual Anthropology', 477, 3)], {
                     '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"
                                            }))
                                        })