Oracle SQL Tutorial 6 - Relationships and Primary and Foreign Keys - Database Design Primer 3

submitted by mkenny400 on 03/23/18 1

HAPPY VALENTINES DAY!!! Let's talk relationships.. This is the 6th video in your Oracle Database series. We are discussing database relationships which are a key feature of relational database management systems. We first discussed entities and attributes. I talked about how each entity is assigned a table and each attribute is a column within a table. We moved on to the three kinds of relationships. The first was one-to-one. This describes an entity and an attribute. A piece of data that is exclusive to an entity is, by definition, an attribute of that entity. This is stored in one table with the attribute being a column within this table. The second relationship is one-to-many. This relationship is between two entities. The way we properly store this in a database is using a foreign key in the child table. Remember, the child table is the entity on the many side of the one-to-many relationship. Every row within the child table will have a value for the foreign key that references a primary key in the parent table. This assumes that the foreign key field is not optional (NOT NULL). If the foreign key is optional, than a reference is not required but any reference must be valid. The third kind of relationship is a many-to-many relationship. In this situation, we need 3 tables. The many-to-many relationship is broken up into two one-to-many relationships. The intermediary table will associate each entity from one table with the appropriate entities in the other table. There is debate as to whether this table needs a primary key. This is because you can intact use the combination of two foreign keys as a primary key. This works because we will never have two duplicate rows within the intermediary table and the two foreign keys work as a compound key because of this. We finally discussed primary keys and foreign keys. Primary keys are used to keep each row inside of a table unique. If this key is a computer generated number it is known as a surrogate key, otherwise it is known as a natural key. Natural keys have real world meaning. For example, a social security number may work, or an email address (in some situations), etc. Whichever type of key you choose is solely up to you and/or the company you may be working for. HELP ME! www.patreon.com/calebcurry Subscribe to my newsletter: eepurl.com/-8qtH Donate!: bit.ly/DonateCTVM2. ~~~~~~~~~~~~~~~Additional Links~~~~~~~~~~~~~~~ More content: CalebCurry.com Facebook: www.facebook.com/CalebTheVideoMaker Google+: plus.google.com/+CalebTheVideoMaker2 Twitter: Twitter.com/calebCurry Amazing Web Hosting - www.dreamhost.com/r.cgi?1487063 (The best web hosting for a cheap price!)

Leave a comment

Be the first to comment

Collections with this video
Email
Message
×
Embed video on a website or blog
Width
px
Height
px
×
Join Huzzaz
Start collecting all your favorite videos
×
Log in
Join Huzzaz

facebook login
×
Retrieve username and password
Name
Enter your email address to retrieve your username and password
(Check your spam folder if you don't find it in your inbox)

×