On MySQL Views (Re: Accountability with MySQL)

2006-03-16 Thread Martijn Tonies
Hello Gordon, > And now we are down to reality. This is a MySQL list. Views are a wonderful > thing for creating an isolation layer between the application and the > database. However, MySQL's current implementation makes it extremely > difficult in many cases to avoid full table scans when you de

RE: Accountability with MySQL

2006-03-16 Thread Gordon
f Database magazine. In the end I believe they agreed to disagree. -Original Message- From: Martijn Tonies [mailto:[EMAIL PROTECTED] Sent: Thursday, March 16, 2006 5:33 AM To: mysql@lists.mysql.com Subject: Re: Accountability with MySQL From: <[EMAIL PROTECTED]> > "Martijn T

True Propositions (was Re: Accountability with MySQL)

2006-03-16 Thread Martijn Tonies
> >> > Read the literature on how to design databases. What you do > >> > is storing "true propositions". That is, each attribute defines a > >> > certain "true proposition". For example: > >> > > >> > Employee "Martijn" has Employee# 14. > >> > > >> > You should be able to derive these sentences f

Re: Accountability with MySQL

2006-03-16 Thread Martijn Tonies
James, > Also, surely if you left join to a table then if there's no matching row you get a null value in your result set. So I'm not sure what the difference is between getting that null because you store it in a column in the primary table, and deriving it by left joining to a related table wit

Re: Accountability with MySQL

2006-03-16 Thread James Harvard
Also, surely if you left join to a table then if there's no matching row you get a null value in your result set. So I'm not sure what the difference is between getting that null because you store it in a column in the primary table, and deriving it by left joining to a related table with no mat

Re: Accountability with MySQL

2006-03-16 Thread Martijn Tonies
> > > in order to retrieve all the information about them. Replacing a > > > theoretically ugly null flag with a 10 way join strikes me, as an > engineer > > > rather than a theoretician, the wrong side of the > elegance/practicality > > > trade-off. > > > > Using NULLs as well as de-normalization

Re: Accountability with MySQL

2006-03-16 Thread Alec . Cawley
"Martijn Tonies" <[EMAIL PROTECTED]> wrote on 16/03/2006 11:32:45: > From: <[EMAIL PROTECTED]> > > "Martijn Tonies" <[EMAIL PROTECTED]> wrote on 16/03/2006 11:02:32: > > > > > Well, the question still is if you should store "unknown" at all ;) > > > > > > Not according to Date: you should store wh

Re: Accountability with MySQL

2006-03-16 Thread Martijn Tonies
From: <[EMAIL PROTECTED]> > "Martijn Tonies" <[EMAIL PROTECTED]> wrote on 16/03/2006 11:02:32: > > > Well, the question still is if you should store "unknown" at all ;) > > > > Not according to Date: you should store what is known. See the remarks > > about the "true propositions", from which relat

Coalesce (was: Re: Accountability with MySQL)

2006-03-16 Thread Martijn Tonies
> > Ah well, SQL (these days) provides plenty of functions to avoid > > the problems. Coalesce being one of them... > > > > How often do people write: > > > > (probably not valid MySQL) > > select firstname || coalesce(middlename || ' ', ' ') || lastname > > from ... > > > Your syntax isn't quite

Re: Accountability with MySQL

2006-03-16 Thread Alec . Cawley
"Martijn Tonies" <[EMAIL PROTECTED]> wrote on 16/03/2006 11:02:32: > Well, the question still is if you should store "unknown" at all ;) > > Not according to Date: you should store what is known. See the remarks > about the "true propositions", from which relational databases are derived > (but

Re: Accountability with MySQL

2006-03-16 Thread Martijn Tonies
> But (in at least some situations) is not appropriate to record that you know that you don't have a value? > Sure it would. It it's needed. But the answer doesn't have to be a NULL. Remember the example about recording the fact that a student did not make a test for whatever reason? It was th

Re: Accountability with MySQL

2006-03-16 Thread James Harvard
But (in at least some situations) is not appropriate to record that you know that you don't have a value? I think the words of Donald Rumsfeld are appropriate here: "There are known knowns. These are things we know that we know. There are known unknowns. That is to say, there are things that we

Re: Accountability with MySQL

2006-03-16 Thread Martijn Tonies
From: "Mark Leith" > Martijn Tonies wrote: > > >We're arguing about whether or not your database design > >(as stored on disk) should contain NULLs. > > > >IMO: no, or at least as few as possible. > > > > > I believe the answer really is - *it depends*. > > You are both right, really. Martijn,

Re: Accountability with MySQL

2006-03-16 Thread Mark Leith
Martijn Tonies wrote: We're arguing about whether or not your database design (as stored on disk) should contain NULLs. IMO: no, or at least as few as possible. I believe the answer really is - *it depends*. You are both right, really. Martijn, yes, according to academia and proper databa

Re: Accountability with MySQL

2006-03-16 Thread Martijn Tonies
From: "James Harvard" > At 7:28 pm +0100 14/3/06, Martijn Tonies wrote: > >Given that NULLs basically means the absence of a value (eg: unknown), you shouldn't be storing NULLs. > > At 1:49 pm -0500 14/3/06, Rhino wrote: > >A null means "unknown or not applicable" and is a perfectly valid value to

Re: Accountability with MySQL

2006-03-15 Thread James Harvard
At 7:28 pm +0100 14/3/06, Martijn Tonies wrote: >Given that NULLs basically means the absence of a value (eg: unknown), you >shouldn't be storing NULLs. At 1:49 pm -0500 14/3/06, Rhino wrote: >A null means "unknown or not applicable" and is a perfectly valid value to use >in many, many situation

Re: Accountability with MySQL

2006-03-15 Thread Stephen Cook
A commonly used example (at least at my last 3 jobs) would be a table of demographics for people (whether they be employees, clients, whatever). You can have one table and allow NULLs for some of the fields (id, LastName, FirstName, MiddleInitial, Title, NameSuffix, AddressLine1, AddressLine2,

Re: Accountability with MySQL

2006-03-15 Thread Rhino
- Original Message - From: "Martijn Tonies" <[EMAIL PROTECTED]> To: Sent: Wednesday, March 15, 2006 10:47 AM Subject: Re: Accountability with MySQL Hello, (please read all before replying) >> >> > Basics of database design: store what you know. &

Re: Accountability with MySQL

2006-03-15 Thread Martijn Tonies
Hello, (please read all before replying) > >> >> > Basics of database design: store what you know. > >> >> > > >> >> > Given that NULLs basically means the absence of a value > >> >> > (eg: unknown), you shouldn't be storing NULLs. > >> >> > > >> >> Nonsense!! > >> > > >> > That's a bold statemen

Re: Accountability with MySQL

2006-03-15 Thread Rhino
- Original Message - From: "Martijn Tonies" <[EMAIL PROTECTED]> To: Sent: Wednesday, March 15, 2006 2:53 AM Subject: Re: Accountability with MySQL >> > Basics of database design: store what you know. >> > >> > Given that NULLs basi

Re: Accountability with MySQL

2006-03-14 Thread Martijn Tonies
> >> > Basics of database design: store what you know. > >> > > >> > Given that NULLs basically means the absence of a value > >> > (eg: unknown), you shouldn't be storing NULLs. > >> > > >> Nonsense!! > > > > That's a bold statement ... > > > >> That's simply wrong. A null means "unknown or not ap

Re: Accountability with MySQL

2006-03-14 Thread Martijn Tonies
> At 7:48 pm -0500 14/3/06, Rhino wrote: > >>Ah, so now things become clear, a NULL actually can mean > >>two things? So much for clarity then... > > > >Come on; that's not fair. "Unknown" and "not applicable" are more like different senses of the same thing, not two opposite things. > > > IIRC (

Re: Accountability with MySQL

2006-03-14 Thread James Harvard
At 7:48 pm -0500 14/3/06, Rhino wrote: >>Ah, so now things become clear, a NULL actually can mean >>two things? So much for clarity then... > >Come on; that's not fair. "Unknown" and "not applicable" are more like >different senses of the same thing, not two opposite things. IIRC (but please don'

Re: Accountability with MySQL

2006-03-14 Thread Rhino
- Original Message - From: "Martijn Tonies" <[EMAIL PROTECTED]> To: "Rhino" <[EMAIL PROTECTED]>; Sent: Tuesday, March 14, 2006 2:16 PM Subject: Re: Accountability with MySQL > >Should you have a flag for the status "movement complet

Re: Accountability with MySQL

2006-03-14 Thread Rhino
- Original Message - From: "Bruno B B Magalháes" <[EMAIL PROTECTED]> To: Sent: Tuesday, March 14, 2006 2:07 PM Subject: Re: Accountability with MySQL I am designing a simple accountability system so all the partners can have direct access to it by intranet. I w

Re: Accountability with MySQL

2006-03-14 Thread Martijn Tonies
> > >Should you have a flag for the status "movement complete" ? I would say > >>yes but instead of a simple checkbox, you could store a date value. That > >>gives you two pieces of information > >> > >>a) if the date is null then the movement is not complete. > >>b) if the date is NOT null then t

Re: Accountability with MySQL

2006-03-14 Thread Bruno B B Magalháes
>>I am designing a simple accountability system so all the partners can >> have >> direct access to it by intranet. >> >> I was designing the data model, and came up with this: >> >> CREATE TABLE `moviments` ( >> `moviment_id` int(20) NOT NULL auto_increment, >> `moviment_date` date NOT NULL def

Re: Accountability with MySQL

2006-03-14 Thread Rhino
- Original Message - From: "Martijn Tonies" <[EMAIL PROTECTED]> To: Sent: Tuesday, March 14, 2006 1:28 PM Subject: Re: Accountability with MySQL >Should you have a flag for the status "movement complete" ? I would say yes but instead of a simple che

Re: Accountability with MySQL

2006-03-14 Thread Rhino
- Original Message - From: "Martijn Tonies" <[EMAIL PROTECTED]> To: Sent: Tuesday, March 14, 2006 1:16 PM Subject: Re: Accountability with MySQL Hello Bruno, well about the date default value being invalid, well it´s working here in my system (MySQL 4.1.16, Mac O

Re: Accountability with MySQL

2006-03-14 Thread Martijn Tonies
Hello Shawn, > > well about the date default value being invalid, well it´s working here in > > my system (MySQL 4.1.16, Mac OS X 10.4.5), and all my systens work with > > this... > > Yes, it's a valid value in MySQL, but it's an invalid date, > that's what I'm trying to say. Why have an invalid d

Re: Accountability with MySQL

2006-03-14 Thread Rhino
- Original Message - From: "Bruno B B Magalháes" <[EMAIL PROTECTED]> To: Sent: Tuesday, March 14, 2006 12:41 PM Subject: Accountability with MySQL I am designing a simple accountability system so all the partners can have direct access to it by intranet. I was de

Re: Accountability with MySQL

2006-03-14 Thread Martijn Tonies
>Should you have a flag for the status "movement complete" ? I would say >yes but instead of a simple checkbox, you could store a date value. That >gives you two pieces of information > >a) if the date is null then the movement is not complete. >b) if the date is NOT null then the movement is compl

Re: Accountability with MySQL

2006-03-14 Thread SGreen
"Martijn Tonies" <[EMAIL PROTECTED]> wrote on 03/14/2006 01:16:11 PM: > Hello Bruno, > > > well about the date default value being invalid, well it´s working here in > > my system (MySQL 4.1.16, Mac OS X 10.4.5), and all my systens work with > > this... > > Yes, it's a valid value in MySQL, bu

Re: Accountability with MySQL

2006-03-14 Thread Martijn Tonies
Hello Bruno, > well about the date default value being invalid, well it´s working here in > my system (MySQL 4.1.16, Mac OS X 10.4.5), and all my systens work with > this... Yes, it's a valid value in MySQL, but it's an invalid date, that's what I'm trying to say. Why have an invalid date as the

Re: Accountability with MySQL

2006-03-14 Thread SGreen
Bruno B B Magalháes <[EMAIL PROTECTED]> wrote on 03/14/2006 12:41:35 PM: > I am designing a simple accountability system so all the partners can have > direct access to it by intranet. > > I was designing the data model, and came up with this: > > CREATE TABLE `moviments` ( > `moviment_id` i

Re: Accountability with MySQL

2006-03-14 Thread Bruno B B Magalháes
Hi Martijn, well about the date default value being invalid, well it´s working here in my system (MySQL 4.1.16, Mac OS X 10.4.5), and all my systens work with this... About the business logic I was thinking about showing the current month by default, and if the user wants he can select diferent d

Re: Accountability with MySQL

2006-03-14 Thread Martijn Tonies
Hello Bruno, > I am designing a simple accountability system so all the partners can have > direct access to it by intranet. > > I was designing the data model, and came up with this: > > CREATE TABLE `moviments` ( > `moviment_id` int(20) NOT NULL auto_increment, > `moviment_date` date NOT NUL

Accountability with MySQL

2006-03-14 Thread Bruno B B Magalháes
I am designing a simple accountability system so all the partners can have direct access to it by intranet. I was designing the data model, and came up with this: CREATE TABLE `moviments` ( `moviment_id` int(20) NOT NULL auto_increment, `moviment_date` date NOT NULL default '-00-00', `m