I need to create a database using sql for my reviews site. I tried to use the on delete and on update constraints but I'm not sure if they are right. I created three tables a 'cars'(my review items) 'reviews'(holds the reviews) and a 'users' one. I linked cars_id and users_id with reviews table. I used on update cascade and on delete cascade for both. I'm not sure if that's right. Can someone help me understand them more?
SQL Confused over ON UPDATE and ON DELETE
138 Views Asked by user3183658 At
1
There are 1 best solutions below
Related Questions in SQL
- Can MVC.NET prevent SQL-injection at razor or controller level?
- SQL server not returning all rows
- When dealing with databases, does adding a different table when we can use a simple hash a good thing?
- Creating a parametrized field name for a SELECT clause
- Combine two rows based on common ID
- Column displays each count
- Slick query for one to optional one (zero or one) relationship
- Aggregate and count in PostgreSQL
- MAX and GROUP BY - SQL
- SQL statement for a tricky 2 table query
- How to create nested selects with sql?
- Pull and push data from and into sql databases using Excel VBA without pasting the data in Excel sheets
- Best Practice for adding columns to a Table in Oracle database
- SQL FIFO STACK using two tables
- SQL Query - Order by String (which contains number and chars)
Related Questions in CASCADE
- Entity Framework : Why WillCascadeOnDelete() Method is ignored?
- Is there a way to create a primary key and have it cascade into other tables without re-entering data into the new tables?
- Set null on cascading delete
- GAE datastore foreign key and join
- Cascade DIVs like Windows
- Symfony entity no configured for cascade
- SQLite : On cascade delete doesn't works
- How to delete cascade when parentID and childID are on the same table?
- Simplest way to cascade styles in react native
- Detect rectangle shape OpenCv
- On Delete Cascade - SQL Alchemy + Postgres
- MS Access SQL On Update/On Delete
- Oracle cascade remove only when last reference was deleted
- Core Data many-to-many cascade archival (trashing) for last child object
- Hibernate - save some Entity in one transaction
Related Questions in CASCADING-DELETES
- delete the output of a join (record in multipe tables)
- Removing one child detaches all others in Entity Framework C#
- Cannot delete a records (OneToMany) with Symfony
- Sql delete parent from child/delete whole tree
- Spring Data JPA deletions not what I expected
- EclipseLink Remove Cascade
- How to cascade deletes in Titan DB?
- Delete belongsTo association not working
- What is the recommended equivalent of cascaded delete in MongoDB for N:M relationships?
- How to delete a child record when there ManyToOne relationship?
- How to do a cascade delete in .Netcore 2.0
- C# - Predict file system events on folder delete
- Adding "Soft Delete" to an existing system
- Using EF4 CTP5 code first with no cascade delete
- Cascade deletes on linked table joining 2 tables that each have a cascade delete to another table. How?
Related Questions in RESTRICT
- How to limit usage of a tool to users within your company network?
- How to restrict public access to a webapplication?
- Internet Explorer restrict multiple tabs
- ActiveMQ 5.10: Cannot restrict access to server from remote client
- Restrict subdomain to root access
- Display information page to only logged in and particular customer group
- Useless case for restrict
- Retrieve current Outlook appointment
- On delete restrict SQL help
- Restricting "hg push" via hg-ssh for shared hosting
- openERP restrict users
- openERP rules and restrictions
- VBA Filter only returning exactly half the restricted criteria items
- restricting character set in a Textinput field
- Restrict a Wordpress Template to show only one category
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
It is a matter of data modelling.
Ask yourself the question:
"If I delete a car, do I want to delete the relational records of other tables too?"
If YES put it to CASCADE etc.
Or:
"If I delete a user, do I want to delete his cars too?"
"If I delete a car, do I want do delete the corresponding user too?"
Maybe a good idea to read first here:
http://en.wikipedia.org/wiki/Relational_database
and then here: http://dev.mysql.com/doc/refman/5.1-olh/de/innodb-foreign-key-constraints.html