I am designing the database for a portal.Specifically, I have a users table that contains columns: id, username and password.
Also there are three types of users: buyers, sellers and brokers and each user has a separate table with columns: name, description, mobile,introducer etc.The broker table doesn't have introducer column.
Based on this design I want to create a two step registration form with first step login info and the second step profile info.
Now, the business rules dictate that a user can be a buyer, seller or broker.A user can have at most one profile(buyer, seller or broker). I want to keep the login details and the profile info separate in the database
What I have done:
I have created a separate table for users, brokers, buyers and sellers with user id as foreign key in the buyers , brokers and sellers table.
Now my question is
I am new to database designing and all help is appreciated.Thanks in advance.
To create a schemaIn Object Explorer, expand the Databases folder. Expand the database in which to create the new database schema. Right-click the Security folder, point to New, and select Schema. In the Schema - New dialog box, on the General page, enter a name for the new schema in the Schema name box.
There are mainly two tools you'd use to create a database schema. The first is an RDBMS, or a relational database management system. Examples of RDBMSs include SQL Server, MySQL, and PostgreSQL. The second and most important tool is SQL (structured query language).
As "A user can have at most one profile" it sounds like you'll benefit by adding a user_profile
table which would then be 'subtyped' by broker
, seller
and buyer
, adding additional fields as applicable.
A user
would have a 1:1 with user_profile
and user_profile
would have 1:0/1 with broker
, seller
and buyer
. I'd consider using the user_id
as the primary key to all these.
I think you will also find this answer useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With