473,779 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with append and delete duplicates

allingame
4 New Member
Hello Friends,

I Need help with append and delete duplicates


I have tables namely

1)emp, 2)time and 3)payroll

TABLE emp
ssn text PK
name text
regular_rate number
ot_rate number

TABLE time
regular_hours number
ot_hours number
period_from date/time
period_to date/time
check_date date/time
deductions number

TABLE payroll
ssn text
name text
regular_rate number
ot_rate number
regular_hours number
ot_hours number
period_from date/time
period_to date/time
check_date date/time
regular_salary = regular_rate * regular_hours number
ot_salary=ot_ra te * ot_hours number
total_salary = regular_salary + ot_salary number


I want the user only to enter the hours and the payroll has to be calculated basing on the hours entered.

Option1: Either payroll table should be appended using append query after hours entered in time table but must restrict duplicate entries or delete duplicate entries after append.



Option2: Just not to have any payroll table at all and everything to be taken care in time table and create a form for hours entry that will restrict users from entering duplicate records. For example for ssn=123-45-6789 and period_from =Jan 01, 2008 and period_to=Jan 31, 2008. I want to restrict users from entering hours for this particular period(Jan 01, 2008 to Jan 31, 2008) if hours already exists for employee whose ssn=123-45-6789 and at the same time I want to allow database user to enter record for ssn 123-45-6789 for other periods(Feb, Mar, Apr and so on).

I cannot have PK on SSN in time table as it will restrict me from entering more than one record as every month I will have new record entry for this ssn=123-45-6789.

Any ideas will be highly appreciated. What is the best option I should adopt and how. Please bear with me if I am silly or stupid as I am very new to databases
Jun 22 '08 #1
3 2061
zachster17
30 New Member
It looks like you should make employee ID, period_to, and period_from the fields for a primary key in the time table.

Using that as the primary key, you could only enter the employee once for each period (but still have the employee listed every pay period).

Also, it looks like you don't need the actual table 'payroll'--all the information there can be derived from the other two tables so I would actually just make a query to pull that information.

Let me know if I can further explain any of my ideas above..

Thanks,

Zachh
Jun 22 '08 #2
allingame
4 New Member
Thanks for the reply Zachh.

If I make period_from or period_to as prime key it will allow me to enter data for employee a but it then it will not allow me to enter data for employee b

Thanks,

Allingame
Jun 23 '08 #3
NeoPa
32,577 Recognized Expert Moderator MVP
The point here is that keys (Primary Key in this case) need not be restricted to a single field.

Complex keys are made up of multiple individual fields. This is what has been suggested and I see this as a good way to hold your data.
Jun 25 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
1899
by: george young | last post by:
For each run of my app, I have a known set of (<100) wafer names. Names are sometimes simply integers, sometimes a short string, and sometimes a short string followed by an integer, e.g.: 5, 6, 7, 8, 9, bar, foo_6, foo_7, foo_8, foo_9, foo_10, foo_11 I need to read user input of a subset of these. The user will type a set of names separated by commas (with optional white space), but there may also be sequences indicated by a dash...
3
2422
by: Alexander Anderson | last post by:
I have a DELETE statement that deletes duplicate data from a table. It takes a long time to execute, so I thought I'd seek advice here. The structure of the table is little funny. The following is NOT the table, but the representation of the data in the table: +-----------+ | a | b | +-----+-----+ | 123 | 234 | | 345 | 456 |
7
1813
by: Christian Christmann | last post by:
Hi, in the past I always appreciated your help and hope that you also can help me this time. I've spent many many hours but still can't solve the problem by myself and you are my last hope. I've a program which is using self-written double-linked lists as a data structure. The template list consists of list elements and the list itself linking the list elements.
7
3283
by: Amy | last post by:
I'm trying to add an autoincrementing id to a table based on an existing field Name, but Name has duplicated records. How can I do that in ACCESS? Thanks. Amy
10
3073
by: Mark | last post by:
I have a table about people containing 25 fields. The table contains the usual fields - first, last, address, city, state and zip. There is no primary key. These fields all have data with the exception of a few records missing zip. A person may be in one to five records in the database. If a person is in multiple records, the other fields in the table in each record for that person may or may not contain data. I have two problems: 1. I...
3
386
by: jw | last post by:
i have a program it has a list of random numbers and my aim is to add the nodes in another list the nodes will be in an order at the new link list #include<iostream> #include<cmath> using namespace std; class Node{ private:
1
2043
by: John Wright | last post by:
I am running a console application that connects to an Access database (8 million rows) and converts it to a text file and then cleans and compacts the database. When it runs I get the following error: The CLR has been unable to transition from COM context 0x1a2008 to COM context 0x1a2178 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long...
16
3519
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for renaming the duplicate records? My thinking was to take the results of the duplicate query, and somehow have it number each line where there is a duplicate (tried a groups query, but "count" won't work), then do an update query to change the duplicate to...
10
2064
by: pythonnoob | last post by:
Hello everyone. New to python as well as this forum, but i must say ive learned a but already reading through some posts. Seems to be a pretty helpful community here. Before i post a question ill give you a little background. I have done programming in the past in Basic, VB, and a little C. I am not much of a programmer, its more of a hobby/curiosity. The following code is not mine, i am trying to modify a template of a mock database....
3
2369
allingame
by: allingame | last post by:
Need help with append and delete duplicates I have tables namely 1)emp, 2)time and 3)payroll TABLE emp ssn text U]PK name text
0
10302
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10136
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10071
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9925
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4036
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.