4

I would like to design and develop school application using PHP and MYSQL as backend. The frontend - a combination of HTML, JS and CSS - has a registration form for every school.

Every school has its own students, classes, teachers and the like. I would like to use a single database with one students table having a client column that refers to the owner of every record.

e'g: sutd_id, client_id, first_name, last_name......

e'g: class_id, client_id, description, blahblah....

Question 1

Will a WHERE clause with too many parameters affect performance? I mean thinks like WHERE id='blah' AND class_ID='blah' AND client_id='blah' AND enroll_date between 'time' AND 'AGO'.

If the case that affects performance, I've thought of creating views for every new client, example: When new successful registration takes place, I will create some extra views to the database by using new client's unique name.
e'g: new client which is abc is registered than automatically i will create these views: (abc_students, abc_classes....)

Question 2

Would this approach (the one with the views) affect the performance or accuracy of results?

Question 3

Is there another way to increase the performance, other that creating views?

gnat
  • 21,442
  • 29
  • 112
  • 288

2 Answers2

1

Views will not help with performance; they are effectively just queries with a Name. Indeed, they may actually make things worse and, IIRC, MySQL does suffer from this "View overhead".

Indexes are what you're looking for.

Sensible indexing can make millions of rows just as responsive as a handful of them.
Don't get carried away, though. Whilst well-chosen indexes will speed up selects, they need to be amended by every insert and delete (and, possibly, update) so the more of them that you have, the slower your update traffic might become.

Indexing, like most things database-y, is a "balancing act". You need to try things out and see what's "best" for your needs.

Phill W.
  • 11,891
  • 4
  • 21
  • 36
  • In some RDBMS, like Oracle views do improve performance since they are like telling the RDBMS: "hey, I will be running this query a lot". The optimizer doesn't have to calculate the fetching strategy everytime and it stays in the SQL cache longer. – Tulains Córdova Apr 26 '16 at 13:46
  • @TulainsCórdova that may be true for some RDBMS, but not Oracle -- it's ability to cache the SQL plan is not affected by whether the query uses views. – David Aldridge Nov 24 '16 at 09:22
0

If you want to partition the data by school/client, you'll probably want to look at schemas instead of views. A schema will put the tables (and indexes, triggers, etc) in a separate namespace. Depending on the database you use, you may be able to put individual schemas in separate files, which should give you the ability to put individual schools/clients on separate drives if one or more of them grows large enough to require that. Note, however, that while you can use the same data model in your application for all schemas, if you change a table definition you will have to change the table in each schema individually.

TMN
  • 11,313
  • 1
  • 21
  • 31