Skip to content
Advertisement

Tag: relational-database

Why store whole records in audit tables?

I worked in several companies and in each of them audit tables have been storing full snapshots of records for every change. To my understanding it’s enough to store only changed columns to recreate record in any given point of time. It will obviously reduce storage space. Moreover I suppose it would improve performance as we would need to write

Relational Databases: Is it fine to have a foreign key referencing an Associative table?

Lets say we have Passengers, where Passengers can attend many Flights, and one Flight may have many Passengers. In each Flight, each Passenger has a unique selection of Movies he/she can watch. For Passengers, Flights, and the association between them, we have three tables: For Movies, it must specify for which Passenger and for which Flight will it be available

Postgresql delete multiple rows from multiple tables

Consider 2 or more tables: I wish to delete all users and their orders that match first name ‘Sam’. In mysql, I usually do left join. In this example userid is unknown to us. What is the correct format of the query? Answer http://www.postgresql.org/docs/current/static/sql-delete.html You can also create the table with ON delete cascade http://www.postgresql.org/docs/current/static/ddl-constraints.html

PostgreSQL Foreign Key syntax

I have 2 tables as you will see in my PosgreSQL code below. The first table students has 2 columns, one for student_name and the other student_id which is the Primary Key. In my second table called tests, this has 4 columns, one for subject_id, one for the subject_name, then one for a student with the highest score in a

Advertisement