relational

Find the sids of the suppliers who supply every part

徘徊边缘 提交于 2019-12-01 10:51:57
3 tables: Suppliers(sid, sname, address), Parts(pid, pname, colour), Catalog(sid, pid, cost) The answer to find all the suppliers who supply every part is: SELECT C.sid FROM Catalog C WHERE NOT EXISTS ( SELECT P.pid FROM Parts P WHERE NOT EXISTS ( SELECT C1.sid FROM Catalog C1 WHERE C1.sid = C.sid AND C1.pid = P.pid ) ) Could someone explain this answer to me? I'm just a bit lost! I've heard it explained as 'Find suppliers such that there does not exist a part that they do not sell', but I'm struggling to see how SELECT C1.sid FROM Catalog C1 WHERE C1.sid = C.sid AND C1.pid = P.pid )

Find the sids of the suppliers who supply every part

一个人想着一个人 提交于 2019-12-01 07:32:45
问题 3 tables: Suppliers(sid, sname, address), Parts(pid, pname, colour), Catalog(sid, pid, cost) The answer to find all the suppliers who supply every part is: SELECT C.sid FROM Catalog C WHERE NOT EXISTS ( SELECT P.pid FROM Parts P WHERE NOT EXISTS ( SELECT C1.sid FROM Catalog C1 WHERE C1.sid = C.sid AND C1.pid = P.pid ) ) Could someone explain this answer to me? I'm just a bit lost! I've heard it explained as 'Find suppliers such that there does not exist a part that they do not sell', but I'm

SQL two tables and creating a link table

梦想与她 提交于 2019-11-30 21:50:18
I have two tables: Employee (ID, Name, Address) and Store(ID,Address) and I would like to record information about people who work in each store. I thought of making a new table called Employee_List table. My questions: 1- Employee_List and Employee has one-to-many relation, right? 2- Employee_list to store has one-to-one relation, right? 3- How to define foreign and primary keys for Employee_List table? Employee_list should have: employee_listid (INT PK) employee_id (INT FK) store_id (INT FK) I would recommend changing the table name to represent the composite table, i.e. EmployeeStores .

SQL two tables and creating a link table

倖福魔咒の 提交于 2019-11-30 17:38:53
问题 I have two tables: Employee (ID, Name, Address) and Store(ID,Address) and I would like to record information about people who work in each store. I thought of making a new table called Employee_List table. My questions: 1- Employee_List and Employee has one-to-many relation, right? 2- Employee_list to store has one-to-one relation, right? 3- How to define foreign and primary keys for Employee_List table? 回答1: Employee_list should have: employee_listid (INT PK) employee_id (INT FK) store_id

(De)Normalization of two relations

一世执手 提交于 2019-11-30 13:34:50
People who read C.J.Date's Introduction to Database System or books of similar level should not have problems with definition of normalization and denormalization. However, memory is not what it used to be and I find myself often looking at some design and saying that it is not normalized even though I can not find which of the normal forms it is breaking. The actual example that illustrate it is: If we have relations r1 (A, B, C) and r2 (A, D) with FDs: AB->C and A->D and r1 represent detailed data, while r2 is summary of that data (in another words each instance of D is a function of values

Efficient persistent data structures for relational database

主宰稳场 提交于 2019-11-30 05:18:34
I'm looking for material on persistent data structures that can be used to implement a relational model. Persistence in the meaning of immutable data structures. Anyone know of some good resources, books, papers and such? (I already have the book Purely Functional Data Structures , which is a good example of what I'm looking for.) It is straightforward to modify the ubiquitous B-tree to be persistent. Simply always alloctate a new node whenever a node is modified, and return the new node to the recursive caller, who will insert it at that level by allocating a new node, etc. Ultimate the new

Using Tuples in Ruby?

我的梦境 提交于 2019-11-30 02:36:55
Does anyone use tuples in Ruby? If so, how may one implement a tuple? Ruby hashes are nice and work almost as well, but I'd really like to see something like the Tuple class in Python, where you can use . notation to find the value for which you are looking. I'm wanting this so that I can create an implementation of D , similar to Dee for Python. OpenStruct ? Brief example: require 'ostruct' person = OpenStruct.new person.name = "John Smith" person.age = 70 person.pension = 300 puts person.name # -> "John Smith" puts person.age # -> 70 puts person.address # -> nil Based on the fact that you

Should I delete or disable a row in a relational database?

我们两清 提交于 2019-11-29 20:19:26
In a brand new program where space isn't really that big a deal, is it better to delete a row or to disable a row by let's say a boolean "Disabled" and have the program just ignore it? For example, if I wanted to remove a user from a program. Not deleting will create a new class of bugs for all future queries. Don't forget that query writing is often done by power users (i.e. non-IT professionals), and junior developers. So now every table that has invalid data marked only by a BIT active flag will need an additional AND in the WHERE clause for every query from now until forever. This will

Reasonable Export of Relational to Non-Relational Data

笑着哭i 提交于 2019-11-29 13:05:07
We have different products that rely on relational databases for various reasons, basically the transactional nature of the operations (atomicity, consistency, etc.). This is not going to change any time soon. Given this scenario, are there any possible justifications to export the data to a NoSQL solution? Maybe Datawarehousing, Analytics, etc. Any comments are welcome. "Data" is just a vague generality without a data structure. "Relational" means the data structure is relations/tables with generic queries. ( Not automatically interleaved execution of semantically atomic concurrent

Use two or more relational operators in one sentence in python

有些话、适合烂在心里 提交于 2019-11-29 12:28:29
How do two or more relational operators in a single sentence work? For example: 5 < 5 <= 3 > 10 Python supports double-ended comparisons. For example, 3 < x <= 7 is a check for 3 < x and x <= 7 (with x being evaluated just once). By extension, 5 < 5 <= 3 > 10 means (5 < 5) and (5 <= 3) and (3 > 10) , all of which are False , so the whole expression evaluates to False . https://docs.python.org/2/reference/expressions.html#comparisons It's evaluated in order, so your expression expands to 5 < 5 and 5 <= 3 and 3 > 10 which evaluates to False 来源: https://stackoverflow.com/questions/22776897/use