Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to ask experts here what is the best structure for database construction separate each table or reduce them all in big table


this screen shot of my database 

<img src="http://imageshack.com/a/img36/2562/hf9i.png" width="800px" />
Posted
Comments
Maciej Los 5-Mar-14 14:35pm    
Please, read CP's rules!

Generally, you can't create "one big table" without placing artificial restrictions on how many of an item may be contained at design time - and that tends to waste space enourmously.

For example, an invoice is unlikely to be a good candidate for "one big table" because there is no upper or lower limit on the number of items that must be listed on an invoice. As soon as you have an item which is related to a number of other items, it is generally best to maintain separate tables with a foreign key relationship.

The only time a single big table makes sense if when it is "flat" data with no hierarchical elements at all - and in that case, why not just use a big flat file instead of teh complexity of a database?
 
Share this answer
 
Comments
Maciej Los 5-Mar-14 14:40pm    
Deserves for 5 ;)
TheSniper105 5-Mar-14 16:43pm    
big flat file instead of teh complexity of a database

any link (more details)??
OriginalGriff 6-Mar-14 4:35am    
Files have no format: at the most basic level they are a collection of bytes (or bits if you want to be picky, but that depends on the storage medium to a large extent)

Applications impose a structure, a format, on that stream of bytes: this could be as simple as "lines" terminated with a newline character, or a table-like structure with "fixed length" rows. Or it can be a lot more complex than that, as it is with a database file, which contains a load of different structures which work together.

If you want to, you can create a file and treat it as fixed length rows - just use Seek and Read and Write within the stream - but it's a lot of work because you have to sort it all out yourself.

But - if you want to make a DB into "one big table" that is effectively what you have to do: tell the DB engine to ignore all the "clever stuff" it knows and can do for you and just flatten everything down to a basic file.
Don't do it - you end up with a lot more work!
The question makes no sense at all. It depends on the requirements, the structure of real data to be used, but of course "all in big table" will totally defeat the purpose of relational databases and relational model.
Probably you just need to educate yourself in databases in general, especially relational database. For example, see:
http://en.wikipedia.org/wiki/Database[^],
http://en.wikipedia.org/wiki/Relational_database[^],
http://en.wikipedia.org/wiki/Relational_model[^],
http://en.wikipedia.org/wiki/Relational_algebra[^],
http://en.wikipedia.org/wiki/Database_schema[^],
http://en.wikipedia.org/wiki/Database_normalization[^],
http://en.wikipedia.org/wiki/ACID[^].

This is just the very top level though… I cannot pretend that this list of topics is comprehensive or sufficient for any particular purpose. It just to give you some ideas…

—SA
 
Share this answer
 
Comments
Maciej Los 5-Mar-14 14:35pm    
+5!
Sergey Alexandrovich Kryukov 5-Mar-14 14:35pm    
Thank you, Maciej.
—SA

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