Is This Relational Database Sound or Can it be Improved? - sql

I am trying to create a database for an online instrumental shop. I designed this database and added a cart table but I don't know if this is a good implementation for a online shop with cart.

The database sounds ohk and can be improved in many ways to make it even perfect one.
The following links gives u more detail in depth
https://www.ntu.edu.sg/home/ehchua/programming/sql/Relational_Database_Design.html

Related

Which SQL table should I use to store `popularity` field

I am setting up a small E-commerce website using Django. My aim is to ensure that the landing page displays products in order of popularity. I am defining popularity as the total number of times a product was purchased.
In terms of design architecture, what is the best way of achieving this?
At first I thought of putting the popularity field inside the Product table. However, I suspect that I will get in trouble with caching further down the line. Perhaps it is best to create a PopularityDetails table with both product_id (pk) and popularity?
I see many website have this functionality so I would have thought that there must be a standard practice on this. Alas, I have not found any resources on the matter. Any help would be much appreciated.
Thanks in advance!

When is a good time use EAV?

I am trying to create a networking site to allow manufacturers to network with Producers. My boss wants other organizations to be able to upload excel files to the website of their products and have it stored in the database. Each product that people enter could have their own host of properties. Maybe the company could somehow control the attributes they want to display on said networking site. That said this seems like a time where I might end up with near inifinite amount of attributes and EAV seems like it makes alot of sense for this type of task.
I went here to see my different options:
How to design a product table for many kinds of product where each product has many parameters
Is this a good case to use EAV or no
and saw that there were these questions
Do you have a lot of product types ?
Do you need to handle "variants" of the products ?
Do you intend to add entirely new types of products ?
and the answer for all of them in my mind is yes SO I think this is a good time to use eav but I'm not sure because I know some people think EAV IS the the enemy. I also have no experience using a nosql database and maybe that is the direction I should think about going. if it matters at all im doing the back end with asp.net visual studio as of right now.
But on a sidenote I feel like this is a bad task to give a singular intern (still in college) to make a networking site this big when you are a small manufacturing company with no cs division... debating quitting.
regardless does anyone have any advice as to if I should stick with MySQL and try eav vs one of the other options from the first link.

Should I use EAV database design model or a lot of tables

I started a new application and now I am looking at two paths and don't know which is good way to continue.
I am building something like eCommerce site. I have a categories and subcategories.
The problem is that there are different type of products on site and each has different properties. And site must be filterable by those product properties.
This is my initial database design:
Products{ProductId, Name, ProductCategoryId}
ProductCategories{ProductCategoryId, Name, ParentId}
CategoryProperties{CategoryPropertyId, ProductCategoryId, Name}
ProductPropertyValues{ProductId, CategoryPropertyId, Value}
Now after some analysis I see that this design is actually EAV model and I read that people usually don't recommend this design.
It seems that dynamic sql queries are required for everything.
That's one way and I am looking at it right now.
Another way that I see is probably named a LOT WORK WAY but if it's better I want to go there.
To make table
Product{ProductId, CategoryId, Name, ManufacturerId}
and to make table inheritance in database wich means to make tables like
Cpus{ProductId ....}
HardDisks{ProductId ....}
MotherBoards{ProductId ....}
erc. for each product (1 to 1 relation).
I understand that this will be a very large database and very large application domain but is it better, easier and performance better than the option one with EAV design.
EAV is rarely a win. In your case I can see the appeal of EAV given that different categories will have different attributes and this will be hard to manage otherwise. However, suppose someone wants to search for "all hard drives with more than 3 platters, using a SATA interface, spinning at 10k rpm?" Your query in EAV will be painful. If you ever want to support a query like that, EAV is out.
There are other approaches however. You could consider an XML field with extended data or, if you are on PostgreSQL 9.2, a JSON field (XML is easier to search though). This would give you a significantly larger range of possible searches without the headaches of EAV. The tradeoff would be that schema enforcement would be harder.
This questions seems to discuss the issue in greater detail.
Apart from performance, extensibility and complexity discussed there, also take into account:
SQL databases such as SQL Server have full-text search features; so if you have a single field describing the product - full text search will index it and will be able to provide advanced semantic searches
take a look at no-sql systems that are all the rage right now; scalability should be quite good with them and they provide support for non-structured data such as the one you have. Hadoop and Casandra are good starting points.
You could very well work with the EAV model.
We do something similar with a Logistics application. It is built on .net though.
Apart from the tables, your application code has to handle the objects correctly.
See if you can add generic table for each object. It works for us.

Draw EER Model to create Store Database system

I asked the following question on a database site:
I am trying to build an EER Model for a Autostore that has 5 locations
and offers a range of auto products. They offer car repairs and
roadworthy tests as a service also. I need to be able to make
fortnightly reports on unfinished service jobs, and fortnightly
reports on the sales. They have a wide customer database filled with
full addresses. There is a constant inflow of new stock items and
restocking of old ones. There should also be a way to know the cost of
each item in stock and where its being held.
I swear I've researched it enough to be able to understand it by now
but Im really struggling to map this out as I'm constantly running
into a wall when dealing with the products that are being restocked,
sold and stocked by particular stores in different locations.
-I'm a total rookie with this kind of thing but if anyone can help me it would be amazing.
but I am struggling to find an answer and was thinking that maybe if I asked someone here to build an SQL setup it would lead me in the direction of being able to make the model or if there was a way of building the relational model then it would be a simple step from there, unless someone has the original answer - or all of them haha, hope you can help!
Thanks,
Jacob
If you are struggling with creating an EER diagram, my guess is that you may not have captured detailed enough requirements for the application. A clear understanding of the functionality the application should provide should lay the groundwork for what you need to model in the database.
Ask yourself these questions.
Have I created user profiles for each type of user the application will be used by?
Have I outlined every action these users will be performing on the application and the details of the actions?
These are just two of many questions that you have hopefully fully addressed. If you have addressed these topics and everything else fully, perhaps you just need a different approach in organizing your requirements.
Break it up into segments of data. For example, you'll need to create a system of tables that manages inventory. Which will need to then be linked up to a system of tables that manages sales and service records. Which will need to be linked to a system of tables that manages customers data. The sales/service and inventory control will need to be linked up to a system of tables that governs employees and their roles and ability to do things (security, privileges, etc). I can go on and on speaking theoretically about this, but this should hopefully be enough to get you started.
Good luck.

How to understand the business of AdventureWorks2008 DB

I am trying to understand AdventureWorks Database as most of the good examples on web and books are usually explained taking it as a sample database.
I found few links like
http://msdn.microsoft.com/en-us/library/ms124825(v=sql.100).aspx
http://merc.tv/img/fig/AdventureWorks2008_Conceptual.pdf
http://merc.tv/img/fig/AdventureWorks2008.gif
But I found them insufficient for explaining the business completely.
I tried to practice some queries as well so that I could get more knowledge about its business. But looking at 70 tables, I finds myself no were in the understanding of its Business.
Can you help me giving some good likes where I can get more details about it.
EDIT
I never read northwind database. Is it important to understand it to get a good grasp on AdventureWorks2008
Looking into what you are doing, I think it is not important for you to fully understand the AW business. If would be a better use of your time to understand the queries that are required and just the 2-3 tables in question rather than the entire database.
Even thought the MSTS certification book pulls from the AW DB, understanding that database is not part of the certification. If you have trouble with specific questions from your book, I would suggest you post what you are doing and what result you are trying to achieve.
I can go on explaining the business of AW but it will consume a lot of time as I cannot completely give the business understanding. You will only understand those things that I will describe here. I am currently going through this book- The Microsoft Datawarehouse Toolkit by Ralph Kimball. This is the best book that will give you a detailed understanding of AW business.
The business requirements ranges from a variety of people. From sales to technical people and others. So I suggest you read the first 3 chapters of this book as it simplifies learning the business.
If reading is not feasible I will show you another approach:
AdventureWorks (AW) is an imaginary manufacturer and seller of bicycles and its accessories (Table Production.ProductCategory).
The schemas help a lot in understanding their business, sales, employee data and product info.
The schemas involved in AW database are: HumanResources, Person, Production, Purchasing, Sales.
The table names are self-explanatory to a great extent. A simple query against each table will give you a fair amount of information about data.
You can go through this link that gives a brief overview of schemas used in AW
https://technet.microsoft.com/en-us/library/ms124894(v=sql.100).aspx
Think of yourself an interviewer and then frame questions that you will be asking the officers/managers of AW. Trust me there are lot of pitfalls if you are a newbie. Like, if you ask the question to business: "What do you want in your datawarehouse?" WRONG. This is your job to figure out.
All the best with exploration.
I have found this link below which if you follow the link depending on which sample database you are interested, it explains what it is all about:
https://msdn.microsoft.com/en-us/library/ms124501(v=sql.100).aspx
I have also fouund this ETL (but could not find for other databases):
http://msftdbprodsamples.codeplex.com/wikipage?title=%20AdventureWorksLTDiagram&referringTitle=AWSchemaDiag
I have also found these exercises:
http://sqlzoo.net/wiki/AdventureWorks