<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kyuhee Lee</title>
    <description>The latest articles on DEV Community by Kyuhee Lee (@kyuhee1011).</description>
    <link>https://dev.to/kyuhee1011</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1054478%2F7bd41261-129a-4cc5-8a86-6bac7051b158.png</url>
      <title>DEV Community: Kyuhee Lee</title>
      <link>https://dev.to/kyuhee1011</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kyuhee1011"/>
    <language>en</language>
    <item>
      <title>Authentication vs. Authorization-Identify Myself</title>
      <dc:creator>Kyuhee Lee</dc:creator>
      <pubDate>Tue, 03 Oct 2023 06:03:59 +0000</pubDate>
      <link>https://dev.to/kyuhee1011/authentication-vs-authorization-identify-myself-3ei8</link>
      <guid>https://dev.to/kyuhee1011/authentication-vs-authorization-identify-myself-3ei8</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lWwQs8FU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lb2knh5ybqsyigu0xiqi.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lWwQs8FU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lb2knh5ybqsyigu0xiqi.jpg" alt="Image description" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Authentication and authorization are essential applications in building secure web applications. this essential function is required when logging into personal online accounts for websites like Netflix, bank applications, and buildings that require secure access.&lt;/p&gt;

&lt;p&gt;To utilize the function described, as a user you must register an account and provide personal information. However, even though register an account, you cannot access all systems because permissions are granted differently as administrator, developer, or user with different levels of accessibility.&lt;/p&gt;

&lt;p&gt;Authentication is the process of verifying who you are when entering a secured application or building.&lt;/p&gt;

&lt;p&gt;For example, to log in to the Amazon website, you must enter your ID and password. This verifies that legitimate users actually exist in the database and which permissions are granted to the account.&lt;/p&gt;

&lt;p&gt;When logging in using password-based authentication, you must use a secret key which is a random key that protects the user's account from hacking.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask, make_response, jsonify, request, session
from flask_migrate import Migrate
from flask_restful import API, Resource

from models import db, Article, User

app = Flask(__name__)
app.secret_key = b'Y\xf1Xz\x00\xad|eQ\x80t \xca\x1a\x10K'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.json.compact = False

migrate = Migrate(app, db)

db.init_app(app)

api = Api(app)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Authorization refers to the process of allowing or denying users' access to an application. For example, all Amazon members are given minimum privileges, and if they purchase for prime access, they are given the privilege to use the Amazon Prime service and the privilege to use music and video applications.&lt;/p&gt;

&lt;p&gt;How to write the code.&lt;/p&gt;

&lt;p&gt;First, create data in models.py.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Video(db.Model, SerializerMixin):
     __tablename__ = 'videos'

     id = db.Column(db.Integer, primary_key=True)
     title = db.Column(db.String)
     author = db.Column(db.String)
     files = db.Column(db.String)
     is_member_only = db.Column(db.Boolean, default=False)


     user_id = db.Column(db.Integer, db.ForeignKey('users.id'))

     def __repr__(self):
         return f'Article {self.id} by {self.title}'

class User(db.Model):
     __tablename__ = "users"

     id = db.Column(db.Integer, primary_key=True)
     username = db.Column(db.String)
     password = db.Column(db.String)
     created_at = db.Column(db.DateTime, 
     server_default=db.func.now())


     videos = db.relationship('Video', backref='user')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code below ensures that the password is securely hashed before storing and provides authenticate method to check whether a given bcrypt matches the stored hash.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@hybrid_property
     def password_hash(self):
         raise Exception('Password hashes may not be viewed.')

     @password_hash.setter
     def password_hash(self, password):
         password_hash = bcrypt.generate_password_hash(
             password.encode('utf-8'))
         self._password_hash = password_hash.decode('utf-8')

     def authenticate(self, password):
         return bcrypt.check_password_hash(
             self._password_hash, password.encode('utf-8'))

     def __repr__(self):
         return f'User {self.username}, ID {self.id}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The before_request decorator allows you to run a function before the request. In other words, the function is defined with the .before_request() decorator to check whether any permissions are granted or not before every request is made.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@app.before_request
def is_member_only():
        if request.endpoint == 'member_video' and not session.get('user_id'):

#endpoint refers to member_video route/path

         return {'error':'Unauthorized'},401


class Signup(Resource):

     ddef post(self):
         json = request.get_json()
         user = User(
             username=json['username'],
         )
         user.password_hash=json['password']

         db.session.add(user)
         db.session.commit()
         session['user_id']= user.id

         return user.to_dict(), 201

class CheckSession(Resource):
     def get(self):

     #the 'get' method, will check if a session 'user_id' 
     #exists and matches values in session.get('user_id')

         if session.get('user_id'):
             user =User.query.filter(User.id==session.get('user_id')).first()

#because of filter and .first() will retrieve the first
#matching user. If a matching found will return 200
# if it's not then will return 204

             return user.to_dict(),200

         return {}, 204



class Login(Resource):
     def post(self):
json = request.get_json()

         username=json['username']
         user =User.query.filter(User.username==username).first()

         password=json['password']
         if user.authenticate(password):
             session['user_id']=user.id
             return user.to_dict(), 200
         return{'error': 'Invalid username or password'}, 401


class Logout(Resource):
     def delete(self):
         session['user_id'] = None

         return {}, 204

class MemberVideo(Resource):
def get(self):
        videos = [video.to_dict() for video in Video.query.all() if video.is_member_only == True]

         return videos, 200
#because of @app.before_request function above, the code now checking the MemberVideo (endpoint 'member_video) and and whether there is a valid user_id in the session.

api.add_resource(Signup, '/signup', endpoint='signup')
api.add_resource(CheckSession, '/check_session', endpoint='check_session')
api.add_resource(Login, '/login', endpoint='login')
api.add_resource(Logout, '/logout', endpoint='logout')
api.add_resource(MemberVideo, '/member_video', endpoint='member_video')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We learned the difference between authentication and authorization.&lt;br&gt;
Authentication is the process that confirms the user's identity, while authorization determines which level of access the account holder has. Thank you for your time reading my post and I hope this helps you understand the difference between authentication and authorization better.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Difference Between Primary Key and Foreign Key in SQL</title>
      <dc:creator>Kyuhee Lee</dc:creator>
      <pubDate>Tue, 08 Aug 2023 22:47:50 +0000</pubDate>
      <link>https://dev.to/kyuhee1011/llll-2e8m</link>
      <guid>https://dev.to/kyuhee1011/llll-2e8m</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DHk1OChJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rnq2yzd0b4joditicrpv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DHk1OChJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rnq2yzd0b4joditicrpv.jpg" alt="Image description" width="185" height="227"&gt;&lt;/a&gt; In the past, finding information took a lot of time because it was on paper. But today, when we order something or find information online, it doesn't take much time because the information is in a database, the process can be completed with a single click or a few keyword inputs. A database is a tool for collecting and organizing information. Also, it may collect orders, addresses, objects, or other items. As your company grows, using a database management system can greatly help your company grow.&lt;/p&gt;

&lt;p&gt;Before creating or using any kind of database, you need to know two key constraints to be useful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Primary Key&lt;/strong&gt;&lt;br&gt;
A primary key is a constraint that uniquely identifies each row in a table. Each table can have only one primary key. In a table, the primary key cannot be null and must have a unique value like the id number.&lt;/p&gt;

&lt;p&gt;For example, before entering code to create a table in Python, you want to think about how you are going to normalize the table so you can use a statement like the SQL Join clause. Let's say you want to create a table like the example below, two students take several classes and the professor also teaches several classes, you have to find which key going to be the primary key and the foreign key. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--npcRZ1HO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n0ha1d8z5x9auriiao9k.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--npcRZ1HO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n0ha1d8z5x9auriiao9k.jpg" alt="Image description" width="800" height="141"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Looking at the table above, we have the Student id, Student Name, Major, Course, Title, Instructor Name, Instructor Location, and Grade. The most unique key here is the &lt;strong&gt;student id&lt;/strong&gt; because other keys can have many of the same content, but the student id is the only key that identifies that student.&lt;/p&gt;

&lt;p&gt;Since the primary key cannot have nulls, you have to fill in the empty spaces by repeating the student number, name, and major.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Foreign Key&lt;/strong&gt;&lt;br&gt;
The foreign key is a column that references a primary key in another table. Also, it's a column or a group of columns in a relational database table that provides a link between data in other tables.&lt;/p&gt;

&lt;p&gt;Let's look at the table and see which key can be both a foreign key and a primary key in another table. The major cannot be a foreign key because it could be various courses or another course with other professors, so it's not a unique key.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;course_id&lt;/strong&gt; key can be both a foreign key and a primary key because it tells you what the course name is, who the professor is, and where the class gonna be. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--biBb1c3R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qtvxkwv6tfnji8wcfaxr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--biBb1c3R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qtvxkwv6tfnji8wcfaxr.jpg" alt="Image description" width="800" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, both tables are not related to each other yet because there is no relationship between the Course to Student table, only Student to Course. At this time, creating a join table will define a many-to-many relationship on both Student and Course tables. The &lt;strong&gt;many-to-many&lt;/strong&gt; relationship will contain both primary key as a foreign key and then using the relationship() function will define relationship on both tables.&lt;/p&gt;

&lt;p&gt;If you look at the table below, there are three tables, one has only student information, the other one has course information, and student_course has both student_id and course_id that define a relationship on both tables. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K3osEATt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ii89uimtkbnta4soeg9i.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K3osEATt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ii89uimtkbnta4soeg9i.jpg" alt="Image description" width="800" height="215"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that the table is organized using the Excel, all you have to do is enter the code in python.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# create join table
&lt;/span&gt;&lt;span class="n"&gt;student_course&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Table&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="s"&gt;"student_course
    Base.metadata, 
    Column ("&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="s"&gt;", Integer, primary_key=True),
    Column ("&lt;/span&gt;&lt;span class="n"&gt;students_id&lt;/span&gt;&lt;span class="s"&gt;", ForeignKey("&lt;/span&gt;&lt;span class="n"&gt;students&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="s"&gt;")),
    Column ("&lt;/span&gt;&lt;span class="n"&gt;course_id&lt;/span&gt;&lt;span class="s"&gt;", ForeignKey("&lt;/span&gt;&lt;span class="n"&gt;course&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="s"&gt;"))
)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="c1"&gt;#creating table 
&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Base&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;__tablename__&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'students'&lt;/span&gt;
    &lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Integer&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;primary_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="n"&gt;major&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;Column&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

&lt;span class="c1"&gt;# repr () returns a string similar to how print() works
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__repr__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"Student id:&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: "&lt;/span&gt;\
            &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"Student name:&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; "&lt;/span&gt;\
            &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"Major:&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;major&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;
    &lt;span class="n"&gt;courses&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;relationship&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Course "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;secondary&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;student_course&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="n"&gt;back_populates&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"courses"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Course&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Base&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;__tablename__&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'courses'&lt;/span&gt;
    &lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Integer&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;primary_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="n"&gt;instructor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;Column&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Column&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;


    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__repr__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"Course id:&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: "&lt;/span&gt;\
            &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"Course title:&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; "&lt;/span&gt;\
            &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"Instructor:&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;instructor&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;\
            &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"Location:&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;
     &lt;span class="n"&gt;students&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;relationship&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Student"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;secondary&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;student_course&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; 
     &lt;span class="n"&gt;back_populates&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"students"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;'__main__'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

    &lt;span class="n"&gt;engine&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;create_engine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'sqlite:///:memory:'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;Base&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create_all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;Session&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sessionmaker&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bind&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Session&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Student&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Course&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;students&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="n"&gt;Student&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;student_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"52146"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
              &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Kyuhee Lee"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;major&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"MTH"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;Student&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;student_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"75486"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
              &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Lilly Smith"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;major&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"ART"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;

&lt;span class="n"&gt;courses&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="n"&gt;Course&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;course_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"60205"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
              &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Algebra"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;instructor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"West"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"B222"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;Course&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;course_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"20105"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
              &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Art"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;instructor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Kim"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"B213"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;Course&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;course_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"320101"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
              &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Basic English"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;instructor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Porter"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"D319"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;Course&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;course_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"740102"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
              &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Science"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;instructor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Kim"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"B213"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;

&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bulk_save_objects&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;students&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;courses&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;commit&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
We discussed the importance of primary and foreign keys when creating tables in a database. You've learned which keys are primary keys and which are foreign keys. Identifying two keys is important when creating a table because it tells the relationship between the tables. Again, primary keys contain unique values, and foreign keys contain values referenced by the primary key and are keys that can be used as primary keys in other tables, thereby determining relationships between tables. I hope this helps you understand how to easily find primary and foreign keys.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Communication Between the Parent Component and the Child Component.</title>
      <dc:creator>Kyuhee Lee</dc:creator>
      <pubDate>Mon, 29 May 2023 09:39:11 +0000</pubDate>
      <link>https://dev.to/kyuhee1011/introducing-react-2lli</link>
      <guid>https://dev.to/kyuhee1011/introducing-react-2lli</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eZ8iZL8d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7bseg8dr0majrugc5z98.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eZ8iZL8d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7bseg8dr0majrugc5z98.jpg" alt="Image description" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;React uses components to pass data from a parent to a child or uses callback function to let the child component communicate with the parent component. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Props&lt;/strong&gt;&lt;br&gt;
Props is a type of properties and arguments that pass down data or value from the parent component to the child component. &lt;/p&gt;

&lt;p&gt;Lets look at an example below to find out which one is a parent and which one is a child first.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--thoCrEyH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dzfwwolmxsflbe2v0bbk.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--thoCrEyH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dzfwwolmxsflbe2v0bbk.jpg" alt="Image description" width="576" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Apps is the parent component and Header and Home are the Child component.   &lt;/p&gt;

&lt;p&gt;In this example, the Apps is passing the prop articleText and the commentText to each Child component with a value. The Home component will look like the example below to use the object (props) to access and render values&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yFmjYT8e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8telqu4vcl37680vwofm.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yFmjYT8e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8telqu4vcl37680vwofm.jpg" alt="Image description" width="438" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you console.log (props) then you will see the message "Phase2 React project by Lee" inside of the Home component.&lt;/p&gt;

&lt;p&gt;There is another way to pass the data calls Destructuring props.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Destructuring props.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Destructuring props helps developer to write easier, clean, and more readable code. It can assign a variable or can call more than one property.&lt;/p&gt;

&lt;p&gt;Here is an example without using destructuring props. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QnwB-6bO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9axbyr7ceh0k4b30u2ak.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QnwB-6bO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9axbyr7ceh0k4b30u2ak.jpg" alt="Image description" width="463" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since we called props an object so we have to pass props to every property like props.img, props.name, props.description, and props.texture.&lt;/p&gt;

&lt;p&gt;However, if we wrote a code with destructuring props, we can call these properties directly from the (props) object to write a simple readable code like the image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FJT8utda--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sd67sqd7grudkc2tjznn.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FJT8utda--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sd67sqd7grudkc2tjznn.jpg" alt="Image description" width="513" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;React can only pass props from parent to child, not between children or from child to parent. But what if we want to send a data opposite way? In this time, we can use a callback function in a child component to affect data in the parent component. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;useState&lt;/strong&gt;&lt;br&gt;
useState is a React Hook that allow us to use a callback function. It's a function passed as an argument to another function, allowing the parent-child can communicate each other. In React, most callback functions are used as event handlers to pass data between components to continue rendering and updating them.&lt;/p&gt;

&lt;p&gt;Before using useState in our component, we have to import useState from react like the image below on line 4. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c9THXe1j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7rknvkomp7b4w4lzfshj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c9THXe1j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7rknvkomp7b4w4lzfshj.jpg" alt="Image description" width="547" height="294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The example above, the handCountClick function is passing an onClickTask event handler to the Home (child) component. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--klg_hYeu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f155lcgpdowrvgljuxim.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--klg_hYeu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f155lcgpdowrvgljuxim.jpg" alt="Image description" width="620" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Home component will look like image above, we are now passing onClickTask function in child component to make changes in App (parent) component. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Now we learned how the parent and child components are communicating with each other. Props is passing down the data from top to bottom and if we want to do the reverse then we should use a callback function. Thank you for your time reading this post, I hope this helped you to understand how React components communicate each other. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding How the Website Finds the Item that You WANT!</title>
      <dc:creator>Kyuhee Lee</dc:creator>
      <pubDate>Mon, 24 Apr 2023 08:24:52 +0000</pubDate>
      <link>https://dev.to/kyuhee1011/understanding-how-the-website-finds-the-item-that-you-want-1oi7</link>
      <guid>https://dev.to/kyuhee1011/understanding-how-the-website-finds-the-item-that-you-want-1oi7</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MtGoLPXX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sgijtiknj9fbysolg37b.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MtGoLPXX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sgijtiknj9fbysolg37b.jpg" alt="Image description" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When I was working for eCommerce Companies, I had a question about how I should design a website that would attract more customers’ attention and make ordering easier, so I became interested in website design and studied HTML and CSS. While I was studying those two codes I was wondering how the site finds and open the pages that I was looking for, so I decided to study more. Thankfully, Amazon provided the way and I was thankfully accepted into the Flatiron School.&lt;/p&gt;

&lt;p&gt;During the course, I noticed that the HTML and CSS I learned were simple design coding that colored sketches, whereas I thought JavaScript is complicated because it is the programming that executes it. In the middle of learning a lot of things, I was getting answers little by little to what I was curious about before.&lt;/p&gt;

&lt;p&gt;I was curious when I search for the name of an item on Amazon.com, how the site brings up the page I want among other pages. However, now I understand that the system uses filter() or find() to call pages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;filter()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For example, if you look at the code below, you have an array and function. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VF7dT92q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ovrnoqz8ygs4l3z24b7t.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VF7dT92q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ovrnoqz8ygs4l3z24b7t.jpg" alt="Image description" width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We know that we can iterate through the array to find the words contains from the search and give a result for the word that contains it, like how example finds out apple and grapes by searching only "ap".&lt;/p&gt;

&lt;p&gt;Let's look at another example.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6Icnpo5A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mg23kfhpcj08zxfnve7f.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6Icnpo5A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mg23kfhpcj08zxfnve7f.jpg" alt="Image description" width="507" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you search for "Lip", it will look for the name that contains the word "Lip" and the result will give all four items except ColorStay Suede Ink. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;find ()&lt;/strong&gt;&lt;br&gt;
Find is very similar to filter(), however, find() will return the first element that passed the provided function test. &lt;/p&gt;

&lt;p&gt;Let's say we have the same array as above. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f5L502sX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xxkxk0v90o5u3nu428tq.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f5L502sX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xxkxk0v90o5u3nu428tq.jpg" alt="Image description" width="507" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Function code and the result will be&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DyMwGQ2l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/310k5k6rxuxk8e6dubmc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DyMwGQ2l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/310k5k6rxuxk8e6dubmc.jpg" alt="Image description" width="628" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The result gave the Couture Lipstick Satin instead of Ultra Rouge Lipstick because Couture Lipstick Satin is the first element and before the Ultra Rouge Lipstick.&lt;/p&gt;

&lt;p&gt;So whenever we search for a word on amazon.com or Google, that's how the website finds the product or pages to bring it to us. &lt;/p&gt;

&lt;p&gt;Thank you for time reading this post, I hope this helped you to understand how the filter() and find() work. &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
