Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6921237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:15:02+00:00 2026-05-27T10:15:02+00:00

The reason I am asking this is because it seems (for me) a lot

  • 0

The reason I am asking this is because it seems (for me) a lot easier to set-up a file management system in Java than to set up a complicated relational database in SQL. What would having an SQL relational database benefit me over the following example:

Example: a Products file that allows variable pricing for the same product

in Java:

public class Product implements Serializable {
    public static int productCount = 0;
    private final int productID;
    private final long productRegisterDate;
    private String productDescription;
    private List<ProductPrice> productPrices;
    Product (String desc) {
        productID = ++productCount;
        productRegisterDate = Calendar.getInstance().getTimeInMillis();
        productDescription = desc;
        productPrices = new ArrayList<ProductPrice>();
    }
    public Product addPrice(double price, String priceDesc) {
        productPrices.add(new ProductPrice(price, priceDesc);
        return this;
    }
    public void updateProduct(String desc, ArrayList<ProductPrice> prices) {
        productDescription = desc;
        productPrices = prices;
    }
    public int getID() return productID;
    public long getDateRegistered() return productRegisterDate;
    public String getDescription() return productDescription;
    public ArrayList<ProductPrice> getPrices() return productPrices;
}
public class ProductPrice implements Serializable {
    private double price;
    private String priceDescription;
    ProductPrice(double price, String priceDesc) {
        this.price = price;
        priceDescription = priceDesc;
    }
}

inserting products:

...
List<Product> myProducts = new ArrayList<Product>();
myProducts.add(new Product("product a")
    .addPrice(1.99,"250g pack")
    .addPrice(2.99,"500g pack");

find Product objects:

...
public Product findProductById(int pid) {
    for (Product p:myProducts)
        if (p.getID() == pid) return p;
    return null;
}
public List<Product> searchProducts(String searchTerm, int limit) {
    List<Product> results = new ArrayList<Product>();
    int count = 0;
    for (Product p:myProducts) {
        if (p.getDescription().indexOf(searchTerm)>-1) {
            results.add(p);
            count++;
            if (count >= limit) break;
        }
    return results;
}

query product info with object:

...
String productDescription = p.getDescription();

update product info without object:

public boolean updateProductByID(int pid, String desc, ArrayList<ProductPrice> prices) {
    Product p = null;
    try {
        p = findProductById(pid);
        p.updateProduct(desc, prices);
    } catch (NullPointerException e) {
        return false;
    }
    return true;
}

save/load data:

...
private final String SAVE_PATH = "C:/";
private final String PRODUCTS_FILE = "Products.dat";
public static boolean saveProducts(ArrayList<Product> myProducts) {
    ObjectOutputStream out = null;
    try {
        out = new ObjectOutputStream(new FileOutputStream(SAVE_PATH+PRODUCTS_FILE));
        out.writeObject(myProducts);
        out.close();
    } catch (IOException e) {
        return false;
    }
    return true;
}
public static boolean loadProducts(ArrayList<Product> myProducts) {
    ObjectInputStream in = null;
    try {
        in = new ObjectInputStream(new FileInputStream(SAVE_PATH+PRODUCTS_FILE));
        myProducts = (ArrayList<Product>) in.readObject();
        return true;
    } catch (IOException e1) {
        return false;
    } catch (ClassNotFoundException e2) {
        return false;
    }
}

Please advise me, I want to know all of the details.
Bear in mind I already have a Java application with class objects (i.e. Products, Orders, etc) and I am wondering if I should use a database to serve and store the data rather than the local file system.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:15:03+00:00Added an answer on May 27, 2026 at 10:15 am

    You can reinvent anything you want to, if you really want to.

    Pros:

    • You learn a lot.
    • You have complete control over the system.

    Cons:

    • You have complete control over the system.
    • You lose the experience of those who make a living making whatever system you reinvent.
    • You have to fix all bugs you find yourself.
    • You have to test it yourself (millions of people use RDBMS already, for example).
    • When you find a problem you won’t know if it’s your database system, or the system that uses it.

    So the question is, how much time are you willing to spend creating this?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The reason I'm asking this is because there is a validation in OpenERP that
The reason I'm asking is that this post http://amix.dk/blog/post/19577 Indicates that Node.js 0.2.2 seems
The reason for asking this question is because I want to be able to
The reason why I am asking this is because I was recommended by @Greg
I know this might be fairly Unity-specific, but the reason I am asking it
I'm not asking this question because of the merits of garbage collection first of
The reason I am asking is that I am thinking of building a foot
How should __nonzero__ be implemented using the Python C-API? The reason I'm asking is
The reason I want to sign the dll is because I want to add
The reason I need the inner class to be non static is because I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.