Parent child relationship questions
I have two related tables:
device_details
- device_id
- device_name
- device_type
device_events
- device_id
- event_type
- event_date
One to many relationship: device_id
I have two questions that I would like some advice on:
1. How should I insert records into the device_details & device_events? The first insert will require inserts into both tables but subsequent inserts will only insert into device_events. There needs to be some sort of 'if exists' condition on the device_details table.
2. I need to select all records from device_details along with only the last/most recent device_events record, then filter the results using event_type. What's the most efficient way to achieve this?
Thanks for any help, as can be seen my SQL skills is extremely limited.
Subject
Written By
Posted
Parent child relationship questions
July 24, 2022 05:13AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.