Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
G-Dub
Dec 28, 2004

The Gonz

Alex007 posted:

Meet your new friend SQL_CALC_FOUND_ROWS !!!

http://www.arraystudio.com/as-workshop/mysql-get-total-number-of-rows-when-using-limit.html

Will you be my best friend? This is news to me and makes my life a happier one

Adbot
ADBOT LOVES YOU

G-Dub
Dec 28, 2004

The Gonz
I wonder if someone could give me some pointers regarding a table structure for a hierarchical team setup. I am developing a workforce management system for about 2000 employees (using Access). I have the employee side of things set up fine - one employee record to many employee detail records, where employee detail is things like hours, shift pattern, basically anything that changes over time so we can have a historical picture of their employment. Currently these detail records also store the team the employee is in as we want to know that historically too.

Where I am struggling is the team structure and the best way to store and manage it. There are about three levels of management and at each level we need to be able to pull results for everything under each span of command. Level one is fine, as there is only one team underneath each low-level manager. At level two, each manager manages around 10 lower-level managers so we need to be able to query information about those 10 lower-level managers and also the members of staff they manage. So on and so forth.

I'm not sure if I am Googling poo poo terms or what, but I cannot find practicle examples of how best to do this. Has anyone done anything similar and would you care to share how you tackled this?

Thanks.

G-Dub
Dec 28, 2004

The Gonz

stray posted:

I know I'm going to get some poo poo from people here for even mentioning this accursed product's name, but I have to work with Microsoft Access. I'm trying to turn a large Excel spreadsheet into nicely-formatted reports and Access actually does make it pretty easy. Everything works except for one thing.

Right now, the Access database is using Link Tables to get data from a file that's located on my desktop. However, if other people in the office are going to use this, I need a way for the user to select the Excel file with which they want to link tables (and thus pull in the data and generate the reports). UPDATE: I've created a form with buttons that give the user a File Dialog, but how do I tell Access to use this file as the one to whose tables I want to link?

How do I do this in Access? (Is this what Macros and Modules are for?) Also, I don't know VB, so is this simple task going to be a nightmare for me?

This isn't an SQL question so it is probably better placed elsewhere. Anyway you are going to have to delete any currently linked tables (see DeleteObject) and then link to the new file, the path for which you will have from your File Open Dialog (see TransferDatabase) using VBA.

G-Dub
Dec 28, 2004

The Gonz

mindphlux posted:

Any thoughts?

I can't say for sure without seeing the app but is it maybe because the combobox has focus? I have never used that feature of Access so I can't say for sure.

To ensure it does what you want it to do you could look in to the Excel object model and create your own export to Excel function, and add a button to your form. It's really quite easy. My one clue is 'CopyFromRecordset'. I have seen too many people iterate through recordsets (takes forever) instead of using this function which takes a tiny fraction of a second.

G-Dub
Dec 28, 2004

The Gonz
This is probably a really basic question but I was really doubting myself earlier when planning the schema for a new system.

The structure of things is:

There is an event (not in the programming sense) which has a unique ID
Each event can have 1 to n customers who all have unique reference numbers
Each customer can make 0 to n responses to the invitation to the event
Each response can specify 1 to n options

So, the event table's PK is the EventID
The event customers table's PK can be EventID and CustomerID (the customers table is completely separate, this just relates the customer to the event)

Would the normal thing to do here be to have the response table's PK being EventID, CustomerID and ResponseID? And then the next increment for the options?

Also, the options each have a fixed ID so they are fine to tack on to the PK if this is the route to go down but the responses do not. If this is the route to follow can the responses table's PK be EventID, CustomerID and then a count of responses +1 for ResponseID?

Please enlighten me. This is on SQL Server 2008.

Thanks

Adbot
ADBOT LOVES YOU

G-Dub
Dec 28, 2004

The Gonz

Goat Bastard posted:

...but then what if you get thrown the additional requirement that each customer can respond multiple times to one event (maybe they're suddenly allowed to decline then attend it, or attend it multiple times for some brain-dead business reason or something).

Each customer can response as many times as they want to one event. Sorry if that wasn't clear in my original question.

Sorry for being dumb but when it was said earlier that the real world changes all the time. It is the whole basis of the system that the event ID and the customer ID cannot change, and even if they did it would need to be a change rolled out throughout, e.g. each event id would change to the new one and likewise for the customer id. You can't start disassociating customers with their events for example. Therefore. in my eyes, if either change the uniqueness of the key would still be intact.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply