Activity 17: Data Structure Again
1. Product Table
1. List
A List is a collection of items that are ordered and can be accessed by their index. In the context of the Product Table, a List might represent a collection of product names or prices.
Example:
Product Table Structure
ID | Name | Category | Price | Stock | Supplier Email |
1 | Laptop | Electronics | 750 | 50 | supplier1@gmail.com |
2 | Desk Chair | Furniture | 100 | 200 | supplier2@gmail.com |
3 | Smartwatch | Electronics | 200 | 150 | supplier3@gmail.com |
4 | Notebook | Stationery | 5 | 500 | supplier4@gmail.com |
5 | Running Shoes | Apparel | 80 | 100 | supplier5@gmail.com |
2. Object
An Object represents a single entity with various properties (or attributes). Each product in the Product Table can be considered an Object that contains information about that specific product.
Example:
jsonCopy code{
"ID": 1,
"Name": "Laptop",
"Category": "Electronics",
"Price": 750,
"Stock": 50,
"Supplier Email": "supplier1@gmail.com"
}
3. List of Objects
A List of Objects is a collection of Objects. In this case, it would be an array of product Objects, where each Object contains details about a different product.
Example:
jsonCopy code[ { "ID": 1, "Name": "Laptop", "Category": "Electronics", "Price": 750, "Stock": 50, "Supplier Email": "supplier1@gmail.com" }, { "ID": 2, "Name": "Desk Chair", "Category": "Furniture", "Price": 100, "Stock": 200, "Supplier Email": "supplier2@gmail.com" }, { "ID": 3, "Name": "Smartwatch", "Category": "Electronics", "Price": 200, "Stock": 150, "Supplier Email": "supplier3@gmail.com" }, { "ID": 4, "Name": "Notebook", "Category": "Stationery", "Price": 5, "Stock": 500, "Supplier Email": "supplier4@gmail.com" }, { "ID": 5, "Name": "Running Shoes", "Category": "Apparel", "Price": 80, "Stock": 100, "Supplier Email": "supplier5@gmail.com" }]
2. Employee Table
Employee Table Structure
ID | Name | Department | Age | |
1 | John Doe | Sales | 30 | john.doe@company.com |
2 | Jane Smith | Human Resources | 25 | jane.smith@company.com |
3 | Mark Johnson | IT | 40 | mark.johnson@company.com |
4 | Lisa Wong | Marketing | 28 | lisa.wong@company.com |
5 | Paul McDonald | Finance | 35 | paul.mcdonald@company.com |
Breakdown of Columns
ID: A unique identifier for each employee.
- Example: 1, 2, 3, etc.
Name: The name of the employee.
- Example: John Doe, Jane Smith, etc.
Department: The department where the employee works.
- Example: Sales, Human Resources, etc.
Age: The age of the employee.
- Example: 30 (for John Doe), 25 (for Jane Smith).
Email: The email address of the employee.
- Example: john.doe@company.com, jane.smith@company.com.
1. List
A List is an ordered collection of items, typically of the same type. In the context of the Employee Table, a List could represent a single attribute of all employees.
Example of a List: Employee Names
plaintextCopy code["John Doe", "Jane Smith", "Mark Johnson", "Lisa Wong", "Paul McDonald"]
Characteristics:
The order matters.
It can contain duplicate values (if applicable).
The items are accessible by their index.
2. Object
An Object is a collection of key-value pairs, representing a single entity with various attributes. For the Employee Table, each employee can be considered an object.
Example of an Object: John Doe's Data
jsonCopy code{
"ID": 1,
"Name": "John Doe",
"Department": "Sales",
"Age": 30,
"Email": "john.doe@company.com"
}
Characteristics:
Each key (attribute) is associated with a value.
Objects can contain multiple types of data (numbers, strings, etc.).
They represent a single instance of an entity (in this case, an employee).
3. List of Objects
A List of Objects is a collection of multiple objects, each representing a distinct entity. In this case, it represents all the employees in the Employee Table.
Example of a List of Objects: Employee Data
jsonCopy code[ { "ID": 1, "Name": "John Doe", "Department": "Sales", "Age": 30, "Email": "john.doe@company.com" }, { "ID": 2, "Name": "Jane Smith", "Department": "Human Resources", "Age": 25, "Email": "jane.smith@company.com" }, { "ID": 3, "Name": "Mark Johnson", "Department": "IT", "Age": 40, "Email": "mark.johnson@company.com" }, { "ID": 4, "Name": "Lisa Wong", "Department": "Marketing", "Age": 28, "Email": "lisa.wong@company.com" }, { "ID": 5, "Name": "Paul McDonald", "Department": "Finance", "Age": 35, "Email": "paul.mcdonald@company.com" }]
Characteristics:
The list contains multiple objects, each representing an employee.
Each object can have different attributes but follows a similar structure.
Useful for managing collections of related data.
Books Table
Books Table Structure
Column Name | Data Type | Description |
ID | INT | Unique identifier for each book |
Title | VARCHAR(255) | Title of the book |
Author | VARCHAR(255) | Author of the book |
Genre | VARCHAR(255) | Genre/category of the book |
Published Year | INT | Year the book was published |
ISBN | VARCHAR(13) | International Standard Book Number |
Stock | INT | Number of copies available in stock |
Price | DECIMAL(10,2) | Price of the book |
1. List
A List can represent a single attribute from all the books, such as the titles of the books.
Example of a List: Book Titles
plaintextCopy code["The Great Gatsby", "To Kill a Mockingbird", "1984", "The Catcher in the Rye", "A Brief History of Time"]
Characteristics:
An ordered collection of titles.
Accessed by index.
Simple and straightforward.
2. Object
An Object can represent the details of a single book, containing all its attributes.
Example of an Object: Details of "The Great Gatsby"
jsonCopy code{
"ID": 1,
"Title": "The Great Gatsby",
"Author": "F. Scott Fitzgerald",
"Genre": "Fiction",
"Published Year": 1925,
"ISBN": "978-0743273565",
"Stock": 20,
"Price": 15.99
}
Characteristics:
Contains key-value pairs that describe one book.
Each key represents a specific attribute (e.g., Title, Author).
Provides a structured way to access a book's details.
3. List of Objects
A List of Objects represents multiple books, each as an object containing all their respective attributes.
Example of a List of Objects: Books Data
jsonCopy code[ { "ID": 1, "Title": "The Great Gatsby", "Author": "F. Scott Fitzgerald", "Genre": "Fiction", "Published Year": 1925, "ISBN": "978-0743273565", "Stock": 20, "Price": 15.99 }, { "ID": 2, "Title": "To Kill a Mockingbird", "Author": "Harper Lee", "Genre": "Fiction", "Published Year": 1960, "ISBN": "978-0060935467", "Stock": 35, "Price": 10.99 }, { "ID": 3, "Title": "1984", "Author": "George Orwell", "Genre": "Dystopian", "Published Year": 1949, "ISBN": "978-0451524935", "Stock": 40, "Price": 9.99 }, { "ID": 4, "Title": "The Catcher in the Rye", "Author": "J.D. Salinger", "Genre": "Fiction", "Published Year": 1951, "ISBN": "978-0316769488", "Stock": 25, "Price": 8.99 }, { "ID": 5, "Title": "A Brief History of Time", "Author": "Stephen Hawking", "Genre": "Non-fiction", "Published Year": 1988, "ISBN": "978-0553380163", "Stock": 10, "Price": 18.99 }]
Characteristics:
A collection of multiple objects, each representing a book.
Each book object contains various attributes structured as key-value pairs.
Allows easy management and access to a collection of books.
University Table
1. List
A List is a collection of items where each item is typically of the same type. In programming, lists are often used to store multiple values in a single variable.
Example of a List based on the University Table:
plaintextCopy code["University of the Philippines", "Ateneo de Manila University", "De La Salle University", "University of Santo Tomas", "Polytechnic University of the Philippines"]
- Description: This list contains the names of the universities. It's a simple one-dimensional structure that holds multiple values.
University Table Structure
Column Name | Data Type | Description |
ID | INT | Unique identifier for each university |
Name | VARCHAR(255) | Name of the university |
Location | VARCHAR(255) | City where the university is located |
Established Year | INT | Year the university was established |
Type | VARCHAR(50) | Type of university (e.g., Public or Private) |
Website | VARCHAR(255) | Official website of the university |
2. Object
An Object is a data structure that can contain multiple properties and values. Each property is defined by a key-value pair, and objects can represent complex data more effectively.
Example of an Object based on the University Table:
jsonCopy code{
"ID": 1,
"Name": "University of the Philippines",
"Location": "Quezon City",
"Established Year": 1908,
"Type": "Public",
"Website": "www.up.edu.ph"
}
- Description: This object represents a single university with various properties like ID, Name, Location, etc. Each property provides specific information about that university.
3. List of Objects
A List of Objects is essentially a list where each item is an object. This allows for a structured representation of multiple entities, each with its own set of properties.
Example of a List of Objects based on the University Table:
jsonCopy code[ { "ID": 1, "Name": "University of the Philippines", "Location": "Quezon City", "Established Year": 1908, "Type": "Public", "Website": "www.up.edu.ph" }, { "ID": 2, "Name": "Ateneo de Manila University", "Location": "Quezon City", "Established Year": 1859, "Type": "Private", "Website": "www.ateneo.edu" }, { "ID": 3, "Name": "De La Salle University", "Location": "Manila", "Established Year": 1911, "Type": "Private", "Website": "www.dlsu.edu.ph" }, { "ID": 4, "Name": "University of Santo Tomas", "Location": "Manila", "Established Year": 1611, "Type": "Private", "Website": "www.ust.edu.ph" }, { "ID": 5, "Name": "Polytechnic University of the Philippines", "Location": "Manila", "Established Year": 1904, "Type": "Public", "Website": "www.pup.edu.ph" }]
- Description: This structure contains a list of university objects. Each object represents a university with its associated properties, allowing for easy access and management of university data.
Summary
List: A simple collection of items (e.g., university names).
Object: A complex structure representing a single entity with multiple properties (e.g., details of one university).
List of Objects: A collection of objects, where each object represents an individual entity with its own properties (e.g., details of multiple universities).
Restaurant Table
Restaurant Table Structure
Column Name | Data Type | Description |
ID | Integer | Unique identifier for each restaurant (Primary Key). |
Name | String | The name of the restaurant. |
Location | String | The geographical area or city where the restaurant is located. |
Cuisine Type | String | The type of cuisine offered (e.g., Italian, Chinese, etc.). |
Established Year | Integer | The year the restaurant was established. |
Website or Contact | String | The website URL or contact information for the restaurant. |
1. List
A List is a simple collection of items where each item is typically of the same type. It is often used to store multiple values in a single variable.
Example of a List based on the Restaurant Table:
plaintextCopy code["Vikings Luxury Buffet", "Antonio's Restaurant", "Mesa Filipino Moderne", "Manam Comfort Filipino", "Ramen Nagi"]
- Description: This list contains the names of the restaurants. It's a straightforward one-dimensional structure that holds multiple values.
2. Object
An Object is a data structure that can contain multiple properties and values. Each property is defined by a key-value pair, allowing for a structured representation of an entity.
Example of an Object based on the Restaurant Table:
jsonCopy code{
"ID": 1,
"Name": "Vikings Luxury Buffet",
"Location": "Pasay City",
"Cuisine Type": "Buffet",
"Established Year": 2011,
"Website or Contact": "www.vikings.ph"
}
- Description: This object represents a single restaurant with various properties like ID, Name, Location, etc. Each property provides specific information about that restaurant.
3. List of Objects
A List of Objects is a list where each item is an object. This structure allows for a detailed representation of multiple entities, each with its own set of properties.
Example of a List of Objects based on the Restaurant Table:
jsonCopy code[ { "ID": 1, "Name": "Vikings Luxury Buffet", "Location": "Pasay City", "Cuisine Type": "Buffet", "Established Year": 2011, "Website or Contact": "www.vikings.ph" }, { "ID": 2, "Name": "Antonio's Restaurant", "Location": "Tagaytay", "Cuisine Type": "Fine Dining", "Established Year": 2002, "Website or Contact": "www.antoniosrestaurant.ph" }, { "ID": 3, "Name": "Mesa Filipino Moderne", "Location": "Makati City", "Cuisine Type": "Filipino", "Established Year": 2009, "Website or Contact": "www.mesa.ph" }, { "ID": 4, "Name": "Manam Comfort Filipino", "Location": "Quezon City", "Cuisine Type": "Filipino", "Established Year": 2013, "Website or Contact": "www.manam.ph" }, { "ID": 5, "Name": "Ramen Nagi", "Location": "Various Locations", "Cuisine Type": "Japanese", "Established Year": 2013, "Website or Contact": "www.ramennagi.com.ph" }]
- Description: This structure contains a list of restaurant objects. Each object represents a restaurant with its associated properties, allowing for easy access and management of restaurant data.
Summary
List: A simple collection of items (e.g., restaurant names).
Object: A complex structure representing a single entity with multiple properties (e.g., details of one restaurant).
List of Objects: A collection of objects, where each object represents an individual entity with its own properties (e.g., details of multiple restaurants).