Re: Damsel in distress!

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Victoria Chin (denryoku_at_hotmail.com)
Date: 02/27/04


Date: Fri, 27 Feb 2004 06:57:08 -0800

Thank you for your response. You will have to forgive me
on the terminology, I'm not a MCDBA, I am trying to learn
it though. I am trying to write this in SQL and your post
has helped. Thanks again. Vicky
>-----Original Message-----
>I love the title to this posting. Unfortunately, you did
not bother
>with any DDL and (if I am guessing correctly) are not
writting in SQL
>Server. Oh, and have a bad schema design.
>
>Have you ever met anyone with a CHAR(50) name? Even
Greek and Polish
>names are under CHAR(30)! You should have some other
identifier for the
>employees, not just their name. Also, "who" is a
question and not a
>name for a data element.
>
>Next, there is no such thing as "id" -- the magic, all-
purpose,
>one-size-fits-all unique-ifier. RDBMS uses keys; by
defintion a key is
>a subset of the attribures of the entity in the data
model.
>Auto-numbering is crap that imitates a sequential file
system and should
>never be used inside a database -- save it for cursors
and other
>sequential applications.
>
>Finally, time exists in durations, not points; see Zeno's
paradoxes and
>Einstein's physics for the details. You need a start and
a stop time.
>
>You also need to read ISO-11179 so you will not use names
like "leave"
>and "who" for a code. Are the leave types really CHAR
(10)? That is long
>for a code and it invites errors. Are tehre really soooo
many of them
>and/or dothey change sooo often that you need to put them
in another
>table? Probably not; I'd guess a CHECK() is better.
>
>Therefore, the table you should have designed looks like
this, perhaps
>with a few more constraints and columns (columns and
rows, NOT fields
>and records!!).
>
>CREATE TABLE TimeCards
>(emp_id INTEGER NOT NULL,
> REFERENCES Personnel(emp_id)
> ON UPDATE CASCADE,
> time_in DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
> time_out DATETIME,
> leave_type CHAR(10) DEFAULT 'Screwing off' NOT NULL
> CHECK (leave_type IN (..))
> PRIMARY KEY (emp_id, time_in));
>
>The NULL clock_out time means "still at work"; you fill
it in when they
>leave the job.
>
>>> If they don't come to work, no record [sic] is created
in the table
>that day. It works great, however, my boss now wants a
record [sic]
>created automatically for employees when they do
not "clock in". <<
>
>Since we did not get any specs, I am going to assume that
an absent
>employee is shown as (1) leave_type = 'not at work' (2)
time_in =
>time_out (3) The work day starts at 00:00 Hrs; I know it
is probably
>more like 08:00 Hrs, but this is a nice fiction.
>
>You will need a Calendar table (you can Google details in
several
>postings here) that shows the work days. Run this query
before you have
>to do a report.
>
>INSERT INTO Timecards (emp_id, time_in, time_out)
>SELECT P1.emp_id, C1.cal_date, C1.cal_date
> FROM Personnel AS P1,
> Calendar AS C1
> WHERE C1.date_type = 'work'
> AND NOT EXISTS
> (SELECT *
> FROM Timecards AS T1
> WHERE T1.emp_id = P1.emp_id
> AND C1.cal_date
> = EXTRACT(DATE FROM T1.clock_in));
>
>I lapsed into Standard SQL with EXTTRACT(), but you can
use whatever
>your dialect has. I left the DEFAULT value take effect.
In English
>this says: Look at the personnel and the work days, and
see that a
>timecard exists for everyone; if it does not exist, then
insert one for
>that work day.
>
>--CELKO--
> ===========================
> Please post DDL, so that people do not have to guess
what the keys,
>constraints, Declarative Referential Integrity,
datatypes, etc. in your
>schema are.
>
>*** Sent via Developersdex http://www.developersdex.com
***
>Don't just participate in USENET...get rewarded for it!
>.
>



Relevant Pages

  • Re: Calendar Form
    ... If it's the name of a query, I need to see the SQL of that query. ... My Calendar form opens, and I can add information into it, as well as ... The fact that the previous line (Dim db As DAO.Database) doesn't ...
    (microsoft.public.access.forms)
  • Re: Calendar display of information from database too slow
    ... > I'm using the calendar control to display information from a SQL ... I use a stored procedure to execute seven select ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Between...And; To Two Different Fields
    ... However, as mentioned above, the Query is still not working. ... Below is my SQL: ... Basically, I have a Form set up, and it is linked to a Calendar. ... Calendar dates go into two TextBoxes just fine, but I can't seem to pass the ...
    (microsoft.public.access.queries)
  • RE: Room Availability Query
    ... I having a problem understanding how you excute your SQL code. ... Private Sub cboStartDate_MouseDown(Button As Integer, Shift As Integer, X As ... ' Note which combo box called the calendar ... Set cboOriginator = cboStartDate ...
    (microsoft.public.access.queries)
  • Re: Alternative for TOP
    ... SELECT TOPis a proprietary feature that was easy to implement in SQL ... The idea is take each salary and build a group of other salaries ... by changing @n and playing with the two comparison operators. ... FROM Personnel AS P1, Personnel AS P2 ...
    (microsoft.public.sqlserver.programming)