Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

How do relationshiped tables behave

$
0
0

Hi!

I'm not sure if should be asking this in vb.net forums or sql forums. So please forgive me if i'm in the wrong place. I have this collection of relationship tables in my sql server. In my previous sql related projects I never relationshiped anything and just maintained data relationships manually.

But for this project i'd like to try and use relationships. Trouble is , I only know relationships from access and even that was many many years ago. These are my relationships.

So my main question is, what will happen if I attempt to insert a line into the scan_LogEntry table?

When inserting a line into scan_LogEntry the scan_Projects table will have to add records to it's table if the project does not already exist? I assume there are special SQL commands for that? Or will I have to write a separate command to then insert the record to the scan_Projects before I can insert a line into the scan_LogEntry table ?

If the scan_Projects ID is already present however that would mean that I can add the line without a problem right?

Far as I understand it the relationships prevent me from inserting a line where an ID is either not supplied or wrong and makes it so I only have to change one record once in order to modify the relevant data across the board, correct?

http://code.tutsplus.com/articles/sql-for-beginners-part-3-database-relationships--net-8561

just bumped into this so I will give that a read tomorrow.

additional info underneath (read if very bored :P)

I am self taught so please forgive my ignorance. Originally I wanted to primary key my barcode columns, but they have symbols in them and a fixed format and I have thus-far not been able to figure out a way to use those as a primary key. What will happen is that I will be supplied with 3 barcodes and 2 time stamps, I will then have to identify the user, action and project by knowing only the barcodes. Using that information I will then either have to insert a new record to scan_Projects before I can add a line to the scan_LogEntry table. Or if the scan_Projects record already exists I will then only insert a line in the scan_LogEntry table. scan_Users, scan_Actions and scan_Department will already exist so I will never have to make a new record there on the fly.

Apologies for the essay. It's not always easy to explain these things.

 


Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>