Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am a beginner in mySQL, just to be clear.

So, I have to make this database that is going to be connected to c# application.
The idea is to make an application for adopting a dog or cat. You can log in or register then when signed in you can navigate through menu where you one button is home button where all ads are visible then other button for dogs and other button for cats and in the end the add button where you can add a cat or dog to adopt.

My main problem is the design of the database tables.
The user table should be made out of columns with name, surname, username, password. But, do I need a table with a type of ad (cat or dog) or can I just make a table dog/cat where one column will represent the type of ad?
To mention, one user can add many ads but one ad can have two types of ad (cat/dog)..
To clarify, I want to make sure that when User is at the Add form, he can make sure he's adding a cat or dog and when he clicks add, the ad he is placing will pop up in the form where it belongs to..

I hope I am making sense.. thank you for your help!

What I have tried:

I have tried modeling the database through EER diagram and then made the database through forward engineering to get the code but I am not sure of the accuracy of the code and will it do right for the application
Posted
Updated 21-Jun-19 7:39am
Comments
BillWoodruff 22-Jun-19 18:12pm    
Since choice of cat-or-dog is binary, you could use a single boolean field.

1 solution

Firstly do not store passwords on a database. See this article Password Storage: How to do it.[^]

You might also find this useful User Login For WinForm Applications[^]

If it was me I would have a single table for the ads with a type column for 'cat','dog'. That makes it easily extensible if you want to start adopting tortoises for example.

On that table you will need a column that "points" at the User that owns it - the foreign key.
If you are struggling with the design then these articles might also help you Database Normalization (Explained in Simple English) - Essential SQL[^], 11 important database designing rules which I follow[^] or get a good book on the subject.
 
Share this answer
 
Comments
[no name] 22-Jun-19 12:15pm    
Thank you for your help.
Also, if I put the type column, what kind of datatype should I use if that one column can only get the value of cat or dog?
CHill60 25-Jun-19 7:52am    
Well you could start with a
varchar(25)
and actually store the text "cat", "dog", "tortoise" etc with each row. Purists would say to store "cat", "dog", "tortoise", etc in a separate table with a unique integer row identifier for each. You would then have an int column on your main table instead. However, I would just go with the varchar type.
BillWoodruff 22-Jun-19 18:10pm    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900