|
Azerban posted:So I've got a schema that looks like this; If I understand your post, we need to avoid having record1.roomno = record2.roomno AND record3.deptID != record4.deptID AND record1.fID = record3.fID AND record2.fID = record4.fID Normally when I need to simultaneously access two records in the same table it's a hint for me to look at self-joins.
|
# ? Mar 3, 2009 23:44 |
|
|
# ? May 10, 2024 00:12 |
|
Learning PL/SQL and have a small question.code:
|
# ? Mar 4, 2009 01:16 |
|
fge posted:Learning PL/SQL and have a small question. There's an example of declaring an explicit cursor in the PL/SQL User's Guide at the following URL: http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14261/overview.htm#BABFAAAJ Here's an example using a wildcard instead of explicitly listing the columns: code:
code:
|
# ? Mar 4, 2009 02:53 |
|
Ok I think I got it, thanks.
|
# ? Mar 4, 2009 03:09 |
|
I just got a pretty hosed up email from work. We're making some pretty big cutbacks (a lot of people lost their job, and it's a small company), so I'm looking for ideas to help out. We have a lot of in-house toolkits that my coworker and I have developed to make our lives easier. One of them is a pretty powerful database abstraction layer for MSSQL 2005, 2008 and 201x. It's a versioned database abstraction layer that emits and consumes only XML, handles all table relationships automatically (including bridge objects - eg Object A can be associated with Object B through Object C), with a Web Service and .NET API. It also provides events (web service calls, email, etc), has tons of filtering options, and can attach to any number of databases. We use it to lessen the annoyance of an industry standard database, and it's actually faster than even well optimized queries most of the time. The feature list is very long, and the amount of things it does for us is crazy. I'm considering talking to the CEO about packaging it as a distinct product. Of all you SQL people, does anyone think this is a sellable product for use as middleware? If you could work with an annoying database through well defined XML based objects, would that help you? I'll be happy to field any questions here if appropriate, via PM or AIM, or by email. I'm not looking for actual buyers, I'm just curious if such a tool could be marketed in the near future. I feel bad even posting this, but since I have to take a 10% pay cut just to keep my job, I think it's worth probing for interest.
|
# ? Mar 4, 2009 08:20 |
|
In SQL Server, I'm trying SELECT * but so that a specific subset of records appears first. Right now it's: SELECT * FROM Account WHERE emaildomain = @domain I need to change it so that it still gets all the records, but gets people from a specific country FIRST, followed by the rest of the results. I tried: SELECT * FROM Account WHERE emaildomain = @domain AND Country = @country UNION SELECT * FROM Account WHERE emaildomain = @domain but that didn't seem to have an effect on the recordset. Is there an easy way to put a specific set of records at the beginning of the recordset? Something along the lines of "ORDER BY Country = @country" isn't any sort of valid syntax.
|
# ? Mar 4, 2009 16:38 |
|
Spiffo posted:In SQL Server, I'm trying SELECT * but so that a specific subset of records appears first. Right now it's: One thing that works for me in Oracle which might translate to SQL Server is placing a function in the order by clause, like this: code:
|
# ? Mar 4, 2009 16:49 |
|
Edit: Maybe not what you were looking for.
|
# ? Mar 4, 2009 17:28 |
|
SLOSifl posted:It's a versioned database abstraction layer that emits and consumes only XML, handles all table relationships automatically (including bridge objects - eg Object A can be associated with Object B through Object C), with a Web Service and .NET API. It also provides events (web service calls, email, etc), has tons of filtering options, and can attach to any number of databases.
|
# ? Mar 4, 2009 18:30 |
|
Yeah, I'm looking around at other products right now. This sucks, I don't know what to do if the company I've spent 10 years at goes under.
|
# ? Mar 4, 2009 18:49 |
|
If the tool you made is as cool as it sounds, that's a pretty sweet thing to put on your resume...
|
# ? Mar 4, 2009 18:54 |
|
Touche. I haven't found any competing products yet that do anything close to what ours does yet. I'm not sure if that's good or bad, since it makes it hard to determine whether there's a market or not.
|
# ? Mar 4, 2009 19:06 |
|
Another PL/SQL question, I have a record like this:code:
code:
|
# ? Mar 4, 2009 19:35 |
|
SLOSifl posted:I haven't found any competing products yet that do anything close to what ours does yet. I'm not sure if that's good or bad, since it makes it hard to determine whether there's a market or not.
|
# ? Mar 4, 2009 19:56 |
|
fge posted:Another PL/SQL question, I have a record like this: You can delete a specific element as follows. code:
code:
|
# ? Mar 4, 2009 20:31 |
|
Spiffo posted:SELECT * FROM Account WHERE emaildomain = @domain AND Country = @country Whoop, while that didn't work, it looke like SELECT * FROM Account WHERE emaildomain = @domain AND Country = @country UNION SELECT * FROM Account WHERE emaildomain = @domain AND Country <> @country does. If it didn't, the CASE solution Var1ety posted will also work.
|
# ? Mar 4, 2009 21:52 |
|
var1ety posted:Check out the PL/SQL User's Guide for information on looping. Maybe you want to use v1.count. Well I know what kind of loop I need to use, I should have been more specific, my loop is supposed to repeat either until the counter limit is reached, or the e_table record is empty. How do I test if e_table is empty or not? Or is there some function that returns the number of elements in a record?
|
# ? Mar 4, 2009 22:11 |
|
fge posted:Well I know what kind of loop I need to use, I should have been more specific, my loop is supposed to repeat either until the counter limit is reached, or the e_table record is empty. How do I test if e_table is empty or not? Or is there some function that returns the number of elements in a record? e_table.count will return the number of elements it contains.
|
# ? Mar 4, 2009 22:36 |
|
var1ety posted:e_table.count will return the number of elements it contains. Oh that's what you meant by v1.count, I'm dumb. Thank you!
|
# ? Mar 4, 2009 23:07 |
|
On MySQL I have multiple tables representing magazines and their covers:code:
code:
code:
code:
Can anyone help shed some light on this or point me in the right direction? I had tried using a UNION between two SELECTs, but the fact it combined the issue results into the same column made it impossible to differentiate between them.
|
# ? Mar 5, 2009 18:07 |
|
Prog and meg are two different objects. Why don't you just run two seperate queries?
|
# ? Mar 5, 2009 18:09 |
|
v1nce posted:On MySQL I have multiple tables representing magazines and their covers: You could try something like: code:
|
# ? Mar 5, 2009 20:59 |
|
Brilliant! Thanks WhoIsBarryBostwick - that was exactly what I was after. It seems so obvious now, padding the result sets across with empty variables. Triple Tech - there are actually a lot more tables we have to search and the number may increase in the future, so a single query that takes a few moments may work out more time efficient than our slow-rear end system sending MySQL repeated queries. Maybe.
|
# ? Mar 5, 2009 23:06 |
|
found the problem. i'm retarded.
KarmaticStylee fucked around with this message at 02:48 on Mar 6, 2009 |
# ? Mar 6, 2009 02:44 |
|
How do I select multiple things at once, and stuff them into the same cell? Okay I know that sounded vague, here is an example. Normally, someone says: code:
"Title1" "Title2" ... "Title20" Well, how do I query it so that it actually returns a delimited, single row, single coloum: "Title1,Title2,Title3,Title4,Title5,Title6,...,Title20" All in one row, one column? EDIT: Using MYSQL More specifically, MySQL and PHP. cannibustacap fucked around with this message at 08:13 on Mar 6, 2009 |
# ? Mar 6, 2009 06:47 |
|
Hey, I need a bit of help with my dumb database project. I'm little more than an SQL beginner, I'm keeping a database of movies, heres a simple version of what the table looks like: code:
Now, its easy enough to find movies that satisfy a single criteria: select Movie from MovieTagValues where Tag="Year" and TagValue="2008"; But how do I go about finding movies that satisfy multiple criteria? Action movies from 2008 for example. Can it be done in a single query or do I need to do more processing on the application side? Also, if you're wondering about the database design itself, it has to handle arbitrary numbers of and content of tags, so all this data can't exist on a single row of a 'Movies' table unfortunately. Nevett fucked around with this message at 06:49 on Mar 6, 2009 |
# ? Mar 6, 2009 06:47 |
|
cannibustacap, what DBMS are you using?
|
# ? Mar 6, 2009 07:38 |
|
Victor posted:cannibustacap, what DBMS are you using? Using MYSQL
|
# ? Mar 6, 2009 08:07 |
|
Nevett posted:Hey, I need a bit of help with my dumb database project. Google up "Entity-Attribute-Value", it's an absolute trainwreck of a denormalized design. The fact that querying for Action movies from 2008 is at all hard to write is already a tip-off. CHECK constraints are practically impossible to write, and so data integrity goes down the tubes as soon as there is a typo in one tag value. In EAV, the more data that goes into the table, everything gets worse: performance, data integrity, query complexity. Genre and Year are attributes of movies. They need to be columns on the Movies table, with correct datatypes (don't use Text for everything!), CHECK constraints, and (where applicable) lookup tables. If this is your own little project, then quote:Also, if you're wondering about the database design itself, it has to handle arbitrary numbers of and content of tags, so all this data can't exist on a single row of a 'Movies' table unfortunately. doesn't *have* to be that way. If you have control of the schema, it will pay off over and over again to use a normalized design.
|
# ? Mar 6, 2009 08:15 |
|
The project is a virtual filesystem where files can be given arbitrary tags and values. The movie example is just one database I've made during testing. It seems like this is one of the scenarios where EAV is (cautiously) justified. The problem is that the code for the database consumer (the VFS driver) needs to be as generic as possible so that it can load up a database of movie files, music files, documents, or a mix, and work just the same. The project is still in its early stages, so I'll definitely investigate some other methods of constructing the database. Perhaps have the VFS read the schema of a database and adapt rather than relying on the tables being exactly how I've set them up currently. Thanks for the input!
|
# ? Mar 6, 2009 08:47 |
|
If it's a virtual filesystem, why not use an object-oriented database?
|
# ? Mar 6, 2009 09:21 |
|
I'm wondering if someone could help me with a query I'm trying to build using MySQL, I hope I can explain this without sounding like an idiot. Basically, I have a list of jobs that have failed with a timestamp attached to them. I'm trying to do a count and a group by to see how many times each individual job fails, but the timestamp messes that up. Basically, the data in the column looks like: FOO_BAR_JOB_NAME Failed Fri Mar 6 13:22 2009 ANOTHER_STUPID_JOB Failed Fri Mar 6 13:25 2009 All I want to do is to match how many times each job failed. I would do this individually but we have literally thousands of jobs like this, and this is going be in a script that will send someone an email if it finds a job that fails too much. What I have pictured in my head is something that would return like this: code:
|
# ? Mar 6, 2009 19:27 |
|
I need help figuring out a workflow and I'm not sure how to go about it... Let's say I'm transforming (ETL?) data from Table A to Table B. Table A has a composite primary key A.a+A.b+A.c, while Table B has just an automatically populated identity column. How can I map the composite keys from A back to the identities created when inserting into B? Preferably I would like to not have any columns in table B related to A's composite key because there are many other tables that need to undergo the same operation but don't have the same composite key structure. This is SQL Server.
|
# ? Mar 6, 2009 20:28 |
|
You can map them through a third table if you can't update table B.code:
|
# ? Mar 6, 2009 22:11 |
|
cannibustacap posted:How do I select multiple things at once, and stuff them into the same cell? You can do: code:
|
# ? Mar 7, 2009 04:00 |
|
geetee posted:You can do: Sweet! Thanks
|
# ? Mar 7, 2009 07:01 |
|
I'm working on a clothing store website, and I'm trying to think of the best way to go about managing inventory (different sizes and colors, etc) with the database. Right now on my products table all I have is one field called "stock", which obviously doesn't cover colors or different sizes. Anyone have any suggestions as for the best way to go about this? I'm new to this whole thing. I was thinking of making a new table for just inventory, and then linking the product ID's. But then I'd have to have a bunch of different fields like, BLUESMALL, BLUEMEDIUM, BLUELARGE, etc etc and I'm pretty sure that isn't the best way.. but what do I know. (Every day I'm beginning to wish I just used premade webshop software. )
|
# ? Mar 8, 2009 06:57 |
|
zeldadude posted:I'm working on a clothing store website, and I'm trying to think of the best way to go about managing inventory (different sizes and colors, etc) with the database. Right now on my products table all I have is one field called "stock", which obviously doesn't cover colors or different sizes. Since you're new at this, I would recommend reading a book (or two) (or three) on data modeling. You may get some good tips in the forums, but it's no place to get an education. Start from the beginning... Bad Titty Puker fucked around with this message at 08:20 on Mar 8, 2009 |
# ? Mar 8, 2009 08:17 |
|
It's been a while since I've done SQL and I've forgotten a pretty basic thing I used to know how to do. example of my problem: Select title, sum(qty) from tablename where sum(qty) > 10 This obviously doesn't work. How do you reference a sum, avg or renamed column like this?
|
# ? Mar 9, 2009 03:19 |
|
|
# ? May 10, 2024 00:12 |
|
gotly posted:It's been a while since I've done SQL and I've forgotten a pretty basic thing I used to know how to do. code:
|
# ? Mar 9, 2009 04:01 |