three-valued-logic

Options for eliminating NULLable columns from a DB model (in order to avoid SQL's three-valued logic)?

空扰寡人 提交于 2020-07-17 08:02:36
问题 Some while ago, I've been reading through the book SQL and Relational Theory by C. J. Date. The author is well-known for criticising SQL's three-valued logic (3VL). 1) The author makes some strong points about why 3VL should be avoided in SQL, however he doesn't outline how a database model would look like if nullable columns weren't allowed . I've thought on this for a bit and have come up with the following solutions. If I missed other design options, I would like to hear about them! 1)

NOT IN does not produce same results as NOT EXISTS

纵饮孤独 提交于 2019-12-20 03:37:19
问题 These are rather basic statements. I have a list of graphics which are linked to items in another table. I want to check how many of the graphics are not in use and can theoretically be deleted. So first I used the NOT IN clause: SELECT [GraphicNr] ,[Graphicfile] FROM [dbo].[Graphic] WHERE graphicnr NOT IN (SELECT graphicnr FROM dbo.Komp) Which gave zero results, which seemed weird to me. After rewriting it to a NOT EXISTS, I got about 600 results: SELECT [GraphicNr] ,[Graphicfile] FROM [dbo]

NOT IN does not produce same results as NOT EXISTS

柔情痞子 提交于 2019-12-02 00:27:54
These are rather basic statements. I have a list of graphics which are linked to items in another table. I want to check how many of the graphics are not in use and can theoretically be deleted. So first I used the NOT IN clause: SELECT [GraphicNr] ,[Graphicfile] FROM [dbo].[Graphic] WHERE graphicnr NOT IN (SELECT graphicnr FROM dbo.Komp) Which gave zero results, which seemed weird to me. After rewriting it to a NOT EXISTS, I got about 600 results: SELECT [GraphicNr] ,[Graphicfile] FROM [dbo].[Graphic] a WHERE NOT EXISTS (SELECT graphicnr FROM dbo.komp b WHERE a.GraphicNr = b.GraphicNr) So I

Example of three valued logic in SQL Server

你。 提交于 2019-11-27 16:40:53
问题 I understand that SQL uses three valued logic but I am having trouble understanding how to use this in practice, especially why TRUE || NULL = True and FALSE && NULL = False instead of evaluating to null . Here are the three valued truth tables that apply to SQL Server: I found a couple explanations of three valued logic online but I cannot find any real code examples of this in use. Can someone show me a code example using three valued logic to help me understand this a little better? 回答1: