# Activity 17: Data Structure Again

List is an ordered data structure that is used to store different or same elements in a **sequential manner**.

The list is similar to array in data structure but in the array, we can store only the elements which are of **same data-type** whereas in the list in the data structure, with some of the programming languages like **python and javascript** we can store elements with different data types also.

1. ### 1\. List (Array)
    
    #### Definition
    
    A **List** (or **Array**) is an ordered collection of items. It can hold multiple values, which can be of different types.
    
    A **List**, known as an **Array** in TypeScript, is an ordered collection of elements that can hold multiple values of different types. For instance, you can have an array that contains strings, numbers, or booleans. Elements in an array maintain their order based on their index, starting from 0. The size of the array can change dynamically, allowing you to add or remove elements as needed. You can access the elements using their numerical index.
    
    #### Characteristics
    
    * **Ordered**: Elements maintain their order based on their index.
        
    * **Dynamic Size**: Arrays can grow or shrink dynamically.
        
    * **Heterogeneous**: Can contain elements of different types (strings, numbers, objects, etc.).
        
    * **Accessed by Index**: Each element can be accessed using its index from zero. 
        
        ```python
        student_name_list = ["Juan Carlos", "Jose Rizal", "Juan Luna", "Andres Bonifacio", "Justin Bieber", "Michael Jordan", "Andrew Jordan", "Jessa Boe", "Ted Talk"]
        ```
        
    

### 2\. Object

#### Definition

An **Object** is a collection of key-value pairs. Keys are typically strings (or Symbols), and values can be any type (including other objects or arrays).

An **Object** in TypeScript is a collection of key-value pairs where the keys are strings (or Symbols) and the values can be of any type, including other objects, arrays, or functions. Unlike arrays, the order of key-value pairs in an object is not guaranteed. Objects are dynamic, meaning you can add, modify, or delete properties at runtime. TypeScript allows you to define the structure of objects using interfaces or types, which provides better type safety and clarity.

#### Characteristics

* **Unordered**: The order of key-value pairs is not guaranteed.
    
* **Dynamic Properties**: You can add, modify, or delete properties at runtime.
    
* **Heterogeneous Values**: Can hold values of different types.
    
    ```javascript
    student_object1 = {
        "name": "Juan Carlos",
        "section": "BSIT-4B",
        "id": 1,
        "email": "juan@gmail.com",
        "age": 22
    }
    ```
    
* ### 3\. List of Objects
    
    #### Definition
    
    A **List of Objects** is an array where each element is an object. This structure combines the features of arrays and objects.
    
* A **List of Objects** is an array where each element is an object. This structure is useful for grouping multiple objects together in a single collection. Each object within the list can have its own properties, and the list maintains the order of these objects. In TypeScript, you can define an interface for the objects in the list to ensure that each object adheres to a specific structure, making it easier to work with collections of similar entities, such as users or products.
    
    #### Characteristics
    
    * **Ordered Collection of Objects**: The array maintains the order of the objects.
        
    * **Each Object Can Have Different Properties**: Objects within the list can have different keys and values.
        
    * **Useful for Grouping Related Data**: Commonly used to represent a collection of similar entities (e.g., users, products).
        

```javascript
students = [
    {
        "name": "Juan Carlos",
        "section": "BSIT-4B",
        "id": 1,
        "email": "juan@gmail.com",
        "age": 22
    }
```

### Concept of List, Obeject, and List of Objects

1. ### Product Table
    

| **ID** | **Name** | **Category** | **Price** | **Stock** | **Supplier Email** |
| --- | --- | --- | --- | --- | --- |
| 1 | Laptop | Electronics | 750 | 50 | [**supplier1@gmail.com**](mailto:supplier1@gmail.com) |
| 2 | Desk Chair | Furniture | 100 | 200 | [**supplier2@gmail.com**](mailto:supplier2@gmail.com) |
| 3 | Smartwatch | Electronics | 200 | 150 | [**supplier3@gmail.com**](mailto:supplier3@gmail.com) |
| 4 | Notebook | Stationery | 5 | 500 | [**supplier4@gmail.com**](mailto:supplier4@gmail.com) |
| 5 | Running Shoes | Apparel | 80 | 100 | [**supplier5@gmail.com**](mailto:supplier5@gmail.com) |

* ### LIST:
    
    In this code snippet, I have several arrays representing a product inventory. The `product_id_list` contains unique IDs (1 to 5), while the `product_name_list` includes names like "laptop," "Desk Chair," and "Smartwatch." The `product_category_list` specifies categories, allowing duplicates such as "Electronics" for both the laptop and smartwatch. The `product_price_list` details prices, with the laptop at $750 and the notebook at $5. The `product_stock_list` shows available quantities, like 50 laptops in stock. Lastly, the `product_supplier_email_list` provides supplier emails. Using an array of objects would improve organization and readability.
    

```javascript
product_id_list = [1, 2, 3, 4, 5]
product_name_list = ["Laptop", "Desk Chair", "Smartwatch", "Notebook", "Running Shoes"]
product_category_list = ["Electronics", "Furniture", "Electronics", "Stationery", "Apparel"]
product_price_list = [750, 100, 200, 5, 80]
product_stock_list = [50, 200, 150, 500, 100]
product_supplier_email_list = ["supplier1@gmail.com", "supplier2@gmail.com", "supplier3@gmail.com", "supplier4@gmail.com", "supplier5@gmail.com"]
```

* ### **OBJECTS:**
    
* To use the product objects defined in the code, I can access their properties directly by referencing the object names. For instance, if I want to get the name of the first product, I can simply use [`product1.name`](http://product1.name), which will return "laptop." Similarly, if I need the price of `product3`, I can access it with `product3.price`, and it will give me 200.
    
    If I want to update a property, like changing the stock of `product2`, I can assign a new value using `product2.stock = 180`. To log the supplier email for `product4`, I can use `console.log(product4.supplierEmail)`, and it will display "[supplier4@gmail.com](mailto:supplier4@gmail.com)." This way, I can easily manage and interact with each product's information in my code.
    
    ```javascript
    product1 = {
      id: 1,
      name: "laptop",
      category: "Electronics",
      price: 750,
      stock: 50,
      supplierEmail: "supplier1@gmail.com",
    };
    
    product2 = {
      id: 2,
      name: "Desk Chair",
      category: "Furniture",
      price: 100,
      stock: 200,
      supplierEmail: "supplier2@gmail.com",
    };
    
    product3 = {
      id: 3,
      name: "Smartwatch",
      category: "Electronics",
      price: 200,
      stock: 150,
      supplierEmail: "supplier3@gmail.com",
    };
    
     product4 = {
      id: 4,
      name: "Notebook",
      category: "Stationery",
      price: 5,
      stock: 500,
      supplierEmail: "supplier4@gmail.com",
    };
    
    product5 = {
      id: 5,
      name: "Running Shoes",
      category: "Apparel",
      price: 80,
      stock: 100,
      supplierEmail: "supplier5@gmail.com",
    };
    ```
    
    ### **LIST OF OBJECT:**
    
    * In this code, I've created an array called `products`, which contains five objects, each representing a different product with specific attributes like `id`, `name`, `category`, `price`, `stock`, and `supplierEmail`.
        
        To access information about these products, I can use their index in the array. For example, `products[0].name` retrieves the name of the first product, which is "laptop," and `products[2].price` gets the price of the third product, which is 200. This structure allows me to easily manage and retrieve product details whenever I need them.
        
    
    * ```javascript
         products = [
          {
            id: 1,
            name: "laptop",
            category: "Electronics",
            price: 750,
            stock: 50,
            supplierEmail: "supplier1@gmail.com",
          },
          {
            id: 2,
            name: "Desk Chair",
            category: "Furniture",
            price: 100,
            stock: 200,
            supplierEmail: "supplier2@gmail.com",
          },
          {
            id: 3,
            name: "Smartwatch",
            category: "Electronics",
            price: 200,
            stock: 150,
            supplierEmail: "supplier3@gmail.com",
          },
          {
            id: 4,
            name: "Notebook",
            category: "Stationery",
            price: 5,
            stock: 500,
            supplierEmail: "supplier4@gmail.com",
          },
          {
            id: 5,
            name: "Running Shoes",
            category: "Apparel",
            price: 80,
            stock: 100,
            supplierEmail: "supplier5@gmail.com",
          },
        ];
        ```
        
    
* # **2\. Employee Table**
    
    | **ID** | **Name** | **Department** | **Age** | **Email** |
    | --- | --- | --- | --- | --- |
    | 1 | John Doe | Sales | 30 | [**john.doe@company.com**](mailto:john.doe@company.com) |
    | 2 | Jane Smith | Human Resources | 25 | [**jane.smith@company.com**](mailto:jane.smith@company.com) |
    | 3 | Mark Johnson | IT | 40 | [**mark.johnson@company.com**](mailto:mark.johnson@company.com) |
    | 4 | Lisa Wong | Marketing | 28 | [**lisa.wong@company.com**](mailto:lisa.wong@company.com) |
    | 5 | Paul McDonald | Finance | 35 | [**paul.mcdonald@company.com**](mailto:paul.mcdonald@company.com) |
    
* ### **LIST:**  
    
    ```javascript
    employee_id_list = [1, 2, 3, 4, 5];
    employee_name_list = ["John Doe", "Jane Smith", "Mark Johnson", "Lisa Wong", "Paul McDonald"];
    employee_department_list = ["Sales", "Human Resources", "IT", "Marketing", "Finance"];
    employee_ages_list = [30, 25, 40, 28, 35];
    employee_emails_list= [
      "john.doe@company.com",
      "jane.smith@company.com",
      "mark.johnson@company.com",
      "lisa.wong@company.com",
      "paul.mcdonald@company.com"
    ];
    ```
    

### OBJECT:

* ```javascript
    employee1 = {
      id: 1,
      name: "John Doe",
      department: "Sales",
      age: 30,
      email: "john.doe@company.com"
    };
    
    employee2 = {
      id: 2,
      name: "Jane Smith",
      department: "Human Resources",
      age: 25,
      email: "jane.smith@company.com"
    };
    
    employee3 = {
      id: 3,
      name: "Mark Johnson",
      department: "IT",
      age: 40,
      email: "mark.johnson@company.com"
    };
    
    employee4 = {
      id: 4,
      name: "Lisa Wong",
      department: "Marketing",
      age: 28,
      email: "lisa.wong@company.com"
    };
    
    employee5 = {
      id: 5,
      name: "Paul McDonald",
      department: "Finance",
      age: 35,
      email: "paul.mcdonald@company.com"
    };
    ```
    

### LIST OF OBJECT:

```javascript
employees = [
  { 
    id: 1, 
    name: "John Doe", 
    department: "Sales", 
    age: 30, 
    email: "[john.doe@company.com](mailto:john.doe@company.com)" 
  },
  { 
    id: 2, 
    name: "Jane Smith", 
    department: "Human Resources", 
    age: 25, 
    email: "[jane.smith@company.com](mailto:jane.smith@company.com)" 
  },
  { 
    id: 3, 
    name: "Mark Johnson", 
    department: "IT", 
    age: 40, 
    email: "[mark.johnson@company.com](mailto:mark.johnson@company.com)" 
  },
  { 
    id: 4, 
    name: "Lisa Wong", 
    department: "Marketing", 
    age: 28, 
    email: "[lisa.wong@company.com](mailto:lisa.wong@company.com)" 
  },
  { 
    id: 5, 
    name: "Paul McDonald", 
    department: "Finance", 
    age: 35, 
    email: "[paul.mcdonald@company.com](mailto:paul.mcdonald@company.com)" 
  }
];
```

3. # **Books Table**
    

| **ID** | **Title** | **Author** | **Genre** | **Published Year** | **ISBN** | **Stock** | **Price** |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 1 | The Great Gatsby | F. Scott Fitzgerald | Fiction | 1925 | 978-0743273565 | 20 | 15.99 |
| 2 | To Kill a Mockingbird | Harper Lee | Fiction | 1960 | 978-0060935467 | 35 | 10.99 |
| 3 | 1984 | George Orwell | Dystopian | 1949 | 978-0451524935 | 40 | 9.99 |
| 4 | The Catcher in the Rye | J.D. Salinger | Fiction | 1951 | 978-0316769488 | 25 | 8.99 |
| 5 | A Brief History of Time | Stephen Hawking | Non-fiction | 1988 | 978-0553380163 | 10 | 18.99 |

###   
**LIST:**

```javascript
book_id_list = [1, 2, 3, 4, 5];
book_title_list = ["The Great Gatsby", "To Kill a Mockingbird", "1984", "The Catcher in the Rye", "A Brief History of Time"];
book_author_list = ["F. Scott Fitzgerald", "Harper Lee", "George Orwell", "J.D. Salinger", "Stephen Hawking"];
book_genre_list = ["Fiction", "Fiction", "Dystopian", "Fiction", "Non-fiction"];
book_published_year_list = [1925, 1960, 1949, 1951, 1988];
book_isbn_list = ["978-0743273565", "978-0060935467", "978-0451524935", "978-0316769488", "978-0553380163"];
book_stock_list = [20, 35, 40, 25, 10];
book_price_list = [15.99, 10.99, 9.99, 8.99, 18.99];
```

### OBJECT:

```javascript
book1 = {
  id: 1,
  title: "The Great Gatsby",
  author: "F. Scott Fitzgerald",
  genre: "Fiction",
  publishedYear: 1925,
  isbn: "978-0743273565",
  stock: 20,
  price: 15.99
};

book2 = {
  id: 2,
  title: "To Kill a Mockingbird",
  author: "Harper Lee",
  genre: "Fiction",
  publishedYear: 1960,
  isbn: "978-0060935467",
  stock: 35,
  price: 10.99
};

book3 = {
  id: 3,
  title: "1984",
  author: "George Orwell",
  genre: "Dystopian",
  publishedYear: 1949,
  isbn: "978-0451524935",
  stock: 40,
  price: 9.99
};

book4 = {
  id: 4,
  title: "The Catcher in the Rye",
  author: "J.D. Salinger",
  genre: "Fiction",
  publishedYear: 1951,
  isbn: "978-0316769488",
  stock: 25,
  price: 8.99
};

book5 = {
  id: 5,
  title: "A Brief History of Time",
  author: "Stephen Hawking",
  genre: "Non-fiction",
  publishedYear: 1988,
  isbn: "978-0553380163",
  stock: 10,
  price: 18.99
};
```

### LIST OF OBJECT:

```javascript
book = [
  {
    id: 1,
    title: "The Great Gatsby",
    author: "F. Scott Fitzgerald",
    genre: "Fiction",
    publishedYear: 1925,
    isbn: "978-0743273565",
    stock: 20,
    price: 15.99
  },
  {
    id: 2,
    title: "To Kill a Mockingbird",
    author: "Harper Lee",
    genre: "Fiction",
    publishedYear: 1960,
    isbn: "978-0060935467",
    stock: 35,
    price: 10.99
  },
  {
    id: 3,
    title: "1984",
    author: "George Orwell",
    genre: "Dystopian",
    publishedYear: 1949,
    isbn: "978-0451524935",
    stock: 40,
    price: 9.99
  },
  {
    id: 4,
    title: "The Catcher in the Rye",
    author: "J.D. Salinger",
    genre: "Fiction",
    publishedYear: 1951,
    isbn: "978-0316769488",
    stock: 25,
    price: 8.99
  },
  {
    id: 5,
    title: "A Brief History of Time",
    author: "Stephen Hawking",
    genre: "Non-fiction",
    publishedYear: 1988,
    isbn: "978-0553380163",
    stock: 10,
    price: 18.99
  }
];
```

4. ### **University Table**
    

| **ID** | **Name** | **Location** | **Established Year** | **Type** | **Website** |
| --- | --- | --- | --- | --- | --- |
| 1 | University of the Philippines | Quezon City | 1908 | Public | [**www.up.edu.ph**](http://www.up.edu.ph/) |
| 2 | Ateneo de Manila University | Quezon City | 1859 | Private | [**www.ateneo.edu**](http://www.ateneo.edu/) |
| 3 | De La Salle University | Manila | 1911 | Private | [**www.dlsu.edu.ph**](http://www.dlsu.edu.ph/) |
| 4 | University of Santo Tomas | Manila | 1611 | Private | [**www.ust.edu.ph**](http://www.ust.edu.ph/) |
| 5 | Polytechnic University of the Philippines | Manila | 1904 | Public | [**www.pup.edu.ph**](http://www.pup.edu.ph/) |

### LIST:

```javascript
university_id_list = [1, 2, 3, 4, 5];
university_name_list = [
  "University of the Philippines",
  "Ateneo de Manila University",
  "De La Salle University",
  "University of Santo Tomas",
  "Polytechnic University of the Philippines"
];
university_location_list = [
  "Quezon City",
  "Quezon City",
  "Manila",
  "Manila",
  "Manila"
];
university_established_year_list = [1908, 1859, 1911, 1611, 1904];
university_type_list = ["Public", "Private", "Private", "Private", "Public"];
university_website_list = [
  "[www.up.edu.ph](http://www.up.edu.ph)",
  "[www.ateneo.edu](http://www.ateneo.edu)",
  "[www.dlsu.edu.ph](http://www.dlsu.edu.ph)",
  "[www.ust.edu.ph](http://www.ust.edu.ph)",
  "[www.pup.edu.ph](http://www.pup.edu.ph)"
];
```

### **OBJECT:**

```javascript
university1 = { 
  id: 1, 
  name: "University of the Philippines", 
  location: "Quezon City", 
  establishedYear: 1908, 
  type: "Public", 
  website: "[www.up.edu.ph](http://www.up.edu.ph)" 
};

university2 = { 
  id: 2, 
  name: "Ateneo de Manila University", 
  location: "Quezon City", 
  establishedYear: 1859, 
  type: "Private", 
  website: "[www.ateneo.edu](http://www.ateneo.edu)" 
};

university3 = { 
  id: 3, 
  name: "De La Salle University", 
  location: "Manila", 
  establishedYear: 1911, 
  type: "Private", 
  website: "[www.dlsu.edu.ph](http://www.dlsu.edu.ph)" 
};

university4 = { 
  id: 4, 
  name: "University of Santo Tomas", 
  location: "Manila", 
  establishedYear: 1611, 
  type: "Private", 
  website: "[www.ust.edu.ph](http://www.ust.edu.ph)" 
};

university5 = { 
  id: 5, 
  name: "Polytechnic University of the Philippines", 
  location: "Manila", 
  establishedYear: 1904, 
  type: "Public", 
  website: "[www.pup.edu.ph](http://www.pup.edu.ph)" 
};
```

### LIST OF OBJECT:

```javascript
const universities = [
  {
    id: 1,
    name: "University of the Philippines",
    location: "Quezon City",
    establishedYear: 1908,
    type: "Public",
    website: "http://www.up.edu.ph"
  },
  {
    id: 2,
    name: "Ateneo de Manila University",
    location: "Quezon City",
    establishedYear: 1859,
    type: "Private",
    website: "http://www.ateneo.edu"
  },
  {
    id: 3,
    name: "De La Salle University",
    location: "Manila",
    establishedYear: 1911,
    type: "Private",
    website: "http://www.dlsu.edu.ph"
  },
  {
    id: 4,
    name: "University of Santo Tomas",
    location: "Manila",
    establishedYear: 1611,
    type: "Private",
    website: "http://www.ust.edu.ph"
  },
  {
    id: 5,
    name: "Polytechnic University of the Philippines",
    location: "Manila",
    establishedYear: 1904,
    type: "Public",
    website: "http://www.pup.edu.ph"
  }
];
```

### **Restaurant Table**

| **ID** | **Name** | **Location** | **Cuisine Type** | **Established Year** | **Website or Contact** |
| --- | --- | --- | --- | --- | --- |
| 1 | Vikings Luxury Buffet | Pasay City | Buffet | 2011 | [**www.vikings.ph**](http://www.vikings.ph/) |
| 2 | Antonio's Restaurant | Tagaytay | Fine Dining | 2002 | [**www.antoniosrestaurant.ph**](http://www.antoniosrestaurant.ph/) |
| 3 | Mesa Filipino Moderne | Makati City | Filipino | 2009 | [**www.mesa.ph**](http://www.mesa.ph/) |
| 4 | Manam Comfort Filipino | Quezon City | Filipino | 2013 | [**www.manam.ph**](http://www.manam.ph/) |
| 5 | Ramen Nagi | Various Locations | Japanese | 2013 | [**www.ramennagi.com.ph**](http://www.ramennagi.com.ph/) |

###   
**LIST:**

```json
restaurant_id_list = [1, 2, 3, 4, 5];
restaurant_name_list = [
  "Vikings Luxury Buffet",
  "Antonio's Restaurant",
  "Mesa Filipino Moderne",
  "Manam Comfort Filipino",
  "Ramen Nagi"
];
restaurant_location_list = [
  "Pasay City",
  "Tagaytay",
  "Makati City",
  "Quezon City",
  "Various Locations"
];
restaurant_cuisine_type_list = [
  "Buffet",
  "Fine Dining",
  "Filipino",
  "Filipino",
  "Japanese"
];
restaurant_established_year_list = [2011, 2002, 2009, 2013, 2013];
restaurant_website_or_contact_list = [
  "www.vikings.ph",
  "www.antoniosrestaurant.ph",
  "www.mesa.ph",
  "www.manam.ph",
  "www.ramennagi.com.ph"
];
```

### OBJECT:

```javascript
restaurant1 = {
  id: 1,
  name: "Vikings Luxury Buffet",
  location: "Pasay City",
  cuisineType: "Buffet",
  establishedYear: 2011,
  websiteOrContact: "www.vikings.ph"
};

restaurant2 = {
  id: 2,
  name: "Antonio's Restaurant",
  location: "Tagaytay",
  cuisineType: "Fine Dining",
  establishedYear: 2002,
  websiteOrContact: "www.antoniosrestaurant.ph"
};

restaurant3 = {
  id: 3,
  name: "Mesa Filipino Moderne",
  location: "Makati City",
  cuisineType: "Filipino",
  establishedYear: 2009,
  websiteOrContact: "www.mesa.ph"
};

restaurant4 = {
  id: 4,
  name: "Manam Comfort Filipino",
  location: "Quezon City",
  cuisineType: "Filipino",
  establishedYear: 2013,
  websiteOrContact: "www.manam.ph"
};

restaurant5 = {
  id: 5,
  name: "Ramen Nagi",
  location: "Various Locations",
  cuisineType: "Japanese",
  establishedYear: 2013,
  websiteOrContact: "www.ramennagi.com.ph"
};
```

### LIST OF OBJECT:

```javascript
restaurants = [
  { 
    id: 1, 
    name: "Vikings Luxury Buffet", 
    location: "Pasay City", 
    cuisineType: "Buffet", 
    establishedYear: 2011, 
    websiteOrContact: "[www.vikings.ph](http://www.vikings.ph)" 
  },
  { 
    id: 2, 
    name: "Antonio's Restaurant", 
    location: "Tagaytay", 
    cuisineType: "Fine Dining", 
    establishedYear: 2002, 
    websiteOrContact: "[www.antoniosrestaurant.ph](http://www.antoniosrestaurant.ph)" 
  },
  { 
    id: 3, 
    name: "Mesa Filipino Moderne", 
    location: "Makati City", 
    cuisineType: "Filipino", 
    establishedYear: 2009, 
    websiteOrContact: "[www.mesa.ph](http://www.mesa.ph)" 
  },
  { 
    id: 4, 
    name: "Manam Comfort Filipino", 
    location: "Quezon City", 
    cuisineType: "Filipino", 
    establishedYear: 2013, 
    websiteOrContact: "[www.manam.ph](http://www.manam.ph)" 
  },
  { 
    id: 5, 
    name: "Ramen Nagi", 
    location: "Various Locations", 
    cuisineType: "Japanese", 
    establishedYear: 2013, 
    websiteOrContact: "[www.ramennagi.com.ph](http://www.ramennagi.com.ph)" 
  }
];
```
