Analyze the scenario for a retail store and identify minimum three different objects from the following
customer_name,
customer,
item_id,
description,
bill_amount,
price_per_unit,
item,
pays_bill,
purchases,
employee,
designation
I have tried item_id, bill_amount and designation as they are unique but the answer was wrong.
I also tried a lot of different options for quite a lot of time but did not succeed.
The objects are instances of a class for example employee, customer, item and purchase. In the case of customer, you may have a class name Customer which has it's specified attributes such as customer_name, ``customer_id` etc.
And when you are ready to create a new customer, you will create an object name customer or customer1 which would be instances of the class Customer.
objects are employee, customer, item and purchase.
customer
customer_name,
customer,
item
item_id,
description,
price_per_unit,
item,
purchase
pays_bill,
purchases,
bill_amount,
employee
employee,
designation
Main objects are employee, customer, item and "purchase" contains new fields with the combination of first 3 objects
The correct answer is Customer, Item, Employee
Related
The current scene is this:
There is a category table [category], the number of records is only more than 50, almost no increase, and the modification is rare.
There is a product table [product] currently millions of levels, will always increase.
These two are many-to-many relationships. One category will have more products, and each product will have multiple categories.
The category list is almost not changed, and there are about 1000 products in a category, and the list of a category will be changed not frequently.
Query requirements:
Query all categories (excluding the list of products under the category)
Query the category list by product_id
Query the product list by category_id
Operational requirements:
Modify the product list in category (add/delete a product to a category, sort the product list in a category, so the product list in category needs order.)
How many-to-many design of this kind of scene is better, there are some points:
1. If you follow the design of the SQL database, add a Category<-->Product relation table.
[Question] The order of each category of products is not well maintained. For example, the front-end performs a large-scale adjustment order on a category of products, and then requests it. The Category<-->Product relation table also needs to add an index field to indicate the order, and needs to update a lot of records. It is not particularly friendly to the operation requirements, is there any What can be optimized?
2. The way of NOSQL. Add a products:[] directly to the category to indicate a list of items in this category.
[Evaluation] In the query requirement, there is a requirement to query all categories (excluding the list of products under the category), which will pull out a lot of unnecessary data (products) at one time. Not applicable.
3. Add products:[] in the Category<-->Product association table
[Question] This can meet the operational requirements, but if you want to meet the Query requirments-2 [Query the category list by product_id], how to query it and will there be performance problems?
You need a third table (junction table) to complete the relationship. The keys must be primary keys along with a foreign key constraint.
tblProductCategories
PK product_id FK
PK category_id FK
I need help, how to make one-to-many queries, for example:
I have 2 collections: customers, orders
customers{
customerId,
fullName,
company,
email,
}
orders{
orderId,
customerId,
createdAt,
}
I want to list all orders in a table with some customers data (customer full name, compa
Congratulations, you are alone in the dark Firestore Forest. Bring back all you have learned of DBMS at the college days and get you hands dirty.
Alternative 1:
First you need to filter the customers that satisfies your criteria. Then, load ALL your orders and filter mannually. I'm not kidding, saddly. The same applies if you need to order orders by customer name, for example. I'll be very happy to see someone downvote this for being wrong.
Reference: https://firebase.google.com/docs/firestore/query-data/queries
Alternative 2:
Stop using Firestore. I think you already done that.
I'm not sure whether the auto generated id (object_id) of mongodb is unique across all the document or not. I've a dilemma about referencing.
Says I have a system which multiple users can create their own products and categories. So I will have product collection and category collection.
To get a category of a product, should I get the category by using user id and product id or product id alone is enough? since I will first get the product id using user id before I can find the category of that particular product.
I have a question in Entity Framework.
I have two tables: Customers and Addresses
The Customers table contains information about customers and Addresses contain information about the customer address. Both tables are linked together by CustomerID.
How can I get all Customers objects (from Customers) who are living in the USA (from Addresses) ?
Can anyone help?
You can use .Where like this:
List<Customer> usaCustomers = dbcontext.Customers.Where(c => c.Address.Country == "USA");
This assumes that:
Each customer has only one address
Address entity has Country property
I have an MVC app I am building as a learning project. I have a table with Payees, and a table with Categories. Certain Payees can make transactions of certain categories. For example, Payee A can make payments to Categories A, B and C. Payee B can maybe payments to categories B, C and D.
So, I have a PayeeCategory linking table, with a PayeeId and a CategoryId.
So see the categories the payee can make transactions against, it's a simple Select from PayeeCategory where PayeeId = this.PayeeId. And I join to the Category table to get the category names.
In the view, when I edit a Payee, I need to display a list of all categories, and and allow the user to select or unselect the categories that the current Payee is associated to.
So, in my ViewModel, I'd have a list of categorySelectableItems, which has maybe the CategoryId, the DisplayName and a Selected boolean field. To get the data, I need to Select from Categories, LEFT JOIN PayeeCategory, and where PayeeCategoryId is null, set the Selected to false, else true.
How would I do that ina single Linq statement?
Then, when the data comes back... how would I save the data? Would I have to delete all the relationships, and then re-add them based on the List<> values I get back?
Hope someone can guide me.
This was answered in a different question.
Linq query assistance