Activity 17: Data Structure Again

·

10 min read

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

IDNameCategoryPriceStockSupplier Email
1LaptopElectronics75050supplier1@gmail.com
2Desk ChairFurniture100200supplier2@gmail.com
3SmartwatchElectronics200150supplier3@gmail.com
4NotebookStationery5500supplier4@gmail.com
5Running ShoesApparel80100supplier5@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

IDNameDepartmentAgeEmail
1John DoeSales30john.doe@company.com
2Jane SmithHuman Resources25jane.smith@company.com
3Mark JohnsonIT40mark.johnson@company.com
4Lisa WongMarketing28lisa.wong@company.com
5Paul McDonaldFinance35paul.mcdonald@company.com

Breakdown of Columns

  1. ID: A unique identifier for each employee.

    • Example: 1, 2, 3, etc.
  2. Name: The name of the employee.

    • Example: John Doe, Jane Smith, etc.
  3. Department: The department where the employee works.

    • Example: Sales, Human Resources, etc.
  4. Age: The age of the employee.

    • Example: 30 (for John Doe), 25 (for Jane Smith).
  5. Email: The email address of the employee.

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.

  1. Books Table

Books Table Structure

Column NameData TypeDescription
IDINTUnique identifier for each book
TitleVARCHAR(255)Title of the book
AuthorVARCHAR(255)Author of the book
GenreVARCHAR(255)Genre/category of the book
Published YearINTYear the book was published
ISBNVARCHAR(13)International Standard Book Number
StockINTNumber of copies available in stock
PriceDECIMAL(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 NameData TypeDescription
IDINTUnique identifier for each university
NameVARCHAR(255)Name of the university
LocationVARCHAR(255)City where the university is located
Established YearINTYear the university was established
TypeVARCHAR(50)Type of university (e.g., Public or Private)
WebsiteVARCHAR(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 NameData TypeDescription
IDIntegerUnique identifier for each restaurant (Primary Key).
NameStringThe name of the restaurant.
LocationStringThe geographical area or city where the restaurant is located.
Cuisine TypeStringThe type of cuisine offered (e.g., Italian, Chinese, etc.).
Established YearIntegerThe year the restaurant was established.
Website or ContactStringThe 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).