Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^4: Avoiding SQL double jeopardy

by GrandFather (Saint)
on Jun 28, 2015 at 05:08 UTC ( [id://1132325]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Avoiding SQL double jeopardy
in thread Avoiding SQL double jeopardy

The big picture is we have a weekly "experience exchange" in our development team. Each week we offer a topic we are prepared to teach for 3/4 of an hour. Then at the appointed time we pair up as teacher/learner for our weekly session. Over time it is expected that we spend about as many sessions teaching as learning.

At present the process is mediated by post it notes stuck to a wall. The script is intended to replace the post it note scrum and help ensure everyone gets a more or less equal opportunity to teach and learn.

So, a person can only be in each session once. For any session a person may be a teacher or a learner. There will only ever be teacher and learner roles. Each session includes everyone who is available.

The query at the heart of the issue is to find all pending session pairings an individual or group of individuals are involved in.

Perl is the programming world's equivalent of English

Replies are listed 'Best First'.
Re^5: Avoiding SQL double jeopardy
by Pope-O-Matik (Pilgrim) on Jun 28, 2015 at 09:25 UTC

    Thank you, i think i got it now. :) Two more clarifications, though: Can there be more than one teacher per session? Can there be more than one student per session? That is, "by definition" as opposed to how it just happens to work out.

      Hmmm there is a little confusion of nomenclature (my fault). Properly speaking we have one XR (eXperience Replication) session a week. People pair up as a teacher and learner. If there is an odd number of people one "pair" will have one teacher and two learners.

      The current Sessions table identifies sessions by DrawDate and contains a "SessionId" which I should rename to PairId. There will be multiple pairs per weekly session.

      PairId is unique in the Sessions table but there will be multiple entries (generally two) in the SessPeople table (which I should rename to the Pairs table) for each PairId.

      Perl is the programming world's equivalent of English

        Okay, so always on teacher, 1 or more Learners.

        Are subjects a set thing? That is, only a limited amount of subjects (expanded at will), or can it be anything, that is, just a quick note.

        I don't believe you need a session id. As one person can only teach one session at a time, the natural key is Teacher/Time. And for Person, shouldn't it be employee? And, do Employees already have unique id, such as their company email address?

        Here's an attempt at it:

        CREATE TABLE Employee ( Id NUMBER PRIMARY KEY AUTOINCREMENT, First_Name TEXT, Last_Name TEXT ); CREATE TABLE Topic ( Name TEXT CHECK(Name = LOWER(Name)) PRIMARY KEY, Description TEXT ); CREATE TABLE Session ( Teacher INTEGER REFERENCES Employee, Start DATETIME, Finish DATETIME, Topic TEXT NOT NULL REFERENCES Topic, PRIMARY KEY(Teacher, Start) ); CREATE TABLE Session_Learner ( Teacher NUMBER, Start DATETIME, Learner NUMBER NOT NULL REFERENCES Employee, -- FOREIGN KEY(Teacher, Start) REFERENCES Session, PRIMARY KEY(Teacher, Start, Learner) ); CREATE VIEW Session_Employee AS WITH Session_Teacher_Learner AS ( SELECT Session.Teacher, Session.Start, Session.Topic, Session_Learner.Learner FROM Session, Session_Learner WHERE Session_Learner.Teacher = Session.Teacher AND Session_Learner.Start = Session.Start ) SELECT Teacher, Start, Topic, Teacher Employee FROM Session_Teacher_Learner UNION ALL SELECT Teacher, Start, Topic, Learner FROM Session_Teacher_Learner;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1132325]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-19 20:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found