Simple definitions
“Structured data: is organized, and follows a specific format, such as tables in a database.
Examples of structured data include customer information like names, addresses, and phone
numbers.
Unstructured data: does not have a predefined format and is more flexible. It can include things
like text documents, images, videos, social media posts, or emails. An example of unstructured
data in a database could be the comments section of an online shopping platform, where users
can write their thoughts about a product.
Primary Key: A primary key is a unique identifier for each record in a table. It ensures that each
record is uniquely identifiable. For example, in a customer table, the primary key could be a
"customer_id" column, which assigns a unique identifier to each customer.
Secondary Key: A secondary key is an optional field that can be used to uniquely identify records
in a table, but it is not the primary key. It helps in faster search and retrieval of data. For
instance, in a customer table, a "phone_number" column could be a secondary key, allowing
quick searches based on a customer's phone number.
Foreign Key: A foreign key establishes a relationship between two tables. It refers to the primary
key of another table, creating a link between them. For example, in a customer_orders table, a
"customer_id" column could be a foreign key that references the primary key of the customer
table. This relationship ensures that each order is associated with a specific customer.”
Extracted from "Chat AI"
"To understand what is relational database, what is primary key, what is secondary key, and what is
foreign key, you can use the following database tables:
Students table:
Column Data type Description
student_id 202100628 Primary key
first_name Yorgo Student's first name
last_name Azar Student's last name
email Yorgo.azar@lau.edu Student's email address
Courses table:
Column Data type Description
course_id ITM211 Primary key
course_name Information Technology Mgt Course name
instructor Caline Karam Course instructor
Student Courses table:
Column Data type Description
student_id 202100628 Foreign key to Students table
course_id ITM211 Foreign key to Courses table
Relational database
A relational database is a type of database that organizes data into tables of related data. Each table has
a set of columns, and each row in a table represents a single record. The tables are related to each other
through foreign keys.
Primary key
A primary key is a column or group of columns in a table that uniquely identifies each row in the table.
Secondary key
A secondary key is a column or group of columns in a table that can be used to uniquely identify rows in
the table, but is not the primary key.
Foreign key
A foreign key is a column or group of columns in a table that references the primary key of another table.
Foreign keys are used to create relationships between tables.
Example
The Students table has a primary key of student_id. The Student_Courses table has two foreign keys:
student_id and course_id. The student_id foreign key references the primary key of the Students table.
The course_id foreign key references the primary key of the Courses table.
The Student_Courses table allows us to track which students are enrolled in which courses. For example,
we can query the Student_Courses table to find all of the students who are enrolled in a particular
course, or all of the courses that a particular student is enrolled in.
What about relational databases?
Use the following database tables as an example:
1- The Students table stores information about students, such as their first name, last name, and
email address. The Courses table stores information about courses, such as the course name and
instructor.
2- The Student_Courses table is used to track which students are enrolled in which courses.
3- How to use foreign keys to create relationships between tables. For example, how to query the
Student_Courses table to find all of the students who are enrolled in a particular course, or all of
the courses that a particular student is enrolled in.
4- Think of other examples of relational databases. For example, you could discuss a database for
tracking employees and departments, or a database for tracking products and orders.
By using real-world examples, you can understand the concepts of relational databases, primary keys,
secondary keys, and foreign keys."
Extracted from "BARD"