As we know a candidate key is a column or combination of columns that uniquely identifies the rows in a relation. Suppose I have a relation in which candidate keys are combinations of columns. I want to ask, is it possible that a subset of a candidate key also uniquely identifies the row? OR is a candidate key a key
Tag: relational-database
Insert multiple rows in one table based on number in another table
I am creating a database for the first time using Postgres 9.3 on MacOSX. Let’s say I have table A and B. A starts off as empty and B as filled. I would like the number of entries in column all_names in table B to equal the number for each names in table A like table B below. Thus names
Complicated MySQL Select query
Here is my table layout: What I would like to do: Count the number of votes for each songID in a particular room (passed in as a parameter). Find out if the userID has at least one vote for a song in a particular room. UserID is also passed in as a parameter. An extension of the two above. If
How to perform a LEFT JOIN in SQL Server between two SELECT statements?
I have two SELECT statements in SQL Server like these: I want to perform a LEFT JOIN between these two SELECT statements on [UserID] attribute and [TailUser] attribute. I want to join existent records in second query with the corresponding records in first query and NULL value for absent records. How can I do this? Answer
Can all SQL queries be represented in Relational Algebra, Domain and Tuple relational calculus
My query includes a having and count or all in. How are these represented in RA/DRC/TRC? Would I have to simplify my SQL query even more? Here is a simplified example: empl(employee (primary key), …
How to Implement Referential Integrity in Subtypes
I have the following tables in a relational database: Basically, ReadingSwitch and ReadingValue are subtypes of Reading and SwitchSensor and AnalogSensor are subtypes of Sensor. A reading can either be a SwitchReading or ValueReading value – it cannot be both, and a Sensor can either be an AnalogSensor or a SwitchSensor. The only way I’ve come across to do this
How to create relationships in MySQL
In class, we are all ‘studying’ databases, and everyone is using Access. Bored with this, I am trying to do what the rest of the class is doing, but with raw SQL commands with MySQL instead of using Access. I have managed to create databases and tables, but now how do I make a relationship between two tables? If I