Hot answers tagged


1. Assuming that sku and item_number will always hold unique values I consider that you have come up to the answer by yourself, since an item_number is an optional attribute (or column at the implementation phase), i.e., it does not apply to all the product occurrences, therefore, from a logical point of view, it decidedly cannot (should not) be declared as ...


The compound PK of EmployeeId and AddressTypeId is exactly what you want, and you don't need anything else. The relationship is still a one-to-many relationship, as for one employee, you may have many address whether it is a home address or a work address. The bridge table is interesting if you may have the same address for multiple employees AND that a ...


Create a supertype entity CarBody for subtypes Sedan, SUV, ... and move all general information to that supertype. Your M-M relationship will be between CarBody and Feature. See this topic for subtyping in datamodeling Supertype/Subtype deciding between category: complete disjoint or incomplete overlapping .


The CASCADE clause works in the opposite direction. From the parent to the child table. When you delete a row in the parent table, the related rows in the child table are deleted as well.


What you are looking for is a 0-many relationship. This is usually referenced by a third table. Publication_Scientists : Publication_Id (int) | Scientist_Id (int) with 1:1 relationships back to the other two tables. Preferably using something like an enforced foreign key.


If your attribute item_number is unique, you can leave it in your original table even in case it can have null values. In fact the PostgreSQL manual says: For the purpose of a unique constraint, null values are not considered equal. So this could be right solution: CREATE TABLE product ( sku text PRIMARY KEY, name text ...


Error code 1064 : This means you have an error in your SQL syntax.( ; missed) Select Model, Variant, EngineSize, RegYear, Mileage, Price, Sector from sampledata ; update sampledata set RegYear = 2010 - RegYear where sector = 'Van Derived Cars' and mileage > 200 and regyear != -1 and price != 999999; Mysql error code 1175 : If you ...


The simplest and probably most common way would be to declare the (album_id, artist_id) pair of columns a unique composite key. There are two variations of this approach. First, you can keep the current structure of the album_artist table and simply add a unique constraint on the said two columns: ALTER TABLE album_artist ADD CONSTRAINT uq_album_artist ...


Normal forms are used to eliminate or at least reduce redundancy in data, as well as to eliminate the so called insertion/deletion anomalies. The BCNF eliminates redundancies and anomalies, but decomposing a relation in BCNF sometimes has the unpleasant effect of causing the loss of one or more functional dependencies during the process. For this reason ...

Only top voted, non community-wiki answers of a minimum length are eligible