|
mindphlux posted:The checkbox's data source is the Y/N field in the Owner's table, so I think yes? The datatype for the Y/N is just access's dedicated Yes/No datatype. this sucks. So all the other fields write out fine? What version of access are you using? Are you sure its not being written into the table?
|
# ? Sep 15, 2010 19:05 |
|
|
# ? May 28, 2024 10:40 |
|
This should be a simple question I think. I'm just trying to create a simple view in MSSQL 2008. code:
**** Figured it out with some help code:
c355n4 fucked around with this message at 20:10 on Sep 15, 2010 |
# ? Sep 15, 2010 19:58 |
|
Sprawl posted:So all the other fields write out fine? access 2010 - yeah, I'm sure it's not being written in the table. Basically the checkbox on my form has a weird thing where it's filled in with a block - not empty or checked, which I assume means it has no data. If I click the box, it just makes a dinging noise like it can't be altered. So, I'm not insane? this should be working as is? I thought it would just work if I defined the relationship and then clicked a checkbox, seems like it would write it in the new table. edit : I just tested it where I added a record in the new table with an existing ownerID, and then on my form the checkbox works like it should. so what, do I need code to check and make sure the record exists in my new table, and create a new record if it doesn't when I bring it up on my form? edit2 : argh, I did a 'before update' on the Y/N checkbox, with iff([Owners]![OwnerID]=Null,[Owners]![OwnerID]=[Stores]![OwnerID],) but this breaks my entire form and more importantly doesn't initialize an OwnerID entry in my owners table mindphlux fucked around with this message at 22:07 on Sep 15, 2010 |
# ? Sep 15, 2010 21:44 |
|
c355n4 posted:
You can also use either COALESCE or ISNULL as such: COALESCE(dbo.talumnicategories.checked,'false') ISNULL(dbo.talumnicategories.checked,'false') ISNULL is typically slightly faster, but for many scenarios they behave differently and you may want to use the other. A lot of the differences are discussed here: http://databases.aspfaq.com/database/coalesce-vs-isnull-sql.html
|
# ? Sep 16, 2010 00:08 |
|
Aredna posted:You can also use either COALESCE or ISNULL as such: Ah, thanks. Thats much cleaner.
|
# ? Sep 16, 2010 00:59 |
|
Can I cast a value while unpivoting? I have a table with several columns with different types. I'm unpivoting the columns into Field, Value rows, and obviously they need to be casted into the same type. Is this possible? code:
|
# ? Sep 16, 2010 21:47 |
|
Nevermind, answered my own question SELECT UserGUID, CAST(Field as nvarchar(100) as Field, ...
|
# ? Sep 16, 2010 22:15 |
|
What are the limitations of COALESCE? I have this query:code:
Even weirder(?), when I change it to COALESCE("a", SUM(amount)), Navicat tells me it's returning a blob, but when I save it to disk, the blob is an empty file. Edit: I found a workaround, I suppose: Wrapping the whole thing in COALESCE. code:
Of course, now I wonder if it's faster to do that (with the subquery), or just run a mysql_num_rows and return '0' if it's 0. And that reeks of premature optimization. But alas, I wonder. Golbez fucked around with this message at 22:32 on Sep 20, 2010 |
# ? Sep 20, 2010 22:10 |
|
It doesn't work because you're trying to GROUP an empty result set. It has nothing to do with COALESCE
|
# ? Sep 20, 2010 22:36 |
|
I need to generate gobs of test data for an application's sql server. The database is rather legacy and I can't really change the schema very much. This means I have almost no constraints and very few tables even have identity columns, or even proper unique constraints. I've look at the red gate data generator but it doesn't seem to be flexible enough for my needs. I've spent a few days working on my own custom tool to do the job where I can manage table relationships in a bit more custom fashion. I finally have the thing mostly working, but I was wondering if anyone knew of a professional tool that might do the job instead of continuing work on my tool. Any thoughts?
|
# ? Sep 24, 2010 02:58 |
|
Atimo posted:I need to generate gobs of test data for an application's sql server. The database is rather legacy and I can't really change the schema very much. I use EMS Sql Manager to do a lot of poo poo, and they do have a commercial tool available that will generate test data for sql server, mysql, and postgres. Never used it though http://www.sqlmanager.net/en/products/mssql/datagenerator I am not familiar with red gate, so I dunno how this compares. But I am sure there has got to be other companies with similar products.
|
# ? Sep 24, 2010 14:41 |
|
I have a table in which I want to dynamically update a column for a particular account. Mostly this table will be used to store the state of windows or panes when the user logged in or out. I should also state this is SQL Server 2008.code:
When I execute the above command in SQL Management Studio, no errors are returned. When I pass and incorrect or non-existent account id, the correct error message is logged. When the column name is non-existent or is AID then the correct error message is logged. Funky part: When all the information is right, it does make it down to "EXECUTE sp_executesql...". No errors are return. When I check the data it never updated the table. All that is output is the message printed to the screen: code:
Beseiged fucked around with this message at 16:35 on Sep 24, 2010 |
# ? Sep 24, 2010 16:33 |
|
Begby posted:I use EMS Sql Manager to do a lot of poo poo, and they do have a commercial tool available that will generate test data for sql server, mysql, and postgres. Never used it though Thanks, I'll look into this product further. At first glance though it does appear to be mapping table relationships with contraints. If I can't set it manually it won't be of much help.
|
# ? Sep 25, 2010 00:40 |
|
First off I should say I feel dumb for this one because it seems like it should be obvious and I am rusty at SQL. I am designing a query to do a current inventory for a rental company. In the rental section I have it designed to have a delivery and pick up date. I might be going about it wrong, but here's the failing design. WHERE not (((([CURRENT_TIMESTAMP])<Rentals.[Date of Pickup] And Not ([CURRENT_TIMESTAMP])<Rentals.[Date of delivery])=False) And ((Equipment.sale)=False)); So it takes all the equipment rom the rental form, and excludes all the products that do not have a pick up/delivery date, and not have been sold. It still shows a few products though that are currently delivered. Is there a better way to go about it, or am I just missing something. I can't stop going in circles over it. EDIT: DECIDED TO DO IT AS A CASE but I get a format error on it. Here's what I got. SELECT Equipment.[Serial Number], Equipment.Product, Equipment.Brand, Equipment.[Product Type], Equipment.[Purchase Date],Rentals.[Date of pickup], CASE = 'status' WHEN [CURRENT_TIMESTAMP]<=[Rentals].[Date of Pickup] then 'Not Available' Else 'Available' end FROM Equipment INNER JOIN (Clients INNER JOIN Rentals ON Clients.[Client ID]=Rentals.[Client ID]) ON Equipment.[Serial Number]=Rentals.[Serial Number]; This should work right? Veskit fucked around with this message at 20:33 on Sep 25, 2010 |
# ? Sep 25, 2010 10:09 |
|
Veskit posted:
Looks like your case statement is off. Not in front of a sql ide so my syntax may be off as well but it should be something more like: 'STATUS' = CASE WHERE CURRENT_TIMESTAMP <= [Rentals].[Date of Pickup] then 'Not Available' Else 'Available' END
|
# ? Sep 25, 2010 22:52 |
|
Veskit posted:This should work right?
|
# ? Sep 26, 2010 20:57 |
|
So, total newbie here, but is there a good resource for learning database design? I'm just starting a project I've been thinking about doing for a while now (if you're familiar with PARANOIA, it'd be a web-based game-running tool), but I want to make sure I don't completely gently caress myself down the line. Right now, I've just got a simple user creation and login system set up to make sure I can figure out the whole PHP/SQL thing, so I'd really like to spend some time doing design now to hopefully avoid having severe performance issues if I start getting any kind of regular traffic or problems adding features I may not initially start with.
|
# ? Sep 28, 2010 03:23 |
|
Kekekela posted:Looks like your case statement is off. Not in front of a sql ide so my syntax may be off as well but it should be something more like: I am still getting horrendous amounts of Syntax errors trying it this way. Did I write this incorrectly or is Access just a giant pain in the rear end?
|
# ? Sep 28, 2010 03:25 |
|
Veskit posted:I am still getting horrendous amounts of Syntax errors trying it this way. Did I write this incorrectly or is Access just a giant pain in the rear end? This might be it: CASE WHERE CURRENT_TIMESTAMP <= [Rentals].[Date of Pickup] then 'Not Available' Else 'Available' END AS Status Its been a while since I've worked with Access though, didn't realize that's what you were using. Kekekela fucked around with this message at 14:57 on Sep 28, 2010 |
# ? Sep 28, 2010 05:46 |
|
Kreeblah posted:So, total newbie here, but is there a good resource for learning database design? I'm just starting a project I've been thinking about doing for a while now (if you're familiar with PARANOIA, it'd be a web-based game-running tool), but I want to make sure I don't completely gently caress myself down the line. Right now, I've just got a simple user creation and login system set up to make sure I can figure out the whole PHP/SQL thing, so I'd really like to spend some time doing design now to hopefully avoid having severe performance issues if I start getting any kind of regular traffic or problems adding features I may not initially start with. To be brutally honest, you are so far from having a usable game that people will want to use (literally years if you know nothing about database design or programming right now) that performance considerations aren't important if finishing the project is the goal, especially not database ones. That said, if you're interested in learning and applying the concepts involved, read up on primary and foreign keys, database normalization, indexes, and entity-relationship diagrams to start. Once you grasp the theory basics, take a look here: http://dev.mysql.com/doc/refman/5.0/en/explain.html for a diagnostic tool to help you out. Normally, to get a good handle on the basics of database optimization I would expect 3 or more graduate level CS courses after an undergrad sequence of 1-3 general courses.
|
# ? Sep 28, 2010 07:22 |
|
baquerd posted:Normally, to get a good handle on the basics of database optimization I would expect 3 or more graduate level CS courses after an undergrad sequence of 1-3 general courses. You're joking aren't you? Granted it takes some learning but it's nowhere near as much of a black art as you make it sound. baquerd posted:To be brutally honest, you are so far from having a usable game that people will want to use (literally years if you know nothing about database design or programming right now) that performance considerations aren't important if finishing the project is the goal, especially not database ones. Aside from the "literally years" bit (which I doubt - months or a year maybe, depending on how much time he intends to dedicate to it), I think he's just aiming to create some automated player aids or something. The game he's talking about is a role-playing game, so I don't imagine he intends his project to actually run a game. My impression is that RPGs have far too much in the way of subjective elements for that to be possible. Kreeblah - I don't really know any essential resources to recommend, but I think the best way to pick up what is and what isn't a good database design is to look at lots of examples, along with the reasons knowledgable people have given as to why those examples show good or bad design. Don't get me wrong, do look up what the various levels of normalisation are, and apply those ideas to examples you come across, but it's easiest to learn by getting a "feel" for what is right and what is wrong. I wouldn't extend this advice to other aspects of creating a web app. There are some core things you definitely need to read up on, but good database design is really very easy once you "get it". Just make sure you do indeed "get it", because it is true that a badly-designed database is a headache to deal with.
|
# ? Sep 28, 2010 09:40 |
|
I have a question about transactions: Say I want to insert a record in a table, read it out again, and then update that same record. Only after the update is the new record really complete, so I don't want any other query to see my new record until after it has been updated. I think that I need to wrap those three operations in a READ COMMITTED transaction. Is that correct?
|
# ? Sep 28, 2010 09:59 |
|
Hammerite posted:You're joking aren't you? Granted it takes some learning but it's nowhere near as much of a black art as you make it sound. I'm not joking. While most day to day cases are simple, really complex queries can take a very difficult and fundamental understanding of the database to fully optimize. People make careers off of doing this well, it's not something you just pick up in school and you're good to go. quote:Aside from the "literally years" bit (which I doubt - months or a year maybe, depending on how much time he intends to dedicate to it), I think he's just aiming to create some automated player aids or something. The game he's talking about is a role-playing game, so I don't imagine he intends his project to actually run a game. My impression is that RPGs have far too much in the way of subjective elements for that to be possible. While I understood his scope to be more in line of a full implementation of quantifiable mechanics, when I've taught computer science, students who've never been exposed to the materials sometimes take months of actual classes with instruction and direct examples to even learn boolean logic fully, let alone understand OOS design techniques and understand the bit of the API that can interact with a database meaningfully. Those of us (yes I'm assuming) who have been doing this forever often have a really warped perspective of what beginners should be capable of, and we likely took to it very easily ourselves as well. I see CS majors walk out of undergrad who would be unable to write a program to connect to a database and output the results to the screen without Google and an hour.
|
# ? Sep 28, 2010 10:02 |
|
Veskit posted:
code:
|
# ? Sep 28, 2010 14:55 |
|
baquerd posted:I'm not joking. While most day to day cases are simple, really complex queries can take a very difficult and fundamental understanding of the database to fully optimize. People make careers off of doing this well, it's not something you just pick up in school and you're good to go. I'll give you that their queries aren't perfectly optimized and sometimes even simple changes can speed them up by an order of magnitude, but they are fast enough and getting the correct results. baquerd posted:While I understood his scope to be more in line of a full implementation of quantifiable mechanics, when I've taught computer science, students who've never been exposed to the materials sometimes take months of actual classes with instruction and direct examples to even learn boolean logic fully, let alone understand OOS design techniques and understand the bit of the API that can interact with a database meaningfully. Those of us (yes I'm assuming) who have been doing this forever often have a really warped perspective of what beginners should be capable of, and we likely took to it very easily ourselves as well.
|
# ? Sep 28, 2010 15:16 |
|
I'm trying to create a table in Oracle Database Express Edition with a foreign key that references another table, but I keep getting the "ORA-00907: missing right parenthesis" error. Does anyone know what I'm doing wrong here? create table order_item( order_id varchar2(50) primary key not null, order_item_seq_id varchar2(50) not null, qty integer not null, unit_price varchar2(50) not null, estimated_delivery_date date not null, product_id varchar2(50) foreign key references customer(cust_id) ) Thanks for any help!
|
# ? Sep 28, 2010 16:27 |
|
baquerd posted:To be brutally honest, you are so far from having a usable game that people will want to use (literally years if you know nothing about database design or programming right now) that performance considerations aren't important if finishing the project is the goal, especially not database ones. Well, Hammerite is right about it being more of a tool than an actual game, so I'm expecting that will help simplify things quite a bit. For background (and I probably should have mentioned this), I have about 80% of a computer engineering degree, but zero database experience. I'm actually hoping to eventually be able to use this as an example of what I can do to help try to land a job with a schedule that'll let me finish my degree, as I haven't had much luck looking so far and not having any database experience seems to be one of the reasons why. Even though this is going to be a first project in this field for me, I do have at least some familiarity with OO design, data structures, design processes, etc. from my classes, which should make things easier to get the logic side of things going once I get a handle on this. I just never had any courses on databases and I've never had to use them for anything myself, so I need to find an excuse to get my hands dirty and this is at least something I've wanted to do for a while for my own use. I do want to come away with good habits, though, which is why I was hoping to find some resources to help develop them. I did check up on primary/foreign keys and database normalization before posting and they were easy enough to grasp (at least up to 3NF; I'm going to need to do some more reading before I feel comfortable saying I understand what the differences are among the higher normal forms), but I wasn't sure what else I was missing so I'll look into indexes and entity-relationship diagrams and then check out that link. Hammerite posted:I don't really know any essential resources to recommend, but I think the best way to pick up what is and what isn't a good database design is to look at lots of examples, along with the reasons knowledgable people have given as to why those examples show good or bad design. Don't get me wrong, do look up what the various levels of normalisation are, and apply those ideas to examples you come across, but it's easiest to learn by getting a "feel" for what is right and what is wrong. Alright. I'll see what I can find for examples, then. And, yeah, I do want to have something usable come out of this, especially since the existing tools for it aren't very good and it's something I'd actually use myself, but if it ends up just being an excuse for gaining some experience with SQL/database design/web app design, I'd be OK with that. I can always finish it later if it comes down to it. Anyway, thanks to the both of you for your help. I really wasn't sure where to get started, so I do appreciate the advice.
|
# ? Sep 28, 2010 18:15 |
|
guch posted:I'm trying to create a table in Oracle Database Express Edition with a foreign key that references another table, but I keep getting the "ORA-00907: missing right parenthesis" error. Does anyone know what I'm doing wrong here? The constraint needs a name: create table order_item( order_id varchar2(50) primary key not null, order_item_seq_id varchar2(50) not null, qty integer not null, unit_price varchar2(50) not null, estimated_delivery_date date not null, product_id varchar2(50) constraint order_item_customer_fk foreign key references customer(cust_id) ) or create table order_item( order_id varchar2(50) primary key not null, order_item_seq_id varchar2(50) not null, qty integer not null, unit_price varchar2(50) not null, estimated_delivery_date date not null, product_id varchar2(50) ); alter table order_item add constraint order_item_customer_fk foreign key (product_id) references customer(cust_id); I'll assume the fact that product_id keys to cust_id is due to a hastily constructed example and not completely insane design Also, I keep this page bookmarked for questions like this http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10759/toc.htm (probably requires OTN account, which is free) MoNsTeR fucked around with this message at 20:13 on Sep 28, 2010 |
# ? Sep 28, 2010 20:07 |
|
Sub Par posted:You cannot use CASE statements in Access SQL. You will need to use IIF instead: Thannnnkkkk you so much for this. Also yeah it's a form field so that the client can see on what specific date the deliveries/pickups are in the future and such.
|
# ? Sep 28, 2010 21:10 |
|
In Oracle, you can prompt for values with the following code:code:
|
# ? Sep 28, 2010 22:33 |
|
baquerd posted:I'm not joking. While most day to day cases are simple, really complex queries can take a very difficult and fundamental understanding of the database to fully optimize. People make careers off of doing this well, it's not something you just pick up in school and you're good to go. That said, the basics of relational theory that you do need can be had in one semester of junior-level material. That's all I ever had. Or the oft-recommended manga guide (which is shockingly good) is a good alternative if a college course isn't a reasonable option.
|
# ? Sep 29, 2010 00:56 |
|
In MySQL, I've been using FROM ... LEFT JOIN ... USING (...) style for a while, but I've become very paranoid about using multiple ones. An example:code:
code:
So what happens if location_id also exists in users? Even if it's equal to the one in companies? Now, before, I would have done the first query above and it would have worked fine, completely unambiguous. But with USING I'm not entirely sure. In a case with any possible ambiguity, should I abandon USING, or is it safe when I know the data is the same? Another question, less about paranoia and more about how this works. Let's say I'm pulling in things from two tables on the same ID: code:
code:
|
# ? Sep 29, 2010 18:05 |
|
Golbez posted:In MySQL, I've been using FROM ... LEFT JOIN ... USING (...) style for a while, but I've become very paranoid about using multiple ones. An example: Not 100% on this, but the way I read the documentation on JOIN, the columns in the USING clause have to exist in both the table (strictly "relation" I guess) on the left and the table on the right, the table being joined. So yes it is smart enough, I reckon. As for the second question, I don't know. Seems ambiguous on the face of it. The documentation might explain it, but I don't care to take the time to read it closely and find out. I prefer using JOIN ... ON personally because it's completely explicit about the criteria for the join. The unquoted part of your post I've no idea
|
# ? Sep 29, 2010 18:19 |
|
Golbez posted:So what happens if location_id also exists in users? Even if it's equal to the one in companies? Now, before, I would have done the first query above and it would have worked fine, completely unambiguous. But with USING I'm not entirely sure. In a case with any possible ambiguity, should I abandon USING, or is it safe when I know the data is the same? I'm going to act like I'm not at work and just start assuming poo poo arbitrarily, like you're at least using MySQL 5.0.12. This is important because the using clause behaves differently in previous versions. code:
code:
code:
Golbez posted:Another question, less about paranoia and more about how this works. Let's say I'm pulling in things from two tables on the same ID:
|
# ? Sep 30, 2010 15:53 |
|
Avarkx posted:If this doesn't throw a syntax error (and I would be seriously surprised if it didn't), go for it. I don't have access to a MySQL instance right now so I can't check this myself or I would, just to see. The manual includes this: quote:This is a conservative extension if we consider each comma in a list of table_reference items as equivalent to an inner join. For example:
|
# ? Sep 30, 2010 16:18 |
|
Golbez posted:The manual includes this: Oh! That's sort of neat I guess, definitely good to know... Edit: Everything I said is a lie, I'm really confused about the INNER JOIN = CROSS JOIN claim the manual is making, I'll repost here after I check something out... Avarkx fucked around with this message at 17:41 on Sep 30, 2010 |
# ? Sep 30, 2010 16:59 |
|
Avarkx posted:USING is a clause with a specific application, namely auto-coalescing common columns for you. Use ON if you don't need the functionality of USING. I figure I should be specific and use ON rather than USING for multiple table issues. Edit: The manual continues, "In standard SQL, they are not equivalent. INNER JOIN is used with an ON clause, CROSS JOIN is used otherwise."
|
# ? Sep 30, 2010 17:42 |
|
Golbez posted:Edit: The manual continues, "In standard SQL, they are not equivalent. INNER JOIN is used with an ON clause, CROSS JOIN is used otherwise." code:
Also in MySQL, the following is probably also true: code:
code:
Golbez posted:I thought that USING (c1) was functionally identical, in a simple situation, to "... ON t1.c1 = t2.c1". I'm a little sick at the moment so I might be missing the obvious here, but is what you're saying equal to what I'm saying? Avarkx fucked around with this message at 18:31 on Sep 30, 2010 |
# ? Sep 30, 2010 17:48 |
|
Avarkx posted:In simple cases, we are talking about the same thing, yes. I'm just attempting to illustrate that in a case involving a possibly ambiguous column, the value of the leading table is favored. That is, the ambiguity is resolved by taking the first non-null value in the common column of the referenced tables (if a value exists, of course). I'm also saying that the USING clause is specific enough for that very reason, but the majority of the time you will be doing yourself (and anybody reading your code later) a service by sticking to the ON clause when the case is in fact, simple. Thanks so much for your analysis.
|
# ? Sep 30, 2010 20:18 |
|
|
# ? May 28, 2024 10:40 |
|
Sub Par posted:You cannot use CASE statements in Access SQL. You will need to use IIF instead: OK ONE LAST THING. I'm getting redundant information in the available column, so how do I get it to exclude all results as available if it already has a serial number in the unavailable column?
|
# ? Oct 1, 2010 20:45 |