Re: [sqlite] Correct, best, or generally accepted database structure for groups of things
Thanks James. Points taken on board. :-) Chris On Fri, Jun 17, 2016 at 5:24 PM, James K. Lowdenwrote: > On Fri, 17 Jun 2016 07:37:16 +0100 > Chris Locke wrote: > > > I fail to see what any of this has to do with sqlite. I thought this > > was a mailing list for sqlite? Seeing queries (no pun intended) on > > sql statements is very subjective, especially with the limited data > > provided by the original poster. > > A query question frequently exposes design choices, either logical or > physical. Both of those can have great effect on the utility and > performance of the system. Answering SQL questions helps people use > SQLite more effectively, and to understand where it differs from other > DBMSs. > > Queries occasionally provoke changes in SQLite itself, either because > the output was wrong (or unexpected), or because it presented a case > for optimization. I have to believe that real queries from users on > this list serve to inform the developers in how SQLite is used. (I > have never seen a homework question on this list.) > > > it won't stop there, and as soon as the original poster has another > > query > > No, it won't, because it hasn't. I've been hanging out here for 18 > months, and I remember only one annoying trivial-query participant. > Out of 13,693 messages, that doesn't amount to much. > > --jkl > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Correct, best, or generally accepted database structure for groups of things
As this is a mailing list, I've not been aware of past history. I thought (albeit wrongly) that an SQLite group was about the product sqlite. Someone posted the other day about a car analogy, so this is like posting to the Ford Engine Forums, askign what air freshner to put in the car. I don't mind off-topic posts either, but the generic post about 'how do I write this sql?' was extremely basic. Half the group will spin off about third normal forms... Ooh yes, I'll be back! I've a very 'basic' knowledge of SQL, so am picking up bits from the odd post here and there. I craft a lot of databases in vb.net but as my needs are small, sqlite eats this up for breakfast... I'm tempted to set up a beginners SQL forum though... a 'getting started' guide together with a 'how the &%$£ do I do this?' section... I prefer forums to email lists... don't feel so 'spammmy' and noisy... Thanks, Chris On Fri, Jun 17, 2016 at 3:16 PM, Drago, William @ CSG - NARDA-MITEQ < william.dr...@l-3com.com> wrote: > > -Original Message- > > From: sqlite-users-boun...@mailinglists.sqlite.org [mailto:sqlite-users- > > boun...@mailinglists.sqlite.org] On Behalf Of John McKown > > Sent: Friday, June 17, 2016 9:35 AM > > To: SQLite mailing list > > Subject: Re: [sqlite] Correct, best, or generally accepted database > structure > > for groups of things > > > > On Fri, Jun 17, 2016 at 1:37 AM, Chris Locke> > wrote: > > > > > I fail to see what any of this has to do with sqlite. I thought this > > > was a mailing list for sqlite? Seeing queries (no pun intended) on > > > sql statements is very subjective, especially with the limited data > > > provided by the original poster. > > > Everyone will give helpful advice, but it won't stop there, and as > > > soon as the original poster has another query (no pun intended) which > > > would result in a schema change, this would have to be explained, etc. > > > > > > A specific group on SQL is required. > > > > > > > Perhaps so. But such a group would run into problems because it would > be a > > case of "whose SQL?" The four "big" ones that I know of are: SQLite, > > PostgreSQL, Oracle, and IBM's DB2. The basics are the same, but each has > > their own peculiarities. I don't know what the intent of this forum > really is. It > > is only for SQLite related "perculiarities"? Or does it include > something like > > the OP's question which is basically "how do I do a SQLite query to get > this > > information?" I don't really know. I also monitor the PostgreSQL forums > and > > see this "how do I craft an SQL query to ...?" type question quite > often. What > > is weird to me, is that someone will post such a question on the _bugs_ > > forums, phrasing it as "I did this SQL query and it didn't do what I > expected. > > Please fix your product to make it work." And the reason it didn't work > was > > because the SQL query is garbage. Ah, the ever requested "do what I need, > > not what I said" fix. > > > > I don't know what the actual rules are for this group either. Almost any > database related topic seems to be tolerated if not enthusiastically > embraced. > Chris Locke has only been active here since May of this year (and maybe he > won't be back now that his problem is solved), so maybe he's unaware of > some of (off) topics that have made the rounds. In any case maybe he has a > good point in keeping the mailing list strictly on topic. I personally > don't mind the occasional detour into other realms, especially on a low > activity group like this one, and I usually learn a thing or two along the > way as well, but that is just my opinion. > > -Bill > > CONFIDENTIALITY, EXPORT CONTROL AND DISCLAIMER NOTE:This e-mail and any > attachments are solely for the use of the addressee and may contain > information that is privileged or confidential. Any disclosure, use or > distribution of the information contained herein is prohibited. In the > event this e-mail contains technical data within the definition of the > International Traffic in Arms Regulations or Export Administration > Regulations, it is subject to the export control laws of the > U.S.Government. The recipient should check this e-mail and any attachments > for the presence of viruses as L-3 does not accept any liability associated > with the transmission of this e-mail. If you have received this > communication in error, please notify the sender by reply e-mail and > immediately delete this message and any attachments. > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Correct, best, or generally accepted database structure for groups of things
On Fri, 17 Jun 2016 07:37:16 +0100 Chris Lockewrote: > I fail to see what any of this has to do with sqlite. I thought this > was a mailing list for sqlite? Seeing queries (no pun intended) on > sql statements is very subjective, especially with the limited data > provided by the original poster. A query question frequently exposes design choices, either logical or physical. Both of those can have great effect on the utility and performance of the system. Answering SQL questions helps people use SQLite more effectively, and to understand where it differs from other DBMSs. Queries occasionally provoke changes in SQLite itself, either because the output was wrong (or unexpected), or because it presented a case for optimization. I have to believe that real queries from users on this list serve to inform the developers in how SQLite is used. (I have never seen a homework question on this list.) > it won't stop there, and as soon as the original poster has another > query No, it won't, because it hasn't. I've been hanging out here for 18 months, and I remember only one annoying trivial-query participant. Out of 13,693 messages, that doesn't amount to much. --jkl ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Correct, best, or generally accepted database structure for groups of things
On Thu, 16 Jun 2016 20:53:25 + "Drago, William @ CSG - NARDA-MITEQ"wrote: > CREATE TABLE Apples ( > ID INTEGER PRIMARY KEY, > Color TEXT COLLATE NOCASE, --Could be Red, Green, or Yellow check Color in ( 'Red', 'Green', 'Yellow' ), -- FTFY > Height REAL, --Measured in cm > Width REAL --Measured in cm > Weight REAL --Measured in grams > ); > > And say I had a function that looks at the Apples table and finds > groups of 4 apples that match in color, dimensions, and weight. create view FourApples as select max(ID) as ID , Color, Height, Width, Weight from Apples group by Color, Height, Width, Weight having count(*) = 4 ; Why bother with a table? --jkl ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Correct, best, or generally accepted database structure for groups of things
On 2016/06/17 3:35 PM, John McKown wrote: On Fri, Jun 17, 2016 at 1:37 AM, Chris Lockewrote: I fail to see what any of this has to do with sqlite. I thought this was a mailing list for sqlite? Seeing queries (no pun intended) on sql statements is very subjective, especially with the limited data provided by the original poster. Everyone will give helpful advice, but it won't stop there, and as soon as the original poster has another query (no pun intended) which would result in a schema change, this would have to be explained, etc. A specific group on SQL is required. Perhaps so. But such a group would run into problems because it would be a case of "whose SQL?" The four "big" ones that I know of are: SQLite, PostgreSQL, Oracle, and IBM's DB2. The basics are the same, but each has their own peculiarities. I don't know what the intent of this forum really is. It is only for SQLite related "perculiarities"? Or does it include something like the OP's question which is basically "how do I do a SQLite query to get this information?" I don't really know. I also monitor the PostgreSQL forums and see this "how do I craft an SQL query to ...?" type question quite often. What is weird to me, is that someone will post such a question on the _bugs_ forums, phrasing it as "I did this SQL query and it didn't do what I expected. Please fix your product to make it work." And the reason it didn't work was because the SQL query is garbage. Ah, the ever requested "do what I need, not what I said" fix. I agree, and I would like to even promote posting query questions that will be executed in SQLite here, simply because there are so many followers of this list who learn from the answers of such SQL related questions, even when (or especially when) the answers get into deep down relational theory. I also think the above from Chris makes sense, an SQL-specific side-list might be useful, but in practice I don't think I would bother with both lists - one that has it all is great. I have not seen any official rules for this list, but I would suggest that SQL questions get included where you are trying to achieve a result or sculpt a query specifically to use in SQLite. It is worth remembering that a good percentage of the SQL used in SQLite is very peculiar to SQLite and SQLite mannerisms (or at a minimum, might behave in ways worth mentioning when run in SQLite). Who is to judge when a query is so significantly void of SQLite peculiarity that it should definitely be on another list? - I think this judgement activity would take more time than simply reading/answering the question here. If one can use the SQL elsewhere, also acceptable - many of us use more SQL platforms than just SQLite - but perhaps the question should at least originate when trying to build an SQLite query. I believe this is mostly the case on this forum and I feel this rule is respected in unwritten form by all thus far. Perhaps a time might come when this is no longer the case, however, I'd wait till then to change things. In short: I wouldn't change a thing yet. Cheers, Ryan ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Correct, best, or generally accepted database structure for groups of things
> -Original Message- > From: sqlite-users-boun...@mailinglists.sqlite.org [mailto:sqlite-users- > boun...@mailinglists.sqlite.org] On Behalf Of John McKown > Sent: Friday, June 17, 2016 9:35 AM > To: SQLite mailing list > Subject: Re: [sqlite] Correct, best, or generally accepted database structure > for groups of things > > On Fri, Jun 17, 2016 at 1:37 AM, Chris Locke> wrote: > > > I fail to see what any of this has to do with sqlite. I thought this > > was a mailing list for sqlite? Seeing queries (no pun intended) on > > sql statements is very subjective, especially with the limited data > > provided by the original poster. > > Everyone will give helpful advice, but it won't stop there, and as > > soon as the original poster has another query (no pun intended) which > > would result in a schema change, this would have to be explained, etc. > > > > A specific group on SQL is required. > > > > Perhaps so. But such a group would run into problems because it would be a > case of "whose SQL?" The four "big" ones that I know of are: SQLite, > PostgreSQL, Oracle, and IBM's DB2. The basics are the same, but each has > their own peculiarities. I don't know what the intent of this forum really > is. It > is only for SQLite related "perculiarities"? Or does it include something like > the OP's question which is basically "how do I do a SQLite query to get this > information?" I don't really know. I also monitor the PostgreSQL forums and > see this "how do I craft an SQL query to ...?" type question quite often. What > is weird to me, is that someone will post such a question on the _bugs_ > forums, phrasing it as "I did this SQL query and it didn't do what I expected. > Please fix your product to make it work." And the reason it didn't work was > because the SQL query is garbage. Ah, the ever requested "do what I need, > not what I said" fix. > I don't know what the actual rules are for this group either. Almost any database related topic seems to be tolerated if not enthusiastically embraced. Chris Locke has only been active here since May of this year (and maybe he won't be back now that his problem is solved), so maybe he's unaware of some of (off) topics that have made the rounds. In any case maybe he has a good point in keeping the mailing list strictly on topic. I personally don't mind the occasional detour into other realms, especially on a low activity group like this one, and I usually learn a thing or two along the way as well, but that is just my opinion. -Bill CONFIDENTIALITY, EXPORT CONTROL AND DISCLAIMER NOTE:This e-mail and any attachments are solely for the use of the addressee and may contain information that is privileged or confidential. Any disclosure, use or distribution of the information contained herein is prohibited. In the event this e-mail contains technical data within the definition of the International Traffic in Arms Regulations or Export Administration Regulations, it is subject to the export control laws of the U.S.Government. The recipient should check this e-mail and any attachments for the presence of viruses as L-3 does not accept any liability associated with the transmission of this e-mail. If you have received this communication in error, please notify the sender by reply e-mail and immediately delete this message and any attachments. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Correct, best, or generally accepted database structure for groups of things
On Fri, Jun 17, 2016 at 1:37 AM, Chris Lockewrote: > I fail to see what any of this has to do with sqlite. I thought this was a > mailing list for sqlite? Seeing queries (no pun intended) on sql > statements is very subjective, especially with the limited data provided by > the original poster. > Everyone will give helpful advice, but it won't stop there, and as soon as > the original poster has another query (no pun intended) which would result > in a schema change, this would have to be explained, etc. > > A specific group on SQL is required. > Perhaps so. But such a group would run into problems because it would be a case of "whose SQL?" The four "big" ones that I know of are: SQLite, PostgreSQL, Oracle, and IBM's DB2. The basics are the same, but each has their own peculiarities. I don't know what the intent of this forum really is. It is only for SQLite related "perculiarities"? Or does it include something like the OP's question which is basically "how do I do a SQLite query to get this information?" I don't really know. I also monitor the PostgreSQL forums and see this "how do I craft an SQL query to ...?" type question quite often. What is weird to me, is that someone will post such a question on the _bugs_ forums, phrasing it as "I did this SQL query and it didn't do what I expected. Please fix your product to make it work." And the reason it didn't work was because the SQL query is garbage. Ah, the ever requested "do what I need, not what I said" fix. > > Just my thoughts... > > > Chris > > -- "Pessimism is a admirable quality in an engineer. Pessimistic people check their work three times, because they're sure that something won't be right. Optimistic people check once, trust in Solis-de to keep the ship safe, then blow everyone up." "I think you're mistaking the word optimistic for inept." "They've got a similar ring to my ear." From "Star Nomad" by Lindsay Buroker: Maranatha! <>< John McKown ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Correct, best, or generally accepted database structure for groups of things
> -Original Message- > From: sqlite-users-boun...@mailinglists.sqlite.org [mailto:sqlite-users- > boun...@mailinglists.sqlite.org] On Behalf Of Chris Locke > Sent: Friday, June 17, 2016 2:37 AM > To: SQLite mailing list > Subject: Re: [sqlite] Correct, best, or generally accepted database structure > for groups of things > > I fail to see what any of this has to do with sqlite. I thought this was a > mailing > list for sqlite? Sorry for the off topic post. I've been a member of this group for a few years and I've seen generic SQL questions posted here from time to time without complaints from the mods. I thought it was ok. I do appreciate the value of a high signal-to-noise ratio group, so I'll take this discussion elsewhere. -- Bill Drago Staff Engineer L3 Narda-MITEQ 435 Moreland Road Hauppauge, NY 11788 631-272-5947 / william.dr...@l-3com.com CONFIDENTIALITY, EXPORT CONTROL AND DISCLAIMER NOTE:This e-mail and any attachments are solely for the use of the addressee and may contain information that is privileged or confidential. Any disclosure, use or distribution of the information contained herein is prohibited. In the event this e-mail contains technical data within the definition of the International Traffic in Arms Regulations or Export Administration Regulations, it is subject to the export control laws of the U.S.Government. The recipient should check this e-mail and any attachments for the presence of viruses as L-3 does not accept any liability associated with the transmission of this e-mail. If you have received this communication in error, please notify the sender by reply e-mail and immediately delete this message and any attachments. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Correct, best, or generally accepted database structure for groups of things
I fail to see what any of this has to do with sqlite. I thought this was a mailing list for sqlite? Seeing queries (no pun intended) on sql statements is very subjective, especially with the limited data provided by the original poster. Everyone will give helpful advice, but it won't stop there, and as soon as the original poster has another query (no pun intended) which would result in a schema change, this would have to be explained, etc. A specific group on SQL is required. Just my thoughts... Chris On Thu, Jun 16, 2016 at 10:14 PM, Simon Slavinwrote: > > On 16 Jun 2016, at 9:53pm, Drago, William @ CSG - NARDA-MITEQ > wrote: > > > Should that function insert its results into a table that looks like the > one below, or is there a better way? > > > > CREATE TABLE Groups ( > > ID INTEGER PRIMARY KEY, > > AppleID1 INTEGER > > AppleID2 INTEGER > > AppleID3 INTEGER > > AppleID4 INTEGER > > ); > > You would definitely want each of the four AppleIDs to have a FOREIGN KEY > reference to the Apple table. > > An alternative to your Groups table would be a Membership table: > > CREATE TABLE Members ( > AppleID INTEGER, > GroupID INTEGER, > FOREIGN KEY (AppleID) REFERENCES Apples(ID) > ); > > It is the responsibility of your software to ensure that every GroupID > appears exactly four times in Members. > > This would allow you to create another table, Groups, which stored things > like the group's colour and total weight. And this should be a foreign key > reference for the Members table too. > > Simon. > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Correct, best, or generally accepted database structure for groups of things
On 16 Jun 2016, at 9:53pm, Drago, William @ CSG - NARDA-MITEQwrote: > Should that function insert its results into a table that looks like the one > below, or is there a better way? > > CREATE TABLE Groups ( > ID INTEGER PRIMARY KEY, > AppleID1 INTEGER > AppleID2 INTEGER > AppleID3 INTEGER > AppleID4 INTEGER > ); You would definitely want each of the four AppleIDs to have a FOREIGN KEY reference to the Apple table. An alternative to your Groups table would be a Membership table: CREATE TABLE Members ( AppleID INTEGER, GroupID INTEGER, FOREIGN KEY (AppleID) REFERENCES Apples(ID) ); It is the responsibility of your software to ensure that every GroupID appears exactly four times in Members. This would allow you to create another table, Groups, which stored things like the group's colour and total weight. And this should be a foreign key reference for the Members table too. Simon. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Correct, best, or generally accepted database structure for groups of things
On 6/16/2016 4:53 PM, Drago, William @ CSG - NARDA-MITEQ wrote: Say I had a table of apples: CREATE TABLE Apples ( ID INTEGER PRIMARY KEY, Color TEXT COLLATE NOCASE, --Could be Red, Green, or Yellow Height REAL, --Measured in cm Width REAL --Measured in cm Weight REAL --Measured in grams ); And say I had a function that looks at the Apples table and finds groups of 4 apples that match in color, dimensions, and weight. Should that function insert its results into a table that looks like the one below, or is there a better way? CREATE TABLE Groups ( ID INTEGER PRIMARY KEY, AppleID1 INTEGER AppleID2 INTEGER AppleID3 INTEGER AppleID4 INTEGER ); That rather depends on what you plan to do next with this data, what kind of queries you expect to run on it. These apples are part of a communication system and there will always be exactly 4 in each group. My concern is, from the Groups table how to do I find the number of groups of red apples, or groups of green apples that weight approx. 80 grams and are approx. 10cm tall without including redundant information from the Apples table? "Approx 80 grams" doesn't look like redundant information; I assume Apples.Weight may store 79 or 81 for an apple belonging to such a group. -- Igor Tandetnik ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] Correct, best, or generally accepted database structure for groups of things
All, Say I had a table of apples: CREATE TABLE Apples ( ID INTEGER PRIMARY KEY, Color TEXT COLLATE NOCASE, --Could be Red, Green, or Yellow Height REAL, --Measured in cm Width REAL --Measured in cm Weight REAL --Measured in grams ); And say I had a function that looks at the Apples table and finds groups of 4 apples that match in color, dimensions, and weight. Should that function insert its results into a table that looks like the one below, or is there a better way? CREATE TABLE Groups ( ID INTEGER PRIMARY KEY, AppleID1 INTEGER AppleID2 INTEGER AppleID3 INTEGER AppleID4 INTEGER ); These apples are part of a communication system and there will always be exactly 4 in each group. My concern is, from the Groups table how to do I find the number of groups of red apples, or groups of green apples that weight approx. 80 grams and are approx. 10cm tall without including redundant information from the Apples table? Any advice is appreciated. Thanks, -- Bill Drago Staff Engineer L3 Narda-MITEQ 435 Moreland Road Hauppauge, NY 11788 631-272-5947 / william.dr...@l-3com.com CONFIDENTIALITY, EXPORT CONTROL AND DISCLAIMER NOTE:This e-mail and any attachments are solely for the use of the addressee and may contain information that is privileged or confidential. Any disclosure, use or distribution of the information contained herein is prohibited. In the event this e-mail contains technical data within the definition of the International Traffic in Arms Regulations or Export Administration Regulations, it is subject to the export control laws of the U.S.Government. The recipient should check this e-mail and any attachments for the presence of viruses as L-3 does not accept any liability associated with the transmission of this e-mail. If you have received this communication in error, please notify the sender by reply e-mail and immediately delete this message and any attachments. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users